⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dscparse.h

📁 GSview 4.6 PostScript previewer。Ghostscript在MS-Windows, OS/2 and Unix下的图形化接口
💻 H
📖 第 1 页 / 共 2 页
字号:
 * chunks.
 */
typedef struct CDSCSTRING_S CDSCSTRING;
struct CDSCSTRING_S {
    unsigned int index;
    unsigned int length;
    char *data;
    CDSCSTRING *next;
};

/* Desktop Color Separations - DCS 2.0 */
typedef struct CDCS2_S CDCS2;
struct CDCS2_S {
    char *colourname;
    char *filetype;	/* Usually EPS */
    /* For multiple file DCS, location and filename will be set */
    char *location;	/* Local or NULL */
    char *filename;
    /* For single file DCS, begin will be not equals to end */
    DSC_OFFSET begin;
    DSC_OFFSET end;
    /* We maintain the separations as a linked list */
    CDCS2 *next;
};

typedef enum CDSC_COLOUR_TYPE_e {
    CDSC_COLOUR_UNKNOWN=0,
    CDSC_COLOUR_PROCESS=1,		/* %%DocumentProcessColors: */
    CDSC_COLOUR_CUSTOM=2		/* %%DocumentCustomColors: */
} CDSC_COLOUR_TYPE;

typedef enum CDSC_CUSTOM_COLOUR_e {
    CDSC_CUSTOM_COLOUR_UNKNOWN=0,
    CDSC_CUSTOM_COLOUR_RGB=1,		/* %%RGBCustomColor: */
    CDSC_CUSTOM_COLOUR_CMYK=2		/* %%CMYKCustomColor: */
} CDSC_CUSTOM_COLOUR;

typedef struct CDSCCOLOUR_S CDSCCOLOUR;
struct CDSCCOLOUR_S {
    char *name;
    CDSC_COLOUR_TYPE type;
    CDSC_CUSTOM_COLOUR custom;
    /* If custom is CDSC_CUSTOM_COLOUR_RGB, the next three are correct */
    float red;
    float green;
    float blue;
    /* If colourtype is CDSC_CUSTOM_COLOUR_CMYK, the next four are correct */
    float cyan;
    float magenta;
    float yellow;
    float black;
    /* Next colour */
    CDSCCOLOUR *next;
};

/* DSC error reporting */

typedef enum CDSC_MESSAGE_ERROR_e {
  CDSC_MESSAGE_BBOX = 0,
  CDSC_MESSAGE_EARLY_TRAILER = 1,
  CDSC_MESSAGE_EARLY_EOF = 2,
  CDSC_MESSAGE_PAGE_IN_TRAILER = 3,
  CDSC_MESSAGE_PAGE_ORDINAL = 4,
  CDSC_MESSAGE_PAGES_WRONG = 5,
  CDSC_MESSAGE_EPS_NO_BBOX = 6,
  CDSC_MESSAGE_EPS_PAGES = 7,
  CDSC_MESSAGE_NO_MEDIA = 8,
  CDSC_MESSAGE_ATEND = 9,
  CDSC_MESSAGE_DUP_COMMENT = 10,
  CDSC_MESSAGE_DUP_TRAILER = 11,
  CDSC_MESSAGE_BEGIN_END = 12,
  CDSC_MESSAGE_BAD_SECTION = 13,
  CDSC_MESSAGE_LONG_LINE = 14,
  CDSC_MESSAGE_INCORRECT_USAGE = 15
} CDSC_MESSAGE_ERROR;

/* severity */
typedef enum CDSC_MESSAGE_SEVERITY_e {
  CDSC_ERROR_INFORM	= 0,	/* Not an error */
  CDSC_ERROR_WARN	= 1,	/* Not a DSC error itself,  */
  CDSC_ERROR_ERROR	= 2	/* DSC error */
} CDSC_MESSAGE_SEVERITY;

/* response */
typedef enum CDSC_RESPONSE_e {
  CDSC_RESPONSE_OK	= 0,
  CDSC_RESPONSE_CANCEL	= 1,
  CDSC_RESPONSE_IGNORE_ALL = 2
} CDSC_RESPONSE;

extern const char * const dsc_message[];

#ifndef CDSC_TYPEDEF
#define CDSC_TYPEDEF
typedef struct CDSC_s CDSC;
#endif

struct CDSC_s {
char dummy[1024];
    /* public data */
    GSBOOL dsc;			/* TRUE if DSC comments found */
    GSBOOL ctrld;		/* TRUE if has CTRLD at start of stream */
    GSBOOL pjl;			/* TRUE if has HP PJL at start of stream */
    GSBOOL epsf;		/* TRUE if EPSF */
    GSBOOL pdf;			/* TRUE if Portable Document Format */
    unsigned int preview;	/* enum CDSC_PREVIEW_TYPE */
    char *dsc_version;	/* first line of file */
    unsigned int language_level;
    unsigned int document_data;	/* Clean7Bit, Clean8Bit, Binary */
				/* enum CDSC_DOCUMENT_DATA */
    /* DSC sections */
    DSC_OFFSET begincomments;
    DSC_OFFSET endcomments;
    DSC_OFFSET beginpreview;
    DSC_OFFSET endpreview;
    DSC_OFFSET begindefaults;
    DSC_OFFSET enddefaults;
    DSC_OFFSET beginprolog;
    DSC_OFFSET endprolog;
    DSC_OFFSET beginsetup;
    DSC_OFFSET endsetup;
    DSC_OFFSET begintrailer;
    DSC_OFFSET endtrailer;
    CDSCPAGE *page;
    unsigned int page_count;	/* number of %%Page: pages in document */
    unsigned int page_pages;	/* number of pages in document from %%Pages: */
    unsigned int page_order;	/* enum CDSC_PAGE_ORDER */
    unsigned int page_orientation;  /* the default page orientation */
				/* enum CDSC_ORIENTATION */
    CDSCCTM *viewing_orientation;
    unsigned int media_count;	/* number of media items */
    CDSCMEDIA **media;		/* the array of media */
    const CDSCMEDIA *page_media;/* the default page media */
    CDSCBBOX *bbox;		/* the document bounding box */
    CDSCBBOX *page_bbox;	/* the default page bounding box */
    CDSCDOSEPS *doseps;		/* DOS binary header */
    char *dsc_title;
    char *dsc_creator;
    char *dsc_date;
    char *dsc_for;

    unsigned int max_error;	/* highest error number that will be reported */
    const int *severity;	/* array of severity values, one per error */


    /* private data */
    void *caller_data;		/* pointer to be provided when calling */
			        /* error and debug callbacks */
    int id;			/* last DSC comment found */
    int scan_section;		/* section currently being scanned */
				/* enum CDSC_SECTION */

    DSC_OFFSET doseps_end;	/* ps_begin+ps_length, otherwise 0 */
    unsigned int page_chunk_length; /* number of pages allocated */
    DSC_OFFSET file_length;	/* length of document */
		/* If provided we try to recognise %%Trailer and %%EOF */
		/* incorrectly embedded inside document. */
		/* We will not parse DSC comments beyond this point. */
		/* Can be left set to default value of 0 */
    int skip_document;		/* recursion level of %%BeginDocument: */
    int skip_bytes;		/* #bytes to ignore from BeginData: */
				/* or DOSEPS preview section */
    int skip_lines;		/* #lines to ignore from BeginData: */
    GSBOOL skip_pjl;		/* TRUE if skip PJL until first PS comment */ 
    int begin_font_count;	/* recursion level of %%BeginFont */
    int begin_feature_count;	/* recursion level of %%BeginFeature */
    int begin_resource_count;	/* recursion level of %%BeginResource */
    int begin_procset_count;	/* recursion level of %%BeginProcSet */

    /* buffer for input */
    char data[CDSC_DATA_LENGTH];/* start of buffer */
    unsigned int data_length; 	/* length of data in buffer */
    unsigned int data_index;	/* offset to next char in buffer */
    DSC_OFFSET data_offset;	/* offset from start of document */
			       	/* to byte in data[0] */
    GSBOOL eof;			/* TRUE if there is no more data */

    /* information about DSC line */
    char *line;			/* pointer to last read DSC line */
				/* not null terminated */
    unsigned int line_length; 	/* number of characters in line */
    GSBOOL eol;			/* TRUE if dsc_line contains EOL */
    GSBOOL last_cr;		/* TRUE if last line ended in \r */
				/* check next time for \n */
    unsigned int line_count;	/* line number */
    GSBOOL long_line;		/* TRUE if found a line longer than 255 characters */
    char last_line[256];	/* previous DSC line, used for %%+ */

    /* more efficient string storage (for short strings) than malloc */
    CDSCSTRING *string_head;	/* linked list head */
    CDSCSTRING *string;		/* current list item */

    /* memory allocation routines */
    void *(*memalloc)(size_t size, void *closure_data);
    void (*memfree)(void *ptr, void *closure_data);
    void *mem_closure_data;

    /* function for printing debug messages */
    void (*debug_print_fn)(void *caller_data, const char *str);

    /* function for reporting errors in DSC comments */
    int (*dsc_error_fn)(void *caller_data, CDSC *dsc, 
	unsigned int explanation, const char *line, unsigned int line_len);

    /* public data */
    /* Added 2001-10-01 */
    CDSCFBBOX *hires_bbox;	/* the hires document bounding box */
    CDSCFBBOX *crop_box;	/* the size of the trimmed page */
    CDCS2 *dcs2;		/* Desktop Color Separations 2.0 */
    CDSCCOLOUR *colours;		/* Process and custom colours */

    /* private data */
    /* Added 2002-03-30 */
    int ref_count;

    /* public data */
    /* Added 2003-07-15 */
    CDSCMACBIN *macbin;		/* Mac Binary header */
};


/* Public functions */

/* Create and initialise DSC parser */
CDSC *dsc_init(void *caller_data);

CDSC *dsc_init_with_alloc(
    void *caller_data,
    void *(*memalloc)(size_t size, void *closure_data),
    void (*memfree)(void *ptr, void *closure_data),
    void *closure_data);

/* Free the DSC parser */
void dsc_free(CDSC *dsc);

/* Reference counting for dsc structure */
/* dsc_new is the same as dsc_init */
/* dsc_ref is called by dsc_new */
/* If dsc_unref decrements to 0, dsc_free will be called */
CDSC *dsc_new(void *caller_data);
int dsc_ref(CDSC *dsc);
int dsc_unref(CDSC *dsc);

/* Tell DSC parser how long document will be, to allow ignoring
 * of early %%Trailer and %%EOF.  This is optional.
 */
void dsc_set_length(CDSC *dsc, DSC_OFFSET len);

/* Process a buffer containing DSC comments and PostScript */
int dsc_scan_data(CDSC *dsc, const char *data, int len);

/* All data has been processed, fixup any DSC errors */
int dsc_fixup(CDSC *dsc);

/* Install error query function */
void dsc_set_error_function(CDSC *dsc, 
    int (*dsc_error_fn)(void *caller_data, CDSC *dsc, 
	unsigned int explanation, const char *line, unsigned int line_len));

/* Install print function for debug messages */
void dsc_set_debug_function(CDSC *dsc, 
	void (*debug_fn)(void *caller_data, const char *str));

/* Print a message to debug output, if provided */
void dsc_debug_print(CDSC *dsc, const char *str);

/* Given a page number, find the filename for multi-file DCS 2.0 */
const char * dsc_find_platefile(CDSC *dsc, int page);

/* Compare two strings, case insensitive */
int dsc_stricmp(const char *s, const char *t);

/* should be internal only functions, but made available to 
 * GSview for handling PDF
 */
int dsc_add_page(CDSC *dsc, int ordinal, char *label);
int dsc_add_media(CDSC *dsc, CDSCMEDIA *media);
int dsc_set_page_bbox(CDSC *dsc, unsigned int page_number, 
    int llx, int lly, int urx, int ury);

/* in dscutil.c */
void dsc_display(CDSC *dsc, void (*dfn)(void *ptr, const char *str));
#endif /* dscparse_INCLUDED */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -