Mon, 31 Dec 2001 07:25:08 +0000
*** empty log message ***
Makefile | file | annotate | diff | revisions | |
parser.y | file | annotate | diff | revisions | |
scanner.l | file | annotate | diff | revisions | |
semantics.c | file | annotate | diff | revisions | |
semantics.h | file | annotate | diff | revisions |
1.1 diff -r e9bf1ed4f331 -r a1cd8cb9d09e Makefile 1.2 --- a/Makefile Mon Dec 31 02:33:50 2001 +0000 1.3 +++ b/Makefile Mon Dec 31 07:25:08 2001 +0000 1.4 @@ -1,6 +1,6 @@ 1.5 # tiff2pdf: build a PDF file out of one or more TIFF Class F Group 4 files 1.6 # Makefile 1.7 -# $Id: Makefile,v 1.6 2001/12/29 20:16:46 eric Exp $ 1.8 +# $Id: Makefile,v 1.7 2001/12/30 23:24:50 eric Exp $ 1.9 # Copyright 2001 Eric Smith <eric@brouhaha.com> 1.10 # 1.11 # This program is free software; you can redistribute it and/or modify 1.12 @@ -24,8 +24,8 @@ 1.13 YACC = bison 1.14 YFLAGS = -d -v 1.15 1.16 -SRCS = bitblt.c bitblt_test.c tiff2pdf.c 1.17 -HDRS = type.h bitblt.h tiff2pdf.h 1.18 +SRCS = bitblt.c bitblt_test.c tiff2pdf.c semantics.c 1.19 +HDRS = type.h bitblt.h tiff2pdf.h semantics.h 1.20 MISC = Makefile scanner.l parser.y 1.21 1.22 TARGETS = tiff2pdf bitblt_test 1.23 @@ -34,7 +34,7 @@ 1.24 AUTO_HDRS = parser.tab.h 1.25 AUTO_MISC = parser.output 1.26 1.27 -tiff2pdf: tiff2pdf.o scanner.o parser.tab.o 1.28 +tiff2pdf: tiff2pdf.o scanner.o semantics.o parser.tab.o 1.29 1.30 bitblt_test: bitblt_test.o bitblt.o 1.31 1.32 @@ -42,6 +42,12 @@ 1.33 clean: 1.34 rm -f *.o *.d $(TARGETS) $(AUTO_SRCS) $(AUTO_HDRS) $(AUTO_MISC) 1.35 1.36 +wc: 1.37 + wc -l $(SRCS) $(HDRS) $(MISC) 1.38 + 1.39 +ls-lt: 1.40 + ls -lt $(SRCS) $(HDRS) $(MISC) 1.41 + 1.42 1.43 %.tab.c %.tab.h %.output: %.y 1.44 $(YACC) $(YFLAGS) $<
2.1 diff -r e9bf1ed4f331 -r a1cd8cb9d09e parser.y 2.2 --- a/parser.y Mon Dec 31 02:33:50 2001 +0000 2.3 +++ b/parser.y Mon Dec 31 07:25:08 2001 +0000 2.4 @@ -38,6 +38,7 @@ 2.5 %token RESOLUTION 2.6 %token INPUT 2.7 2.8 +%token FORMAT 2.9 %token PAGE 2.10 %token PAGES 2.11 %token BOOKMARK 2.12 @@ -69,21 +70,21 @@ 2.13 | INTEGER { $$.first = $1; $$.last = $1; } ; 2.14 2.15 image_ranges: 2.16 - range { input_images ($1.first, $1.last); } 2.17 - | image_ranges ',' range { input_images ($3.first, $3.last); } ; 2.18 + range { input_images ($1); } 2.19 + | image_ranges ',' range { input_images ($3); } ; 2.20 2.21 2.22 input_file_clause: 2.23 FILE_KEYWORD STRING ';' { input_set_file ($2) } ; 2.24 2.25 image_clause: 2.26 - IMAGE INTEGER ';' { input_images ($2, $2); } ; 2.27 + IMAGE INTEGER ';' { range_t range = { $2, $2 }; input_images (range); } ; 2.28 2.29 images_clause: 2.30 IMAGES image_ranges ';' ; 2.31 2.32 rotate_clause: 2.33 - ROTATE INTEGER ';' { input_set_rotation ($2) }; 2.34 + ROTATE INTEGER ';' { input_set_rotation ($2) } ; 2.35 2.36 unit: 2.37 /* empty */ /* default to INCH */ { $$ = 25.4; } 2.38 @@ -125,7 +126,7 @@ 2.39 ODD { input_set_modifier_context (INPUT_MODIFIER_ODD); } 2.40 modifier_clause_list ';' 2.41 { input_set_modifier_context (INPUT_MODIFIER_ALL); } 2.42 - | EVEN { input_set_modifier_context (INPUT_MODIFIER_ODD); } 2.43 + | EVEN { input_set_modifier_context (INPUT_MODIFIER_EVEN); } 2.44 modifier_clause_list ';' 2.45 { input_set_modifier_context (INPUT_MODIFIER_ALL); } ; 2.46 2.47 @@ -150,24 +151,34 @@ 2.48 output_file_clause: 2.49 FILE_KEYWORD STRING ';' { output_set_file ($2) } ; 2.50 2.51 +format_clause: 2.52 + FORMAT STRING ';' { output_set_page_number_format ($2) } ; 2.53 + 2.54 page_ranges: 2.55 - range { output_pages ($1.first, $1.last); } 2.56 - | page_ranges ',' range { output_pages ($3.first, $3.last); } ; 2.57 + range { output_pages ($1); } 2.58 + | page_ranges ',' range { output_pages ($3); } ; 2.59 2.60 page_clause: 2.61 - PAGE INTEGER ';' { output_pages ($2, $2); } 2.62 - | PAGE STRING ',' INTEGER ';' { output_pages ($4, $4); } ; 2.63 + PAGE INTEGER ';' { range_t range = { $2, $2 }; output_pages (range); } ; 2.64 2.65 pages_clause: 2.66 - PAGES page_ranges ';' 2.67 - | PAGES STRING ',' page_ranges ';' ; 2.68 + PAGES page_ranges ';' ; 2.69 + 2.70 +bookmark_name: 2.71 + STRING { output_set_bookmark ($1); } ; 2.72 + 2.73 +bookmark_name_list: 2.74 + bookmark_name 2.75 + | bookmark_name_list ',' bookmark_name ; 2.76 2.77 bookmark_clause: 2.78 - BOOKMARK INTEGER ',' STRING ';' 2.79 - | BOOKMARK STRING ';' ; 2.80 + BOOKMARK { output_push_context (); } 2.81 + bookmark_name_list 2.82 + output_clause_list ';' { output_pop_context (); } ; 2.83 2.84 output_clause: 2.85 output_file_clause 2.86 + | format_clause 2.87 | page_clause | pages_clause 2.88 | bookmark_clause 2.89 | output_clause_list ; 2.90 @@ -177,7 +188,8 @@ 2.91 | output_clauses output_clause ; 2.92 2.93 output_clause_list: 2.94 - '{' output_clauses '}' ; 2.95 + '{' { output_push_context (); } 2.96 + output_clauses '}' { output_pop_context (); } ; 2.97 2.98 output_statement: 2.99 OUTPUT output_clauses ;
3.1 diff -r e9bf1ed4f331 -r a1cd8cb9d09e scanner.l 3.2 --- a/scanner.l Mon Dec 31 02:33:50 2001 +0000 3.3 +++ b/scanner.l Mon Dec 31 07:25:08 2001 +0000 3.4 @@ -1,5 +1,5 @@ 3.5 /* 3.6 -$Id: scanner.l,v 1.10 2001/12/30 09:09:08 eric Exp $ 3.7 +$Id: scanner.l,v 1.11 2001/12/30 23:25:08 eric Exp $ 3.8 */ 3.9 3.10 %option case-insensitive 3.11 @@ -54,6 +54,7 @@ 3.12 crop { return (CROP); } 3.13 even { return (EVEN); } 3.14 file { return (FILE_KEYWORD); } 3.15 +format { return (FORMAT); } 3.16 image { return (IMAGE); } 3.17 images { return (IMAGES); } 3.18 inch { return (INCH); } 3.19 @@ -68,7 +69,7 @@ 3.20 rotate { return (ROTATE); } 3.21 size { return (SIZE); } 3.22 3.23 -\".*\" { 3.24 +\"[^\n"]*\" { 3.25 int len = strlen (yytext) - 2; 3.26 yylval.string = malloc (len + 1); 3.27 memcpy (yylval.string, yytext + 1, len);
4.1 diff -r e9bf1ed4f331 -r a1cd8cb9d09e semantics.c 4.2 --- a/semantics.c Mon Dec 31 02:33:50 2001 +0000 4.3 +++ b/semantics.c Mon Dec 31 07:25:08 2001 +0000 4.4 @@ -19,12 +19,19 @@ 4.5 int line; /* line number in spec file */ 4.6 4.7 4.8 -int input_page_count; /* total input pages in spec */ 4.9 -int output_page_count; /* total output pages in spec */ 4.10 +input_context_t *first_input_context; 4.11 +input_context_t *last_input_context; 4.12 + 4.13 +input_modifier_type_t current_modifier_context; 4.14 4.15 +input_image_t *first_input_image; 4.16 +input_image_t *last_input_image; 4.17 4.18 -input_context_t *current_input_context; 4.19 -input_modifier_type_t current_modifier_context; 4.20 +output_context_t *first_output_context; 4.21 +output_context_t *last_output_context; 4.22 + 4.23 +output_page_t *first_output_page; 4.24 +output_page_t *last_output_page; 4.25 4.26 4.27 void input_push_context (void) 4.28 @@ -34,31 +41,34 @@ 4.29 new_input_context = malloc (sizeof (input_context_t)); 4.30 if (! new_input_context) 4.31 { 4.32 - fprintf (stderr, "failed to calloc an input context\n"); 4.33 + fprintf (stderr, "failed to malloc an input context\n"); 4.34 return; 4.35 } 4.36 4.37 - if (current_input_context) 4.38 + if (last_input_context) 4.39 { 4.40 - memcpy (new_input_context, current_input_context, sizeof (input_context_t)); 4.41 - new_input_context->page_count = 0; 4.42 + memcpy (new_input_context, last_input_context, sizeof (input_context_t)); 4.43 + new_input_context->image_count = 0; 4.44 } 4.45 else 4.46 - memset (new_input_context, 0, sizeof (input_context_t)); 4.47 + { 4.48 + memset (new_input_context, 0, sizeof (input_context_t)); 4.49 + first_input_context = new_input_context; 4.50 + } 4.51 4.52 - new_input_context->parent_input_context = current_input_context; 4.53 - current_input_context = new_input_context; 4.54 + new_input_context->parent = last_input_context; 4.55 + last_input_context = new_input_context; 4.56 }; 4.57 4.58 void input_pop_context (void) 4.59 { 4.60 - if (! current_input_context) 4.61 + if (! last_input_context) 4.62 { 4.63 fprintf (stderr, "failed to pop an input context\n"); 4.64 return; 4.65 } 4.66 4.67 - current_input_context = current_input_context->parent_input_context; 4.68 + last_input_context = last_input_context->parent; 4.69 }; 4.70 4.71 void input_set_modifier_context (input_modifier_type_t type) 4.72 @@ -77,46 +87,218 @@ 4.73 #endif /* SEMANTIC_DEBUG */ 4.74 } 4.75 4.76 +void input_clone (void) 4.77 +{ 4.78 + input_context_t *new_input_context; 4.79 + 4.80 + if (! last_input_context->image_count) 4.81 + return; 4.82 + 4.83 + new_input_context = malloc (sizeof (input_context_t)); 4.84 + if (! new_input_context) 4.85 + { 4.86 + fprintf (stderr, "failed to malloc an input context\n"); 4.87 + return; 4.88 + } 4.89 + 4.90 + memcpy (new_input_context, last_input_context, sizeof (input_context_t)); 4.91 + new_input_context->image_count = 0; 4.92 + last_input_context->next = new_input_context; 4.93 +} 4.94 + 4.95 void input_set_file (char *name) 4.96 { 4.97 + input_clone (); 4.98 + last_input_context->input_file = name; 4.99 }; 4.100 4.101 void input_set_rotation (int rotation) 4.102 { 4.103 - current_input_context->modifiers [current_modifier_context].has_rotation = 1; 4.104 - current_input_context->modifiers [current_modifier_context].rotation = rotation; 4.105 + last_input_context->modifiers [current_modifier_context].has_rotation = 1; 4.106 + last_input_context->modifiers [current_modifier_context].rotation = rotation; 4.107 SDBG(("rotation %d\n", rotation)); 4.108 } 4.109 4.110 -void input_images (int first, int last) 4.111 +void increment_input_image_count (int count) 4.112 { 4.113 - input_page_count += ((last - first) + 1); 4.114 + input_context_t *context; 4.115 + 4.116 + for (context = last_input_context; context; context = context->parent) 4.117 + context->image_count += count; 4.118 +} 4.119 + 4.120 +void input_images (range_t range) 4.121 +{ 4.122 + input_image_t *new_image; 4.123 + int count = ((range.last - range.first) + 1); 4.124 + 4.125 #ifdef SEMANTIC_DEBUG 4.126 - if (first == last) 4.127 - SDBG(("image %d\n", first)); 4.128 + if (range.first == range.last) 4.129 + SDBG(("image %d\n", range.first)); 4.130 else 4.131 - SDBG(("images %d..%d\n", first, last)); 4.132 + SDBG(("images %d..%d\n", range.first, range.last)); 4.133 #endif /* SEMANTIC_DEBUG */ 4.134 + 4.135 + new_image = calloc (1, sizeof (input_image_t)); 4.136 + if (! new_image) 4.137 + { 4.138 + fprintf (stderr, "failed to malloc an input image struct\n"); 4.139 + return; 4.140 + } 4.141 + if (first_input_image) 4.142 + { 4.143 + last_input_image->next = new_image; 4.144 + last_input_image = new_image; 4.145 + } 4.146 + else 4.147 + { 4.148 + first_input_image = last_input_image = new_image; 4.149 + } 4.150 + new_image->range = range; 4.151 + new_image->input_context = last_input_context; 4.152 + increment_input_image_count (count); 4.153 } 4.154 4.155 4.156 void output_push_context (void) 4.157 { 4.158 + output_context_t *new_output_context; 4.159 + 4.160 + new_output_context = malloc (sizeof (output_context_t)); 4.161 + if (! new_output_context) 4.162 + { 4.163 + fprintf (stderr, "failed to malloc an output context\n"); 4.164 + return; 4.165 + } 4.166 + 4.167 + if (last_output_context) 4.168 + { 4.169 + memcpy (new_output_context, last_output_context, sizeof (output_context_t)); 4.170 + new_output_context->page_count = 0; 4.171 + } 4.172 + else 4.173 + { 4.174 + memset (new_output_context, 0, sizeof (output_context_t)); 4.175 + first_output_context = new_output_context; 4.176 + } 4.177 + 4.178 + new_output_context->parent = last_output_context; 4.179 + last_output_context = new_output_context; 4.180 }; 4.181 4.182 +void output_pop_context (void) 4.183 +{ 4.184 + if (! last_output_context) 4.185 + { 4.186 + fprintf (stderr, "failed to pop an output context\n"); 4.187 + return; 4.188 + } 4.189 + 4.190 + last_output_context = last_output_context->parent; 4.191 +}; 4.192 + 4.193 +void output_clone (void) 4.194 +{ 4.195 + output_context_t *new_output_context; 4.196 + 4.197 + if (! last_output_context->page_count) 4.198 + return; 4.199 + 4.200 + new_output_context = malloc (sizeof (output_context_t)); 4.201 + if (! new_output_context) 4.202 + { 4.203 + fprintf (stderr, "failed to malloc an output context\n"); 4.204 + return; 4.205 + } 4.206 + 4.207 + memcpy (new_output_context, last_output_context, sizeof (output_context_t)); 4.208 + new_output_context->page_count = 0; 4.209 + last_output_context->next = new_output_context; 4.210 +} 4.211 + 4.212 void output_set_file (char *name) 4.213 { 4.214 + output_clone (); 4.215 + last_output_context->output_file = name; 4.216 }; 4.217 4.218 -void output_pages (int first, int last) 4.219 +void output_set_bookmark (char *name) 4.220 { 4.221 - output_page_count += ((last - first) + 1); 4.222 + bookmark_t *new_bookmark; 4.223 + 4.224 + /* As the language is defined (parser.y), a bookmark can only appear 4.225 + at the beginning of a context! */ 4.226 + if (last_output_context->page_count) 4.227 + { 4.228 + fprintf (stderr, "internal error, bookmark not at beginning of context\n"); 4.229 + exit (2); 4.230 + } 4.231 + 4.232 + new_bookmark = calloc (1, sizeof (bookmark_t)); 4.233 + if (! new_bookmark) 4.234 + { 4.235 + fprintf (stderr, "failed to calloc a bookmark\n"); 4.236 + return; 4.237 + } 4.238 + 4.239 + new_bookmark->name = name; 4.240 + if (last_output_context->first_bookmark) 4.241 + last_output_context->last_bookmark->next = new_bookmark; 4.242 + else 4.243 + last_output_context->first_bookmark = new_bookmark; 4.244 + last_output_context->last_bookmark = new_bookmark; 4.245 +} 4.246 + 4.247 +void output_set_page_number_format (char *format) 4.248 +{ 4.249 + output_clone (); 4.250 + last_output_context->page_number_format = format; 4.251 +} 4.252 + 4.253 +void increment_output_page_count (int count) 4.254 +{ 4.255 + output_context_t *context; 4.256 + 4.257 + for (context = last_output_context; context; context = context->parent) 4.258 + context->page_count += count; 4.259 +} 4.260 + 4.261 +void output_pages (range_t range) 4.262 +{ 4.263 + output_page_t *new_page; 4.264 + int count = ((range.last - range.first) + 1); 4.265 + 4.266 #ifdef SEMANTIC_DEBUG 4.267 - if (first == last) 4.268 - SDBG(("page %d\n", first)); 4.269 + if (range.first == range.last) 4.270 + SDBG(("page %d\n", range.first)); 4.271 else 4.272 - SDBG(("pages %d..%d\n", first, last)); 4.273 + SDBG(("pages %d..%d\n", range.first, range.last)); 4.274 #endif /* SEMANTIC_DEBUG */ 4.275 + 4.276 + new_page = calloc (1, sizeof (output_page_t)); 4.277 + if (! new_page) 4.278 + { 4.279 + fprintf (stderr, "failed to malloc an output page struct\n"); 4.280 + return; 4.281 + } 4.282 + if (first_output_page) 4.283 + { 4.284 + last_output_page->next = new_page; 4.285 + last_output_page = new_page; 4.286 + } 4.287 + else 4.288 + { 4.289 + first_output_page = last_output_page = new_page; 4.290 + } 4.291 + new_page->range = range; 4.292 + new_page->output_context = last_output_context; 4.293 + 4.294 + /* transfer bookmarks from context to page */ 4.295 + new_page->bookmark_list = last_output_context->first_bookmark; 4.296 + last_output_context->first_bookmark = NULL; 4.297 + last_output_context->last_bookmark = NULL; 4.298 + 4.299 + increment_output_page_count (count); 4.300 } 4.301 4.302 4.303 @@ -126,6 +308,88 @@ 4.304 } 4.305 4.306 4.307 +char *get_input_file (input_context_t *context) 4.308 +{ 4.309 + for (; context; context = context->parent) 4.310 + if (context->input_file) 4.311 + return (context->input_file); 4.312 + fprintf (stderr, "no input file name found\n"); 4.313 + exit (2); 4.314 +} 4.315 + 4.316 +int get_input_rotation (input_context_t *context, input_modifier_type_t type) 4.317 +{ 4.318 + for (; context; context = context->parent) 4.319 + { 4.320 + if (context->modifiers [type].has_rotation) 4.321 + return (context->modifiers [type].rotation); 4.322 + if (context->modifiers [INPUT_MODIFIER_ALL].has_rotation) 4.323 + return (context->modifiers [INPUT_MODIFIER_ALL].rotation); 4.324 + } 4.325 + return (0); /* default */ 4.326 +} 4.327 + 4.328 +char *get_output_file (output_context_t *context) 4.329 +{ 4.330 + for (; context; context = context->parent) 4.331 + if (context->output_file) 4.332 + return (context->output_file); 4.333 + fprintf (stderr, "no output file name found\n"); 4.334 + exit (2); 4.335 +} 4.336 + 4.337 +char *get_output_page_number_format (output_context_t *context) 4.338 +{ 4.339 + for (; context; context = context->parent) 4.340 + if (context->page_number_format) 4.341 + return (context->page_number_format); 4.342 + return (NULL); /* default */ 4.343 +} 4.344 + 4.345 + 4.346 +#ifdef SEMANTIC_DEBUG 4.347 +void dump_input_tree (void) 4.348 +{ 4.349 + input_image_t *image; 4.350 + int i; 4.351 + 4.352 + printf ("input images:\n"); 4.353 + for (image = first_input_image; image; image = image->next) 4.354 + for (i = image->range.first; i <= image->range.last; i++) 4.355 + { 4.356 + input_modifier_type_t parity = (i % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN; 4.357 + printf ("file '%s' image %d, rotation %d\n", 4.358 + get_input_file (image->input_context), 4.359 + i, 4.360 + get_input_rotation (image->input_context, parity)); 4.361 + } 4.362 +} 4.363 + 4.364 +void dump_output_tree (void) 4.365 +{ 4.366 + int i; 4.367 + output_page_t *page; 4.368 + bookmark_t *bookmark; 4.369 + 4.370 + printf ("output pages:\n"); 4.371 + for (page = first_output_page; page; page = page->next) 4.372 + { 4.373 + if (page->bookmark_list) 4.374 + { 4.375 + for (bookmark = page->bookmark_list; bookmark; bookmark = bookmark->next) 4.376 + printf ("bookmark '%s' ", bookmark->name); 4.377 + printf ("\n"); 4.378 + } 4.379 + for (i = page->range.first; i <= page->range.last; i++) 4.380 + { 4.381 + printf ("file '%s' ", get_output_file (page->output_context)); 4.382 + printf ("format '%s' ", get_output_page_number_format (page->output_context)); 4.383 + printf ("page %d\n", i); 4.384 + } 4.385 + } 4.386 +} 4.387 +#endif /* SEMANTIC_DEBUG */ 4.388 + 4.389 boolean parse_spec_file (char *fn) 4.390 { 4.391 boolean result = 0; 4.392 @@ -139,22 +403,31 @@ 4.393 4.394 line = 1; 4.395 4.396 - input_push_context (); /* create initial input context */ 4.397 + input_push_context (); /* create root input context */ 4.398 + input_push_context (); /* create inital input context */ 4.399 + 4.400 + output_push_context (); /* create root output context */ 4.401 output_push_context (); /* create initial output context */ 4.402 4.403 yyparse (); 4.404 4.405 - if (input_page_count != output_page_count) 4.406 + if (first_input_context->image_count != first_output_context->page_count) 4.407 { 4.408 - fprintf (stderr, "input page count %d != output page count %d\n", 4.409 - input_page_count, output_page_count); 4.410 + fprintf (stderr, "input image count %d != output page count %d\n", 4.411 + first_input_context->image_count, 4.412 + first_output_context->page_count); 4.413 goto fail; 4.414 } 4.415 4.416 - fprintf (stderr, "%d pages specified\n", input_page_count); 4.417 + fprintf (stderr, "%d pages specified\n", first_input_context->image_count); 4.418 4.419 result = 1; 4.420 4.421 +#ifdef SEMANTIC_DEBUG 4.422 + dump_input_tree (); 4.423 + dump_output_tree (); 4.424 +#endif /* SEMANTIC_DEBUG */ 4.425 + 4.426 fail: 4.427 if (yyin) 4.428 fclose (yyin);
5.1 diff -r e9bf1ed4f331 -r a1cd8cb9d09e semantics.h 5.2 --- a/semantics.h Mon Dec 31 02:33:50 2001 +0000 5.3 +++ b/semantics.h Mon Dec 31 07:25:08 2001 +0000 5.4 @@ -42,20 +42,58 @@ 5.5 5.6 typedef struct input_context_t 5.7 { 5.8 - struct input_context_t *parent_input_context; 5.9 + struct input_context_t *parent; 5.10 + struct input_context_t *next; 5.11 5.12 - int page_count; /* how many pages reference this context, 5.13 + int image_count; /* how many pages reference this context, 5.14 including those from subcontexts */ 5.15 5.16 + char *input_file; 5.17 + 5.18 input_modifiers_t modifiers [INPUT_MODIFIER_TYPE_COUNT]; 5.19 } input_context_t; 5.20 5.21 5.22 -extern int line; /* line number in spec file */ 5.23 +typedef struct input_image_t 5.24 +{ 5.25 + struct input_image_t *next; 5.26 + input_context_t *input_context; 5.27 + range_t range; 5.28 +} input_image_t; 5.29 + 5.30 + 5.31 +typedef struct bookmark_t 5.32 +{ 5.33 + struct bookmark_t *next; 5.34 + char *name; 5.35 +} bookmark_t; 5.36 5.37 5.38 -extern int input_page_count; /* total input pages in spec */ 5.39 -extern int output_page_count; /* total output pages in spec */ 5.40 +typedef struct output_context_t 5.41 +{ 5.42 + struct output_context_t *parent; 5.43 + struct output_context_t *next; 5.44 + 5.45 + int page_count; /* how many pages reference this context, 5.46 + including those from subcontexts */ 5.47 + 5.48 + char *output_file; 5.49 + bookmark_t *first_bookmark; 5.50 + bookmark_t *last_bookmark; 5.51 + char *page_number_format; 5.52 +} output_context_t; 5.53 + 5.54 + 5.55 +typedef struct output_page_t 5.56 +{ 5.57 + struct output_page_t *next; 5.58 + output_context_t *output_context; 5.59 + range_t range; 5.60 + bookmark_t *bookmark_list; 5.61 +} output_page_t; 5.62 + 5.63 + 5.64 +extern int line; /* line number in spec file */ 5.65 5.66 5.67 boolean parse_spec_file (char *fn); 5.68 @@ -67,8 +105,10 @@ 5.69 void input_set_modifier_context (input_modifier_type_t type); 5.70 void input_set_file (char *name); 5.71 void input_set_rotation (int rotation); 5.72 -void input_images (int first, int last); 5.73 +void input_images (range_t range); 5.74 5.75 /* semantic routines for output statements */ 5.76 void output_set_file (char *name); 5.77 -void output_pages (int first, int last); 5.78 +void output_set_bookmark (char *name); 5.79 +void output_set_page_number_format (char *format); 5.80 +void output_pages (range_t range);