home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gsview13 / src / ps.h < prev    next >
C/C++ Source or Header  |  1995-12-09  |  5KB  |  166 lines

  1. /*
  2.  * ps.h -- Include file for PostScript routines.
  3.  * Copyright (C) 1992, 1994  Timothy O. Theisen.  All rights reserved.
  4.  *
  5.  * This file is part of Ghostview.
  6.  *
  7.  * Ghostview is distributed with NO WARRANTY OF ANY KIND.  No author or
  8.  * distributor accepts any responsibility for the consequences of using
  9.  * it, or for whether it serves any particular purpose or works at all,
  10.  * unless he or she says so in writing.  Refer to the Ghostview Free
  11.  * Public License (the "License") for full details.
  12.  *
  13.  * Every copy of Ghostview must include a copy of the License, normally
  14.  * in a plain ASCII text file named PUBLIC.  The License grants you the
  15.  * right to copy, modify and redistribute Ghostview, but only under
  16.  * certain conditions described in the License.  Among other things, the
  17.  * License requires that the copyright notice and this notice be preserved
  18.  * on all copies.
  19.  *
  20.  *   Author: Tim Theisen           Systems Programmer
  21.  * Internet: tim@cs.wisc.edu       Department of Computer Sciences
  22.  *     UUCP: uwvax!tim             University of Wisconsin-Madison
  23.  *    Phone: (608)262-0438         1210 West Dayton Street
  24.  *      FAX: (608)262-9777         Madison, WI   53706
  25.  */
  26.  
  27. #ifndef NeedFunctionPrototypes
  28. #if defined(FUNCPROTO) || defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) || defined(__TURBOC__) || defined(OS2)
  29. #define NeedFunctionPrototypes 1
  30. #else
  31. #define NeedFunctionPrototypes 0
  32. #endif /* __STDC__ */
  33. #endif /* NeedFunctionPrototypes */
  34.  
  35.     /* Constants used to index into the bounding box array. */
  36.  
  37. #define LLX 0
  38. #define LLY 1
  39. #define URX 2
  40. #define URY 3
  41.  
  42.     /* Constants used to store keywords that are scanned. */
  43.     /* NONE is not a keyword, it tells when a field was not set */
  44.  
  45. enum {ATEND = -1, NONE = 0, PORTRAIT, LANDSCAPE, ASCEND, DESCEND, SPECIAL};
  46.  
  47. #define PSLINELENGTH 257    /* 255 characters + 1 newline + 1 NULL */
  48.  
  49. /* rjl: DOS binary EPS header */
  50. #define PS_DWORD unsigned long    /* must be 32 bits unsigned */
  51. #define PS_WORD unsigned short    /* must be 16 bits unsigned */
  52. typedef struct tagDOSEPS {
  53.    unsigned char id[4];
  54.    PS_DWORD ps_begin;
  55.    PS_DWORD ps_length;
  56.    PS_DWORD mf_begin;
  57.    PS_DWORD mf_length;
  58.    PS_DWORD tiff_begin;
  59.    PS_DWORD tiff_length;
  60.    PS_WORD checksum;
  61. } DOSEPS;
  62.  
  63. struct document {
  64.     int  epsf;                /* Encapsulated PostScript flag. */
  65.     char *title;            /* Title of document. */
  66.     char *date;                /* Creation date. */
  67.     int  pageorder;            /* ASCEND, DESCEND, SPECIAL */
  68.     long beginheader, endheader;    /* offsets into file */
  69.     unsigned int lenheader;
  70.     long beginpreview, endpreview;
  71.     unsigned int lenpreview;
  72.     long begindefaults, enddefaults;
  73.     unsigned int lendefaults;
  74.     long beginprolog, endprolog;
  75.     unsigned int lenprolog;
  76.     long beginsetup, endsetup;
  77.     unsigned int lensetup;
  78.     long begintrailer, endtrailer;
  79.     unsigned int lentrailer;
  80.     int  boundingbox[4];
  81.     int  default_page_boundingbox[4];
  82.     int  orientation;            /* PORTRAIT, LANDSCAPE */
  83.     int  default_page_orientation;    /* PORTRAIT, LANDSCAPE */
  84.     unsigned int nummedia;
  85.     struct documentmedia *media;
  86.     struct documentmedia *default_page_media;
  87.     DOSEPS *doseps;
  88.     unsigned int numpages;
  89.     struct page *pages;
  90.     int linecount;        /* rjl: line count when parsing DSC comments */
  91. };
  92.  
  93. struct page {
  94.     char *label;
  95.     int  boundingbox[4];
  96.     struct documentmedia *media;
  97.     int  orientation;            /* PORTRAIT, LANDSCAPE */
  98.     long begin, end;            /* offsets into file */
  99.     unsigned int len;
  100. };
  101.  
  102. struct documentmedia {
  103.     char *name;
  104.     int width, height;
  105. };
  106.  
  107.     /* list of standard paper sizes from Adobe's PPD. */
  108.  
  109. extern struct documentmedia papersizes[];
  110.  
  111.     /* scans a PostScript file and return a pointer to the document
  112.        structure.  Returns NULL if file does not Conform to commenting
  113.        conventions . */
  114.  
  115. #if NeedFunctionPrototypes
  116. struct document *psscan(FILE *file);
  117. #else
  118. struct document *psscan();
  119. #endif
  120.  
  121.     /* free data structure malloc'ed by psscan */
  122.  
  123. #if NeedFunctionPrototypes
  124. void psfree(struct document *);
  125. #else
  126. void psfree();
  127. #endif
  128.  
  129.     /* Copy a portion of the PostScript file */
  130.  
  131. #if NeedFunctionPrototypes
  132. void pscopy(FILE *from, FILE *to, long begin, long end);
  133. #else
  134. void pscopy();
  135. #endif
  136.  
  137.     /* Copy a portion of the PostScript file upto a comment */
  138.  
  139. #if NeedFunctionPrototypes
  140. char *pscopyuntil(FILE *from, FILE *to, long begin, long end,
  141.           const char *comment);
  142. #else
  143. char *pscopyuntil();
  144. #endif
  145.  
  146.     /* DOS EPS header reading */
  147.  
  148. #if NeedFunctionPrototypes
  149. unsigned long ps_read_doseps(FILE *file, DOSEPS *doseps);
  150. #else
  151. unsigned long ps_read_doseps();
  152. #endif
  153.  
  154. #if NeedFunctionPrototypes
  155. PS_DWORD reorder_dword(PS_DWORD val);
  156. #else
  157. PS_DWORD reorder_dword();
  158. #endif
  159.  
  160. #if NeedFunctionPrototypes
  161. PS_WORD reorder_word(PS_WORD val);
  162. #else
  163. PS_WORD reorder_word();
  164. #endif
  165.  
  166.