1 /*
2  * tumble: build a PDF file from image files
3  *
4  * Semantic routines for spec file parser
5  * Copyright 2001, 2002, 2003, 2017 Eric Smith <spacewar@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.  Note that permission is
10  * not granted to redistribute this program under the terms of any
11  * other version of the General Public License.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
21  *
22  *  2009-03-13 [JDB] Add support for blank pages, overlay images, color
23  *                   mapping, color-key masking, and push/pop of input
24  *                   contexts.
25  */
26 
27 // HACK! rgb_t and colormap_t have to appear here and in pdf_g4!  See pdf.h
28 #define SEMANTICS
29 
30 typedef struct
31 {
32   int first;
33   int last;
34  } range_t;
35 
36 typedef struct
37 {
38   int red;
39   int green;
40   int blue;
41 } rgb_t;
42 
43 typedef struct
44 {
45   range_t red;
46   range_t green;
47   range_t blue;
48 } rgb_range_t;
49 
50 typedef struct
51 {
52   rgb_t black_map;
53   rgb_t white_map;
54 } colormap_t;
55 
56 // end of HACK
57 
58 typedef struct
59 {
60   double x;
61   double y;
62 } position_t;
63 
64 typedef struct
65 {
66   double left;
67   double top;
68 } overlay_t;
69 
70 typedef struct
71 {
72   double width;
73   double height;
74 } page_size_t;
75 
76 typedef struct
77 {
78   double left;
79   double right;
80   double top;
81   double bottom;
82 } crop_t;
83 
84 typedef struct
85 {
86   char *prefix;
87   char style;
88   /* the following fields are not filled by the parser: */
89   int page_index;
90   int base;
91   int count;
92 } page_label_t;
93 
94 
95 typedef enum
96 {
97   INPUT_MODIFIER_ALL,
98   INPUT_MODIFIER_ODD,
99   INPUT_MODIFIER_EVEN,
100   INPUT_MODIFIER_TYPE_COUNT  /* must be last */
101 } input_modifier_type_t;
102 
103 
104 typedef struct bookmark_t
105 {
106   struct bookmark_t *next;
107   int level;  /* 1 is outermost */
108   char *name;
109 } bookmark_t;
110 
111 
112 extern int line;  /* line number in spec file */
113 extern int bookmark_level;
114 
115 
116 /* Bison interface */
117 extern int yyparse (void);
118 void yyerror (const char *s);
119 
120 /* semantic routines for input statements */
121 void input_push_context (void);
122 void input_pop_context (void);
123 void input_set_modifier_context (input_modifier_type_t type);
124 void input_set_file (char *name);
125 void input_set_rotation (int rotation);
126 void input_set_transparency (rgb_range_t rgb_range);
127 void input_set_page_size (page_size_t size);
128 void input_images (range_t range);
129 
130 /* semantic routines for output statements */
131 void output_push_context (void);
132 void output_pop_context (void);
133 
134 void output_set_file (char *name);
135 void output_set_author (char *author);
136 void output_set_creator (char *creator);
137 void output_set_title (char *title);
138 void output_set_subject (char *subject);
139 void output_set_keywords (char *keywords);
140 
141 void output_set_bookmark (char *name);
142 void output_set_page_label (page_label_t label);
143 void output_pages (range_t range);
144 void output_overlay (overlay_t overlay);
145 void output_transparency (rgb_range_t rgb_range);
146 void output_set_colormap (rgb_t black_color, rgb_t white_color);
147 
148 
149 /* functions to be called from main program: */
150 bool parse_control_file (char *fn);
151 bool process_controls (void);
152