xref: /plan9/sys/src/cmd/gs/src/dscparse.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 2000-2003, 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 license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: dscparse.h,v 1.12 2003/08/14 22:28:13 ghostgum Exp $*/
18 /* Interface for the DSC parser. */
19 
20 #ifndef dscparse_INCLUDED
21 #  define dscparse_INCLUDED
22 
23 /* Some local types that may need modification */
24 typedef int GSBOOL;
25 typedef unsigned long GSDWORD;	/* must be at least 32 bits */
26 typedef unsigned int GSWORD;	/* must be at least 16 bits */
27 
28 #ifndef FALSE
29 # define FALSE ((GSBOOL)0)
30 # define TRUE ((GSBOOL)(!FALSE))
31 #endif
32 
33 /* DSC_OFFSET is an unsigned integer which holds the offset
34  * from the start of a file to a particular DSC comment,
35  * or the length of a file.
36  * Normally it is "unsigned long" which is commonly 32 bits.
37  * Change it if you need to handle larger files.
38  */
39 #ifndef DSC_OFFSET
40 # define DSC_OFFSET unsigned long
41 #endif
42 #ifndef DSC_OFFSET_FORMAT
43 # define DSC_OFFSET_FORMAT "lu"	/* for printf */
44 #endif
45 
46 #ifndef dsc_private
47 # ifdef private
48 #  define dsc_private private
49 # else
50 #  define dsc_private static
51 # endif
52 #endif
53 
54 #ifndef min
55 # define min(a,b)  ((a) < (b) ? (a) : (b))
56 #endif
57 #ifndef max
58 # define max(a,b)  ((a) > (b) ? (a) : (b))
59 #endif
60 
61 /* maximum legal length of lines in a DSC compliant file */
62 #define DSC_LINE_LENGTH 255
63 
64 /* memory for strings is allocated in chunks of this length */
65 #define CDSC_STRING_CHUNK 4096
66 
67 /* page array is allocated in chunks of this many pages */
68 #define CDSC_PAGE_CHUNK 128
69 
70 /* buffer length for storing lines passed to dsc_scan_data() */
71 /* must be at least 2 * DSC_LINE_LENGTH */
72 /* We choose 8192 as twice the length passed to us by GSview */
73 #define CDSC_DATA_LENGTH 8192
74 
75 /* Return codes from dsc_scan_data()
76  *  < 0     = error
77  *  >=0     = OK
78  *
79  *  -1      = error, usually insufficient memory.
80  *  0-9     = normal
81  *  10-99   = internal codes, should not be seen.
82  *  100-999 = identifier of last DSC comment processed.
83  */
84 
85 typedef enum CDSC_RETURN_CODE_e {
86   CDSC_ERROR		= -1,	/* Fatal error, usually insufficient memory */
87 
88   CDSC_OK		= 0,	/* OK, no DSC comment found */
89   CDSC_NOTDSC	 	= 1,	/* Not DSC, or DSC is being ignored */
90 
91 /* Any section */
92   CDSC_UNKNOWNDSC	= 100,	/* DSC comment not recognised */
93 
94 /* Header section */
95   CDSC_PSADOBE		= 200,	/* %!PS-Adobe- */
96   CDSC_BEGINCOMMENTS	= 201,	/* %%BeginComments */
97   CDSC_ENDCOMMENTS	= 202,	/* %%EndComments */
98   CDSC_PAGES		= 203,	/* %%Pages: */
99   CDSC_CREATOR		= 204,	/* %%Creator: */
100   CDSC_CREATIONDATE	= 205,	/* %%CreationDate: */
101   CDSC_TITLE		= 206,	/* %%Title: */
102   CDSC_FOR		= 207,	/* %%For: */
103   CDSC_LANGUAGELEVEL	= 208,	/* %%LanguageLevel: */
104   CDSC_BOUNDINGBOX	= 209,	/* %%BoundingBox: */
105   CDSC_ORIENTATION	= 210,	/* %%Orientation: */
106   CDSC_PAGEORDER	= 211,	/* %%PageOrder: */
107   CDSC_DOCUMENTMEDIA	= 212,	/* %%DocumentMedia: */
108   CDSC_DOCUMENTPAPERSIZES    = 213,	/* %%DocumentPaperSizes: */
109   CDSC_DOCUMENTPAPERFORMS    = 214,	/* %%DocumentPaperForms: */
110   CDSC_DOCUMENTPAPERCOLORS   = 215,	/* %%DocumentPaperColors: */
111   CDSC_DOCUMENTPAPERWEIGHTS  = 216,	/* %%DocumentPaperWeights: */
112   CDSC_DOCUMENTDATA	     = 217,	/* %%DocumentData: */
113   CDSC_REQUIREMENTS	     = 218,	/* IGNORED %%Requirements: */
114   CDSC_DOCUMENTNEEDEDFONTS   = 219,	/* IGNORED %%DocumentNeededFonts: */
115   CDSC_DOCUMENTSUPPLIEDFONTS = 220,	/* IGNORED %%DocumentSuppliedFonts: */
116   CDSC_HIRESBOUNDINGBOX	     = 221,	/* %%HiResBoundingBox: */
117   CDSC_CROPBOX	     	     = 222,	/* %%CropBox: */
118   CDSC_PLATEFILE     	     = 223,	/* %%PlateFile: (DCS 2.0) */
119   CDSC_DOCUMENTPROCESSCOLORS = 224,	/* %%DocumentProcessColors: */
120   CDSC_DOCUMENTCUSTOMCOLORS  = 225,	/* %%DocumentCustomColors: */
121   CDSC_CMYKCUSTOMCOLOR       = 226,	/* %%CMYKCustomColor: */
122   CDSC_RGBCUSTOMCOLOR        = 227,	/* %%RGBCustomColor: */
123 
124 /* Preview section */
125   CDSC_BEGINPREVIEW	= 301,	/* %%BeginPreview */
126   CDSC_ENDPREVIEW	= 302,	/* %%EndPreview */
127 
128 /* Defaults section */
129   CDSC_BEGINDEFAULTS	= 401,	/* %%BeginDefaults */
130   CDSC_ENDDEFAULTS	= 402,	/* %%EndDefaults */
131 /* also %%PageMedia, %%PageOrientation, %%PageBoundingBox */
132 
133 /* Prolog section */
134   CDSC_BEGINPROLOG	= 501,	/* %%BeginProlog */
135   CDSC_ENDPROLOG	= 502,	/* %%EndProlog */
136   CDSC_BEGINFONT	= 503,	/* IGNORED %%BeginFont */
137   CDSC_ENDFONT		= 504,	/* IGNORED %%EndFont */
138   CDSC_BEGINFEATURE	= 505,	/* IGNORED %%BeginFeature */
139   CDSC_ENDFEATURE	= 506,	/* IGNORED %%EndFeature */
140   CDSC_BEGINRESOURCE	= 507,	/* IGNORED %%BeginResource */
141   CDSC_ENDRESOURCE	= 508,	/* IGNORED %%EndResource */
142   CDSC_BEGINPROCSET	= 509,	/* IGNORED %%BeginProcSet */
143   CDSC_ENDPROCSET	= 510,	/* IGNORED %%EndProcSet */
144 
145 /* Setup section */
146   CDSC_BEGINSETUP	= 601,	/* %%BeginSetup */
147   CDSC_ENDSETUP		= 602,	/* %%EndSetup */
148   CDSC_FEATURE		= 603,	/* IGNORED %%Feature: */
149   CDSC_PAPERCOLOR	= 604,	/* IGNORED %%PaperColor: */
150   CDSC_PAPERFORM	= 605,	/* IGNORED %%PaperForm: */
151   CDSC_PAPERWEIGHT	= 606,	/* IGNORED %%PaperWeight: */
152   CDSC_PAPERSIZE	= 607,	/* %%PaperSize: */
153 /* also %%Begin/EndFeature, %%Begin/EndResource */
154 
155 /* Page section */
156   CDSC_PAGE		= 700,	/* %%Page: */
157   CDSC_PAGETRAILER	= 701,	/* IGNORED %%PageTrailer */
158   CDSC_BEGINPAGESETUP	= 702,	/* IGNORED %%BeginPageSetup */
159   CDSC_ENDPAGESETUP	= 703,	/* IGNORED %%EndPageSetup */
160   CDSC_PAGEMEDIA	= 704,	/* %%PageMedia: */
161 /* also %%PaperColor, %%PaperForm, %%PaperWeight, %%PaperSize */
162   CDSC_PAGEORIENTATION	= 705,	/* %%PageOrientation: */
163   CDSC_PAGEBOUNDINGBOX	= 706,	/* %%PageBoundingBox: */
164 /* also %%Begin/EndFont, %%Begin/EndFeature */
165 /* also %%Begin/EndResource, %%Begin/EndProcSet */
166   CDSC_INCLUDEFONT	= 707,	/* IGNORED %%IncludeFont: */
167   CDSC_VIEWINGORIENTATION = 708, /* %%ViewingOrientation: */
168   CDSC_PAGECROPBOX	= 709,	/* %%PageCropBox: */
169 
170 /* Trailer section */
171   CDSC_TRAILER		= 800,	/* %%Trailer */
172 /* also %%Pages, %%BoundingBox, %%Orientation, %%PageOrder, %%DocumentMedia */
173 /* %%Page is recognised as an error */
174 /* also %%DocumentNeededFonts, %%DocumentSuppliedFonts */
175 
176 /* End of File */
177   CDSC_EOF		= 900	/* %%EOF */
178 } CDSC_RETURN_CODE;
179 
180 
181 /* stored in dsc->preview */
182 typedef enum CDSC_PREVIEW_TYPE_e {
183     CDSC_NOPREVIEW = 0,
184     CDSC_EPSI = 1,
185     CDSC_TIFF = 2,
186     CDSC_WMF = 3,
187     CDSC_PICT = 4
188 } CDSC_PREVIEW_TYPE;
189 
190 /* stored in dsc->page_order */
191 typedef enum CDSC_PAGE_ORDER_e {
192     CDSC_ORDER_UNKNOWN = 0,
193     CDSC_ASCEND = 1,
194     CDSC_DESCEND = 2,
195     CDSC_SPECIAL = 3
196 } CDSC_PAGE_ORDER;
197 
198 /* stored in dsc->page_orientation and dsc->page[pagenum-1].orientation */
199 typedef enum CDSC_ORIENTATION_ENUM_e {
200     CDSC_ORIENT_UNKNOWN = 0,
201     CDSC_PORTRAIT = 1,
202     CDSC_LANDSCAPE = 2,
203     CDSC_UPSIDEDOWN = 3,
204     CDSC_SEASCAPE = 4
205 } CDSC_ORIENTATION_ENUM;
206 
207 /* stored in dsc->document_data */
208 typedef enum CDSC_DOCUMENT_DATA_e {
209     CDSC_DATA_UNKNOWN = 0,
210     CDSC_CLEAN7BIT = 1,
211     CDSC_CLEAN8BIT = 2,
212     CDSC_BINARY = 3
213 } CDSC_DOCUMENT_DATA ;
214 
215 typedef struct CDSCBBOX_S {
216     int llx;
217     int lly;
218     int urx;
219     int ury;
220 } CDSCBBOX;
221 
222 typedef struct CDSCFBBOX_S {
223     float fllx;
224     float flly;
225     float furx;
226     float fury;
227 } CDSCFBBOX;
228 
229 typedef struct CDSCMEDIA_S {
230     const char *name;
231     float width;	/* PostScript points */
232     float height;
233     float weight;	/* GSM */
234     const char *colour;
235     const char *type;
236     CDSCBBOX *mediabox;	/* Used by GSview for PDF MediaBox */
237 } CDSCMEDIA;
238 
239 #define CDSC_KNOWN_MEDIA 11
240 extern const CDSCMEDIA dsc_known_media[CDSC_KNOWN_MEDIA];
241 
242 typedef struct CDSCCTM_S { /* used for %%ViewingOrientation */
243     float xx;
244     float xy;
245     float yx;
246     float yy;
247     /* float ty; */
248     /* float ty; */
249 } CDSCCTM;
250 
251 typedef struct CDSCPAGE_S {
252     int ordinal;
253     const char *label;
254     DSC_OFFSET begin;
255     DSC_OFFSET end;
256     unsigned int orientation;
257     const CDSCMEDIA *media;
258     CDSCBBOX *bbox;  /* PageBoundingBox, also used by GSview for PDF CropBox */
259     CDSCCTM *viewing_orientation;
260     /* Added 2001-10-19 */
261     CDSCFBBOX *crop_box;  /* CropBox */
262 } CDSCPAGE;
263 
264 /* binary DOS EPS header */
265 typedef struct CDSCDOSEPS_S {
266     GSDWORD ps_begin;
267     GSDWORD ps_length;
268     GSDWORD wmf_begin;
269     GSDWORD wmf_length;
270     GSDWORD tiff_begin;
271     GSDWORD tiff_length;
272     GSWORD checksum;
273 } CDSCDOSEPS;
274 
275 /* macbinary header */
276 typedef struct CDSCMACBIN_S {
277     GSDWORD data_begin;		/* EPS */
278     GSDWORD data_length;
279     GSDWORD resource_begin;	/* PICT */
280     GSDWORD resource_length;
281 } CDSCMACBIN;
282 
283 /* rather than allocated every string with malloc, we allocate
284  * chunks of 4k and place the (usually) short strings in these
285  * chunks.
286  */
287 typedef struct CDSCSTRING_S CDSCSTRING;
288 struct CDSCSTRING_S {
289     unsigned int index;
290     unsigned int length;
291     char *data;
292     CDSCSTRING *next;
293 };
294 
295 /* Desktop Color Separations - DCS 2.0 */
296 typedef struct CDCS2_S CDCS2;
297 struct CDCS2_S {
298     char *colourname;
299     char *filetype;	/* Usually EPS */
300     /* For multiple file DCS, location and filename will be set */
301     char *location;	/* Local or NULL */
302     char *filename;
303     /* For single file DCS, begin will be not equals to end */
304     DSC_OFFSET begin;
305     DSC_OFFSET end;
306     /* We maintain the separations as a linked list */
307     CDCS2 *next;
308 };
309 
310 typedef enum CDSC_COLOUR_TYPE_e {
311     CDSC_COLOUR_UNKNOWN=0,
312     CDSC_COLOUR_PROCESS=1,		/* %%DocumentProcessColors: */
313     CDSC_COLOUR_CUSTOM=2		/* %%DocumentCustomColors: */
314 } CDSC_COLOUR_TYPE;
315 
316 typedef enum CDSC_CUSTOM_COLOUR_e {
317     CDSC_CUSTOM_COLOUR_UNKNOWN=0,
318     CDSC_CUSTOM_COLOUR_RGB=1,		/* %%RGBCustomColor: */
319     CDSC_CUSTOM_COLOUR_CMYK=2		/* %%CMYKCustomColor: */
320 } CDSC_CUSTOM_COLOUR;
321 
322 typedef struct CDSCCOLOUR_S CDSCCOLOUR;
323 struct CDSCCOLOUR_S {
324     char *name;
325     CDSC_COLOUR_TYPE type;
326     CDSC_CUSTOM_COLOUR custom;
327     /* If custom is CDSC_CUSTOM_COLOUR_RGB, the next three are correct */
328     float red;
329     float green;
330     float blue;
331     /* If colourtype is CDSC_CUSTOM_COLOUR_CMYK, the next four are correct */
332     float cyan;
333     float magenta;
334     float yellow;
335     float black;
336     /* Next colour */
337     CDSCCOLOUR *next;
338 };
339 
340 /* DSC error reporting */
341 
342 typedef enum CDSC_MESSAGE_ERROR_e {
343   CDSC_MESSAGE_BBOX = 0,
344   CDSC_MESSAGE_EARLY_TRAILER = 1,
345   CDSC_MESSAGE_EARLY_EOF = 2,
346   CDSC_MESSAGE_PAGE_IN_TRAILER = 3,
347   CDSC_MESSAGE_PAGE_ORDINAL = 4,
348   CDSC_MESSAGE_PAGES_WRONG = 5,
349   CDSC_MESSAGE_EPS_NO_BBOX = 6,
350   CDSC_MESSAGE_EPS_PAGES = 7,
351   CDSC_MESSAGE_NO_MEDIA = 8,
352   CDSC_MESSAGE_ATEND = 9,
353   CDSC_MESSAGE_DUP_COMMENT = 10,
354   CDSC_MESSAGE_DUP_TRAILER = 11,
355   CDSC_MESSAGE_BEGIN_END = 12,
356   CDSC_MESSAGE_BAD_SECTION = 13,
357   CDSC_MESSAGE_LONG_LINE = 14,
358   CDSC_MESSAGE_INCORRECT_USAGE = 15
359 } CDSC_MESSAGE_ERROR;
360 
361 /* severity */
362 typedef enum CDSC_MESSAGE_SEVERITY_e {
363   CDSC_ERROR_INFORM	= 0,	/* Not an error */
364   CDSC_ERROR_WARN	= 1,	/* Not a DSC error itself,  */
365   CDSC_ERROR_ERROR	= 2	/* DSC error */
366 } CDSC_MESSAGE_SEVERITY;
367 
368 /* response */
369 typedef enum CDSC_RESPONSE_e {
370   CDSC_RESPONSE_OK	= 0,
371   CDSC_RESPONSE_CANCEL	= 1,
372   CDSC_RESPONSE_IGNORE_ALL = 2
373 } CDSC_RESPONSE;
374 
375 extern const char * const dsc_message[];
376 
377 #ifndef CDSC_TYPEDEF
378 #define CDSC_TYPEDEF
379 typedef struct CDSC_s CDSC;
380 #endif
381 
382 struct CDSC_s {
383 char dummy[1024];
384     /* public data */
385     GSBOOL dsc;			/* TRUE if DSC comments found */
386     GSBOOL ctrld;		/* TRUE if has CTRLD at start of stream */
387     GSBOOL pjl;			/* TRUE if has HP PJL at start of stream */
388     GSBOOL epsf;		/* TRUE if EPSF */
389     GSBOOL pdf;			/* TRUE if Portable Document Format */
390     unsigned int preview;	/* enum CDSC_PREVIEW_TYPE */
391     char *dsc_version;	/* first line of file */
392     unsigned int language_level;
393     unsigned int document_data;	/* Clean7Bit, Clean8Bit, Binary */
394 				/* enum CDSC_DOCUMENT_DATA */
395     /* DSC sections */
396     DSC_OFFSET begincomments;
397     DSC_OFFSET endcomments;
398     DSC_OFFSET beginpreview;
399     DSC_OFFSET endpreview;
400     DSC_OFFSET begindefaults;
401     DSC_OFFSET enddefaults;
402     DSC_OFFSET beginprolog;
403     DSC_OFFSET endprolog;
404     DSC_OFFSET beginsetup;
405     DSC_OFFSET endsetup;
406     DSC_OFFSET begintrailer;
407     DSC_OFFSET endtrailer;
408     CDSCPAGE *page;
409     unsigned int page_count;	/* number of %%Page: pages in document */
410     unsigned int page_pages;	/* number of pages in document from %%Pages: */
411     unsigned int page_order;	/* enum CDSC_PAGE_ORDER */
412     unsigned int page_orientation;  /* the default page orientation */
413 				/* enum CDSC_ORIENTATION */
414     CDSCCTM *viewing_orientation;
415     unsigned int media_count;	/* number of media items */
416     CDSCMEDIA **media;		/* the array of media */
417     const CDSCMEDIA *page_media;/* the default page media */
418     CDSCBBOX *bbox;		/* the document bounding box */
419     CDSCBBOX *page_bbox;	/* the default page bounding box */
420     CDSCDOSEPS *doseps;		/* DOS binary header */
421     char *dsc_title;
422     char *dsc_creator;
423     char *dsc_date;
424     char *dsc_for;
425 
426     unsigned int max_error;	/* highest error number that will be reported */
427     const int *severity;	/* array of severity values, one per error */
428 
429 
430     /* private data */
431     void *caller_data;		/* pointer to be provided when calling */
432 			        /* error and debug callbacks */
433     int id;			/* last DSC comment found */
434     int scan_section;		/* section currently being scanned */
435 				/* enum CDSC_SECTION */
436 
437     DSC_OFFSET doseps_end;	/* ps_begin+ps_length, otherwise 0 */
438     unsigned int page_chunk_length; /* number of pages allocated */
439     DSC_OFFSET file_length;	/* length of document */
440 		/* If provided we try to recognise %%Trailer and %%EOF */
441 		/* incorrectly embedded inside document. */
442 		/* We will not parse DSC comments beyond this point. */
443 		/* Can be left set to default value of 0 */
444     int skip_document;		/* recursion level of %%BeginDocument: */
445     int skip_bytes;		/* #bytes to ignore from BeginData: */
446 				/* or DOSEPS preview section */
447     int skip_lines;		/* #lines to ignore from BeginData: */
448     GSBOOL skip_pjl;		/* TRUE if skip PJL until first PS comment */
449     int begin_font_count;	/* recursion level of %%BeginFont */
450     int begin_feature_count;	/* recursion level of %%BeginFeature */
451     int begin_resource_count;	/* recursion level of %%BeginResource */
452     int begin_procset_count;	/* recursion level of %%BeginProcSet */
453 
454     /* buffer for input */
455     char data[CDSC_DATA_LENGTH];/* start of buffer */
456     unsigned int data_length; 	/* length of data in buffer */
457     unsigned int data_index;	/* offset to next char in buffer */
458     DSC_OFFSET data_offset;	/* offset from start of document */
459 			       	/* to byte in data[0] */
460     GSBOOL eof;			/* TRUE if there is no more data */
461 
462     /* information about DSC line */
463     char *line;			/* pointer to last read DSC line */
464 				/* not null terminated */
465     unsigned int line_length; 	/* number of characters in line */
466     GSBOOL eol;			/* TRUE if dsc_line contains EOL */
467     GSBOOL last_cr;		/* TRUE if last line ended in \r */
468 				/* check next time for \n */
469     unsigned int line_count;	/* line number */
470     GSBOOL long_line;		/* TRUE if found a line longer than 255 characters */
471     char last_line[256];	/* previous DSC line, used for %%+ */
472 
473     /* more efficient string storage (for short strings) than malloc */
474     CDSCSTRING *string_head;	/* linked list head */
475     CDSCSTRING *string;		/* current list item */
476 
477     /* memory allocation routines */
478     void *(*memalloc)(size_t size, void *closure_data);
479     void (*memfree)(void *ptr, void *closure_data);
480     void *mem_closure_data;
481 
482     /* function for printing debug messages */
483     void (*debug_print_fn)(void *caller_data, const char *str);
484 
485     /* function for reporting errors in DSC comments */
486     int (*dsc_error_fn)(void *caller_data, CDSC *dsc,
487 	unsigned int explanation, const char *line, unsigned int line_len);
488 
489     /* public data */
490     /* Added 2001-10-01 */
491     CDSCFBBOX *hires_bbox;	/* the hires document bounding box */
492     CDSCFBBOX *crop_box;	/* the size of the trimmed page */
493     CDCS2 *dcs2;		/* Desktop Color Separations 2.0 */
494     CDSCCOLOUR *colours;		/* Process and custom colours */
495 
496     /* private data */
497     /* Added 2002-03-30 */
498     int ref_count;
499 
500     /* public data */
501     /* Added 2003-07-15 */
502     CDSCMACBIN *macbin;		/* Mac Binary header */
503 };
504 
505 
506 /* Public functions */
507 
508 /* Create and initialise DSC parser */
509 CDSC *dsc_init(void *caller_data);
510 
511 CDSC *dsc_init_with_alloc(
512     void *caller_data,
513     void *(*memalloc)(size_t size, void *closure_data),
514     void (*memfree)(void *ptr, void *closure_data),
515     void *closure_data);
516 
517 /* Free the DSC parser */
518 void dsc_free(CDSC *dsc);
519 
520 /* Reference counting for dsc structure */
521 /* dsc_new is the same as dsc_init */
522 /* dsc_ref is called by dsc_new */
523 /* If dsc_unref decrements to 0, dsc_free will be called */
524 CDSC *dsc_new(void *caller_data);
525 int dsc_ref(CDSC *dsc);
526 int dsc_unref(CDSC *dsc);
527 
528 /* Tell DSC parser how long document will be, to allow ignoring
529  * of early %%Trailer and %%EOF.  This is optional.
530  */
531 void dsc_set_length(CDSC *dsc, DSC_OFFSET len);
532 
533 /* Process a buffer containing DSC comments and PostScript */
534 int dsc_scan_data(CDSC *dsc, const char *data, int len);
535 
536 /* All data has been processed, fixup any DSC errors */
537 int dsc_fixup(CDSC *dsc);
538 
539 /* Install error query function */
540 void dsc_set_error_function(CDSC *dsc,
541     int (*dsc_error_fn)(void *caller_data, CDSC *dsc,
542 	unsigned int explanation, const char *line, unsigned int line_len));
543 
544 /* Install print function for debug messages */
545 void dsc_set_debug_function(CDSC *dsc,
546 	void (*debug_fn)(void *caller_data, const char *str));
547 
548 /* Print a message to debug output, if provided */
549 void dsc_debug_print(CDSC *dsc, const char *str);
550 
551 /* Given a page number, find the filename for multi-file DCS 2.0 */
552 const char * dsc_find_platefile(CDSC *dsc, int page);
553 
554 /* Compare two strings, case insensitive */
555 int dsc_stricmp(const char *s, const char *t);
556 
557 /* should be internal only functions, but made available to
558  * GSview for handling PDF
559  */
560 int dsc_add_page(CDSC *dsc, int ordinal, char *label);
561 int dsc_add_media(CDSC *dsc, CDSCMEDIA *media);
562 int dsc_set_page_bbox(CDSC *dsc, unsigned int page_number,
563     int llx, int lly, int urx, int ury);
564 
565 /* in dscutil.c */
566 void dsc_display(CDSC *dsc, void (*dfn)(void *ptr, const char *str));
567 #endif /* dscparse_INCLUDED */
568