~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/dscparse.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

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