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

📄 dscparse.h

📁 GSview 4.6 PostScript previewer。Ghostscript在MS-Windows, OS/2 and Unix下的图形化接口
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2000-2003, Ghostgum Software Pty Ltd.  All rights reserved.
  
  This file is part of GSview.
   
  This program is distributed with NO WARRANTY OF ANY KIND.  No author
  or distributor accepts any responsibility for the consequences of using it,
  or for whether it serves any particular purpose or works at all, unless he
  or she says so in writing.  Refer to the GSview Licence (the "Licence") 
  for full details.
   
  Every copy of GSview must include a copy of the Licence, normally in a 
  plain ASCII text file named LICENCE.  The Licence grants you the right 
  to copy, modify and redistribute GSview, but only under certain conditions 
  described in the Licence.  Among other things, the Licence requires that 
  the copyright notice and this notice be preserved on all copies.
*/

/* $Id: dscparse.h,v 1.15 2004/01/08 09:15:41 ghostgum Exp $ */
/* Interface for the DSC parser. */

#ifndef dscparse_INCLUDED
#  define dscparse_INCLUDED

/* Some local types that may need modification */
typedef int GSBOOL;
typedef unsigned long GSDWORD;	/* must be at least 32 bits */
typedef unsigned int GSWORD;	/* must be at least 16 bits */

#ifndef FALSE
# define FALSE ((GSBOOL)0)
# define TRUE ((GSBOOL)(!FALSE))
#endif

/* DSC_OFFSET is an unsigned integer which holds the offset
 * from the start of a file to a particular DSC comment,
 * or the length of a file.
 * Normally it is "unsigned long" which is commonly 32 bits. 
 * Change it if you need to handle larger files.
 */
#ifndef DSC_OFFSET
# define DSC_OFFSET unsigned long
#endif
#ifndef DSC_OFFSET_FORMAT
# define DSC_OFFSET_FORMAT "lu"	/* for printf */
#endif

#ifndef dsc_private
# ifdef private
#  define dsc_private private
# else
#  define dsc_private static
# endif
#endif

#ifndef min
# define min(a,b)  ((a) < (b) ? (a) : (b))
#endif
#ifndef max
# define max(a,b)  ((a) > (b) ? (a) : (b))
#endif

/* maximum legal length of lines in a DSC compliant file */
#define DSC_LINE_LENGTH 255

/* memory for strings is allocated in chunks of this length */
#define CDSC_STRING_CHUNK 4096

/* page array is allocated in chunks of this many pages */
#define CDSC_PAGE_CHUNK 128	

/* buffer length for storing lines passed to dsc_scan_data() */
/* must be at least 2 * DSC_LINE_LENGTH */
/* We choose 8192 as twice the length passed to us by GSview */
#define CDSC_DATA_LENGTH 8192

/* Return codes from dsc_scan_data()
 *  < 0     = error
 *  >=0     = OK
 *
 *  -1      = error, usually insufficient memory.
 *  0-9     = normal
 *  10-99   = internal codes, should not be seen.
 *  100-999 = identifier of last DSC comment processed.
 */

typedef enum CDSC_RETURN_CODE_e {
  CDSC_ERROR		= -1,	/* Fatal error, usually insufficient memory */

  CDSC_OK		= 0,	/* OK, no DSC comment found */
  CDSC_NOTDSC	 	= 1,	/* Not DSC, or DSC is being ignored */

/* Any section */
  CDSC_UNKNOWNDSC	= 100,	/* DSC comment not recognised */

/* Header section */
  CDSC_PSADOBE		= 200,	/* %!PS-Adobe- */
  CDSC_BEGINCOMMENTS	= 201,	/* %%BeginComments */
  CDSC_ENDCOMMENTS	= 202,	/* %%EndComments */
  CDSC_PAGES		= 203,	/* %%Pages: */
  CDSC_CREATOR		= 204,	/* %%Creator: */
  CDSC_CREATIONDATE	= 205,	/* %%CreationDate: */
  CDSC_TITLE		= 206,	/* %%Title: */
  CDSC_FOR		= 207,	/* %%For: */
  CDSC_LANGUAGELEVEL	= 208,	/* %%LanguageLevel: */
  CDSC_BOUNDINGBOX	= 209,	/* %%BoundingBox: */
  CDSC_ORIENTATION	= 210,	/* %%Orientation: */
  CDSC_PAGEORDER	= 211,	/* %%PageOrder: */
  CDSC_DOCUMENTMEDIA	= 212,	/* %%DocumentMedia: */
  CDSC_DOCUMENTPAPERSIZES    = 213,	/* %%DocumentPaperSizes: */
  CDSC_DOCUMENTPAPERFORMS    = 214,	/* %%DocumentPaperForms: */
  CDSC_DOCUMENTPAPERCOLORS   = 215,	/* %%DocumentPaperColors: */
  CDSC_DOCUMENTPAPERWEIGHTS  = 216,	/* %%DocumentPaperWeights: */
  CDSC_DOCUMENTDATA	     = 217,	/* %%DocumentData: */
  CDSC_REQUIREMENTS	     = 218,	/* IGNORED %%Requirements: */
  CDSC_DOCUMENTNEEDEDFONTS   = 219,	/* IGNORED %%DocumentNeededFonts: */
  CDSC_DOCUMENTSUPPLIEDFONTS = 220,	/* IGNORED %%DocumentSuppliedFonts: */
  CDSC_HIRESBOUNDINGBOX	     = 221,	/* %%HiResBoundingBox: */
  CDSC_CROPBOX	     	     = 222,	/* %%CropBox: */
  CDSC_PLATEFILE     	     = 223,	/* %%PlateFile: (DCS 2.0) */
  CDSC_DOCUMENTPROCESSCOLORS = 224,	/* %%DocumentProcessColors: */
  CDSC_DOCUMENTCUSTOMCOLORS  = 225,	/* %%DocumentCustomColors: */
  CDSC_CMYKCUSTOMCOLOR       = 226,	/* %%CMYKCustomColor: */
  CDSC_RGBCUSTOMCOLOR        = 227,	/* %%RGBCustomColor: */

/* Preview section */
  CDSC_BEGINPREVIEW	= 301,	/* %%BeginPreview */
  CDSC_ENDPREVIEW	= 302,	/* %%EndPreview */

/* Defaults section */
  CDSC_BEGINDEFAULTS	= 401,	/* %%BeginDefaults */
  CDSC_ENDDEFAULTS	= 402,	/* %%EndDefaults */
/* also %%PageMedia, %%PageOrientation, %%PageBoundingBox */

/* Prolog section */
  CDSC_BEGINPROLOG	= 501,	/* %%BeginProlog */
  CDSC_ENDPROLOG	= 502,	/* %%EndProlog */
  CDSC_BEGINFONT	= 503,	/* IGNORED %%BeginFont */
  CDSC_ENDFONT		= 504,	/* IGNORED %%EndFont */
  CDSC_BEGINFEATURE	= 505,	/* IGNORED %%BeginFeature */
  CDSC_ENDFEATURE	= 506,	/* IGNORED %%EndFeature */
  CDSC_BEGINRESOURCE	= 507,	/* IGNORED %%BeginResource */
  CDSC_ENDRESOURCE	= 508,	/* IGNORED %%EndResource */
  CDSC_BEGINPROCSET	= 509,	/* IGNORED %%BeginProcSet */
  CDSC_ENDPROCSET	= 510,	/* IGNORED %%EndProcSet */

/* Setup section */
  CDSC_BEGINSETUP	= 601,	/* %%BeginSetup */
  CDSC_ENDSETUP		= 602,	/* %%EndSetup */
  CDSC_FEATURE		= 603,	/* IGNORED %%Feature: */
  CDSC_PAPERCOLOR	= 604,	/* IGNORED %%PaperColor: */
  CDSC_PAPERFORM	= 605,	/* IGNORED %%PaperForm: */
  CDSC_PAPERWEIGHT	= 606,	/* IGNORED %%PaperWeight: */
  CDSC_PAPERSIZE	= 607,	/* %%PaperSize: */
/* also %%Begin/EndFeature, %%Begin/EndResource */

/* Page section */
  CDSC_PAGE		= 700,	/* %%Page: */
  CDSC_PAGETRAILER	= 701,	/* IGNORED %%PageTrailer */
  CDSC_BEGINPAGESETUP	= 702,	/* IGNORED %%BeginPageSetup */
  CDSC_ENDPAGESETUP	= 703,	/* IGNORED %%EndPageSetup */
  CDSC_PAGEMEDIA	= 704,	/* %%PageMedia: */
/* also %%PaperColor, %%PaperForm, %%PaperWeight, %%PaperSize */
  CDSC_PAGEORIENTATION	= 705,	/* %%PageOrientation: */
  CDSC_PAGEBOUNDINGBOX	= 706,	/* %%PageBoundingBox: */
/* also %%Begin/EndFont, %%Begin/EndFeature */
/* also %%Begin/EndResource, %%Begin/EndProcSet */
  CDSC_INCLUDEFONT	= 707,	/* IGNORED %%IncludeFont: */
  CDSC_VIEWINGORIENTATION = 708, /* %%ViewingOrientation: */
  CDSC_PAGECROPBOX	= 709,	/* %%PageCropBox: */

/* Trailer section */
  CDSC_TRAILER		= 800,	/* %%Trailer */
/* also %%Pages, %%BoundingBox, %%Orientation, %%PageOrder, %%DocumentMedia */ 
/* %%Page is recognised as an error */
/* also %%DocumentNeededFonts, %%DocumentSuppliedFonts */

/* End of File */
  CDSC_EOF		= 900	/* %%EOF */
} CDSC_RETURN_CODE;


/* stored in dsc->preview */ 
typedef enum CDSC_PREVIEW_TYPE_e {
    CDSC_NOPREVIEW = 0,
    CDSC_EPSI = 1,
    CDSC_TIFF = 2,
    CDSC_WMF = 3,
    CDSC_PICT = 4
} CDSC_PREVIEW_TYPE;

/* stored in dsc->page_order */ 
typedef enum CDSC_PAGE_ORDER_e {
    CDSC_ORDER_UNKNOWN = 0,
    CDSC_ASCEND = 1,
    CDSC_DESCEND = 2,
    CDSC_SPECIAL = 3
} CDSC_PAGE_ORDER;

/* stored in dsc->page_orientation and dsc->page[pagenum-1].orientation */ 
typedef enum CDSC_ORIENTATION_ENUM_e {
    CDSC_ORIENT_UNKNOWN = 0,
    CDSC_PORTRAIT = 1,
    CDSC_LANDSCAPE = 2,
    CDSC_UPSIDEDOWN = 3,
    CDSC_SEASCAPE = 4
} CDSC_ORIENTATION_ENUM;

/* stored in dsc->document_data */
typedef enum CDSC_DOCUMENT_DATA_e {
    CDSC_DATA_UNKNOWN = 0,
    CDSC_CLEAN7BIT = 1,
    CDSC_CLEAN8BIT = 2,
    CDSC_BINARY = 3
} CDSC_DOCUMENT_DATA ;

typedef struct CDSCBBOX_S {
    int llx;
    int lly;
    int urx;
    int ury;
} CDSCBBOX;

typedef struct CDSCFBBOX_S {
    float fllx;
    float flly;
    float furx;
    float fury;
} CDSCFBBOX;

typedef struct CDSCMEDIA_S {
    const char *name;
    float width;	/* PostScript points */
    float height;
    float weight;	/* GSM */
    const char *colour;
    const char *type;
    CDSCBBOX *mediabox;	/* Used by GSview for PDF MediaBox */
} CDSCMEDIA;

#define CDSC_KNOWN_MEDIA 25
extern const CDSCMEDIA dsc_known_media[CDSC_KNOWN_MEDIA];

typedef struct CDSCCTM_S { /* used for %%ViewingOrientation */
    float xx;
    float xy;
    float yx;
    float yy;
    /* float ty; */
    /* float ty; */
} CDSCCTM;

typedef struct CDSCPAGE_S {
    int ordinal;
    const char *label;
    DSC_OFFSET begin;
    DSC_OFFSET end;
    unsigned int orientation;
    const CDSCMEDIA *media;
    CDSCBBOX *bbox;  /* PageBoundingBox, also used by GSview for PDF CropBox */
    CDSCCTM *viewing_orientation;
    /* Added 2001-10-19 */
    CDSCFBBOX *crop_box;  /* CropBox */
} CDSCPAGE;

/* binary DOS EPS header */
typedef struct CDSCDOSEPS_S {
    GSDWORD ps_begin;
    GSDWORD ps_length;
    GSDWORD wmf_begin;
    GSDWORD wmf_length;
    GSDWORD tiff_begin;
    GSDWORD tiff_length;
    GSWORD checksum;
} CDSCDOSEPS;

/* macbinary header */
typedef struct CDSCMACBIN_S {
    GSDWORD data_begin;		/* EPS */
    GSDWORD data_length;
    GSDWORD resource_begin;	/* PICT */
    GSDWORD resource_length;
} CDSCMACBIN;

/* rather than allocated every string with malloc, we allocate
 * chunks of 4k and place the (usually) short strings in these

⌨️ 快捷键说明

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