1 /*
2  * ps.h -- Include file for PostScript routines.
3  * Copyright (C) 1992  Timothy O. Theisen
4  * Copyright (C) 2004 Jose E. Marchesi
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU gv; see the file COPYING.  If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  *   Author: Tim Theisen           Systems Programmer
22  * Internet: tim@cs.wisc.edu       Department of Computer Sciences
23  *     UUCP: uwvax!tim             University of Wisconsin-Madison
24  *    Phone: (608)262-0438         1210 West Dayton Street
25  *      FAX: (608)262-9777         Madison, WI   53706
26 */
27 
28 /* Constants used to index into the bounding box array. */
29 
30 #define LLX 0
31 #define LLY 1
32 #define URX 2
33 #define URY 3
34 
35 	/* Constants used to store keywords that are scanned. */
36 	/* NONE is not a keyword, it tells when a field was not set */
37 
38 /*
39 enum {ATEND = -1, NONE = 0, PORTRAIT, LANDSCAPE, ASCEND, DESCEND, SPECIAL};
40 */
41 
42 #define ATEND        (-1)
43 #define NONE            0
44 #define PORTRAIT        1
45 #define LANDSCAPE       2
46 #define SEASCAPE        3
47 #define UPSIDEDOWN      4
48 #define ASCEND          5
49 #define DESCEND         6
50 #define SPECIAL         7
51 #define AUTOMATIC       8
52 
53 #define PSLINELENGTH 257	/* 255 characters + 1 newline + 1 NULL */
54 
55 typedef struct document {
56 #ifdef GV_CODE
57     int  structured;                    /* toc will be useful */
58     int  labels_useful;                 /* page labels are distinguishable, hence useful */
59 #endif
60     int  epsf;				/* Encapsulated PostScript flag. */
61     char *title;			/* Title of document. */
62     char *date;				/* Creation date. */
63     int  pageorder;			/* ASCEND, DESCEND, SPECIAL */
64     gv_off_t beginheader, endheader, beginpreview, endpreview, begindefaults, enddefaults,
65           beginprolog, endprolog, beginsetup, endsetup, begintrailer, endtrailer;
66     gv_off_t lenheader;
67     gv_off_t lenpreview;
68     gv_off_t lendefaults;
69     gv_off_t lenprolog;
70     gv_off_t lensetup;
71     gv_off_t lentrailer;
72     int  boundingbox[4];
73     int  default_page_boundingbox[4];
74     int  orientation;			/* PORTRAIT, LANDSCAPE */
75     int  default_page_orientation;	/* PORTRAIT, LANDSCAPE */
76     int nummedia;
77     struct documentmedia *media;
78     Media default_page_media;
79     int numpages;
80     struct page *pages;
81 } *Document;
82 
83 struct page {
84     char *label;
85     int  boundingbox[4];
86     struct documentmedia *media;
87     int  orientation;			/* PORTRAIT, LANDSCAPE */
88     gv_off_t begin, end;			/* offsets into file */
89     gv_off_t len;
90 };
91 
92 	/* scans a PostScript file and return a pointer to the document
93 	   structure.  Returns NULL if file does not Conform to commenting
94 	   conventions . */
95 
96 #define SCANSTYLE_NORMAL     0
97 #define SCANSTYLE_IGNORE_EOF (1<<0)
98 #define SCANSTYLE_IGNORE_DSC (1<<1)
99 
100 Document				psscan (
101     FILE **,
102     char *,
103     char *,
104     char **,
105     char *,
106     char **,
107     char *,
108     int,     /* scanstyle */
109     int	     /* gv_gs_scanDir */
110 );
111 
112 void					psfree (
113     struct document *
114 );
115 
116 extern void				pscopydoc (
117     FILE *,
118     char *,
119     Document,
120     char *
121 );
122