"Fossies" - the Fresh Open Source Software Archive

Member "epstool-3.08/src/cgssrv.h" (10 Jun 2005, 6405 Bytes) of package /linux/misc/old/ghost/ghostgum/epstool-3.08-os2.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Copyright (C) 2001-2002 Ghostgum Software Pty Ltd.  All rights reserved.
    2 
    3   This software is provided AS-IS with no warranty, either express or
    4   implied.
    5 
    6   This software is distributed under licence and may not be copied,
    7   modified or distributed except as expressly authorised under the terms
    8   of the licence contained in the file LICENCE in this distribution.
    9 
   10   For more information about licensing, please refer to
   11   http://www.ghostgum.com.au/ or contact Ghostsgum Software Pty Ltd, 
   12   218 Gallaghers Rd, Glen Waverley VIC 3150, AUSTRALIA, 
   13   Fax +61 3 9886 6616.
   14 */
   15 
   16 /* $Id: cgssrv.h,v 1.6 2003/01/18 02:36:40 ghostgum Exp $ */
   17 /* Ghostscript server header */
   18 
   19 /* Public */
   20 
   21 /* These error codes are returned where GS error codes
   22  * may be used.  GS uses 0 for success, -ve for error,
   23  * and <-100 for more serious errors.
   24  * We use <-200 to avoid confusion.
   25  */
   26 typedef enum GSREQ_ERROR_e {
   27     GSREQ_ERROR_NOERROR = 0,        /* normal */
   28     GSREQ_ERROR_PAGERANGE = -201,   /* page out of range */
   29     GSREQ_ERROR_NOMOREPAGE = -202,  /* non-DSC and no more pages */
   30     GSREQ_ERROR_GS = -203,      /* Ghostscript returned an error */
   31     GSREQ_ERROR_FILE = -204,        /* Problem with reading file */
   32     GSREQ_ERROR_SETDEVICE = -205,   /* Probably due to lack of memory */
   33                     /* so reset the page size. */
   34     GSREQ_ERROR_INTERNAL = -206,    /* Probably due to lack of memory */
   35     GSREQ_ERROR_UNKNOWN = -299
   36 } GSREQ_ERROR;
   37 
   38 typedef enum GSREQ_ACTION_e {
   39     GSREQ_ACTION_DISPLAY = 0,   
   40     /* Display a page. */ 
   41     GSREQ_ACTION_CONVERT = 1,   
   42     /* Convert to bitmap, PDF etc. */ 
   43     GSREQ_ACTION_ABORT = 2, 
   44     /* Abort GS, but don't unload GS DLL */
   45     /* Not sure if this will be used */
   46     GSREQ_ACTION_UNLOAD = 3,
   47     /* We about to exit, so unload GS DLL */
   48     /* Also used if we are changing GS version */
   49     GSREQ_ACTION_CLOSE_THREAD = 4
   50     /* We exiting GSview */
   51 } GSREQ_ACTION;
   52 
   53 
   54 typedef enum CONVERT_OUTPUT_e {
   55     CONVERT_FILE,   /* -sOutputFile="output" */
   56     CONVERT_PIPE,   /* -sOutputFile="%pipe%output" */
   57     CONVERT_HANDLE  /* -sOutputFile="%handle%output" */
   58 } CONVERT_OUTPUT;
   59 
   60 typedef struct GSREQ_CONVERT_s GSREQ_CONVERT;
   61 
   62 struct GSREQ_CONVERT_s {
   63     CONVERT_OUTPUT method; /* determines meaning of output */
   64     TCHAR output[MAXSTR];
   65     char gsdevice[MAXSTR];
   66     PAGELIST pagelist;
   67     /* FIX: should we include page size here, or use PAGESPEC? */
   68 };
   69 
   70 
   71 struct GSREQ_s {
   72     GSREQ *next;
   73     GSREQ_ACTION action;
   74     PAGESPEC pagespec;      /* valid if action is GSREQ_ACTION_DISPLAY */
   75     GSREQ_CONVERT convert;  /* valid if action is GSREQ_ACTION_CONVERT */
   76     CDSC *dsc;
   77     BOOL pdf;
   78     BOOL dcs2multi; /* DCS 2.0 separation in separate file */
   79     BOOL temp_ps;   /* Temporary PostScript file created from bitmap.
   80              * This file should be deleted when the request
   81              * is removed from the queue.
   82              */
   83     View *view;     /* The view that made this request. */
   84             /* We send notifications to this view. */
   85 };
   86 
   87 
   88 GSSRV * gssrv_new(GSview *app);
   89 int gssrv_ref(GSSRV *s);
   90 int gssrv_unref(GSSRV *s);
   91 GSview * gssrv_app(GSSRV *s);
   92 GSIMAGE * gssrv_img(GSSRV *s);
   93 GGTHREAD * gssrv_thread_handle(GSSRV *s);
   94 int gssrv_request(GSSRV *s, GSREQ *reqnew);
   95 void gssrv_notify_view(GSSRV *s, int message, int param);
   96 void gssrv_page_callback(GSSRV *s);
   97 unsigned int gssrv_format(DISPLAY_FORMAT df);
   98 void gssrv_run_thread(void *arg);
   99 void plsrv_run_thread(void *arg);
  100 const char *gssrv_error_message(int id);
  101 
  102 /* platform specific */
  103 int gssrv_poll(GSSRV *s);
  104 
  105 
  106 /**********************************************/
  107 /* Private */
  108 
  109 #ifdef DEFINE_CGSSRV
  110 
  111 struct GSSRV_s {
  112     void *handle;       /* Platform specific handle */
  113 
  114     int refcount;       /* Number of users of this object */
  115     GSview *app;        /* GSview app object */
  116     GSIMAGE *gsimg;         /* display device image */
  117 
  118     /* A linked list of requests. */
  119     /* The currently pending request is head. */
  120     /* The request list is NULL if there is nothing to do. */
  121     GSREQ *req;
  122     
  123     /* Before send a document or page to GS, we set request_removed to FALSE.
  124      * If we get a page callback, request_removed will be set to TRUE and the
  125      * request removed from the list.  If we don't get a callback (e.g beyond last 
  126      * page of non-DSC, or EPS without showpage), then request_removed will be
  127      * still be TRUE and we need to remove the request afterwards.
  128      */
  129     BOOL request_removed;    /* TRUE if we stopped at a page and removed the request */
  130     
  131     /* The last request we received.
  132      * This affects whether we just advance to the next page of the 
  133      * non-DSC document or whether we need to restart Ghostscript.
  134      * Once we start sending the document or page to GS this is also
  135      * the current request.
  136      */
  137     GSREQ lastreq;
  138 
  139     BOOL close_thread;      /* Set to when we wnat to exit */
  140                 /* This overides all other requests */
  141     BOOL abort;         /* Ignore errors and exit GS */
  142     BOOL unload;        /* Unload GS, because we are exiting,
  143                  * or because we need to use a different
  144                  * GS, or because someone else needs to
  145                  * use GS DLL.
  146                  */
  147 
  148     BOOL waiting;       /* Used when singlethread to determine
  149                  * if we are polling or waiting.
  150                  * Ignored when multithread.
  151                      */
  152     GGEVENT event;      /* Semaphore for synchronising threads */
  153     GGTHREAD thread_handle; /* GS thread */
  154 
  155     /* PDF page count is obtained when GS opens file */
  156     int pdf_page_first;
  157     int pdf_page_count;
  158     /* PDF media box, crop box and rotate are obtained when a page is opened */
  159     BBOX pdf_media_box;
  160     BBOX pdf_crop_box;
  161     ORIENT pdf_orient;
  162 
  163     /* GhostPCL read from stdin, so we need to keep the file open */
  164     GFile *gf;          /* stdin for GhostPCL */
  165 
  166     /* Buffer for storing stdout which we search for text tags
  167      * information about the PDF file.
  168      */
  169 #define MAX_TAG_LEN 4096
  170     char pdf_tag_line[MAX_TAG_LEN];
  171     int pdf_page_number;
  172     PDFLINK *pdf_link_head;
  173 };
  174 
  175 int gssrv_remove(GSSRV *s, GSREQ *req);
  176 void gssrv_request_translate(GSSRV *s);
  177 int gssrv_set_lastreq(GSSRV *s, GSREQ *req);
  178 BOOL gssrv_check_requests(GSSRV *s);
  179 BOOL gssrv_check_abort(GSSRV *s);
  180 int gssrv_event_wait(GSSRV *s);
  181 int gssrv_run_string(GSSRV *s, const char *str);
  182 int gssrv_run_formatted(GSSRV *s, const char *str, ...);
  183 
  184 
  185 /* platform specific */
  186 int gssrv_platform_init(GSSRV *s);
  187 int gssrv_platform_finish(GSSRV *s);
  188 int gssrv_event_wait(GSSRV *s);
  189 int gssrv_event_post(GSSRV *s);
  190 
  191 #endif /* DEFINE_GSSRV */