Mon, 31 Dec 2001 16:44:24 +0000
replaced page_number_format with page_label matching how PDF names
and stores them.
semantics.c | file | annotate | diff | revisions | |
semantics.h | file | annotate | diff | revisions | |
t2p.c | file | annotate | diff | revisions | |
t2p.h | file | annotate | diff | revisions | |
tumble.c | file | annotate | diff | revisions | |
tumble.h | file | annotate | diff | revisions |
1.1 diff -r 6575fcfbdb1b -r 139b91f9a224 semantics.c 1.2 --- a/semantics.c Mon Dec 31 08:25:04 2001 +0000 1.3 +++ b/semantics.c Mon Dec 31 16:44:24 2001 +0000 1.4 @@ -5,6 +5,7 @@ 1.5 #include "type.h" 1.6 #include "semantics.h" 1.7 #include "parser.tab.h" 1.8 +#include "tiff2pdf.h" 1.9 1.10 1.11 typedef struct 1.12 @@ -53,7 +54,9 @@ 1.13 char *output_file; 1.14 bookmark_t *first_bookmark; 1.15 bookmark_t *last_bookmark; 1.16 - char *page_number_format; 1.17 + 1.18 + boolean has_page_label; 1.19 + page_label_t page_label; 1.20 } output_context_t; 1.21 1.22 1.23 @@ -312,10 +315,11 @@ 1.24 last_output_context->last_bookmark = new_bookmark; 1.25 } 1.26 1.27 -void output_set_page_number_format (char *format) 1.28 +void output_set_page_label (page_label_t label) 1.29 { 1.30 output_clone (); 1.31 - last_output_context->page_number_format = format; 1.32 + last_output_context->has_page_label = 1; 1.33 + last_output_context->page_label = label; 1.34 } 1.35 1.36 static void increment_output_page_count (int count) 1.37 @@ -408,11 +412,11 @@ 1.38 exit (2); 1.39 } 1.40 1.41 -static char *get_output_page_number_format (output_context_t *context) 1.42 +static page_label_t *get_output_page_label (output_context_t *context) 1.43 { 1.44 for (; context; context = context->parent) 1.45 - if (context->page_number_format) 1.46 - return (context->page_number_format); 1.47 + if (context->has_page_label) 1.48 + return (& context->page_label); 1.49 return (NULL); /* default */ 1.50 } 1.51 1.52 @@ -447,18 +451,87 @@ 1.53 if (page->bookmark_list) 1.54 { 1.55 for (bookmark = page->bookmark_list; bookmark; bookmark = bookmark->next) 1.56 - printf ("bookmark %d '%s'\n", bookmark->level, bookmark->name); 1.57 + printf ("bookmark %d \"%s\"\n", bookmark->level, bookmark->name); 1.58 } 1.59 for (i = page->range.first; i <= page->range.last; i++) 1.60 { 1.61 - printf ("file '%s' ", get_output_file (page->output_context)); 1.62 - printf ("format '%s' ", get_output_page_number_format (page->output_context)); 1.63 + page_label_t *label = get_output_page_label (page->output_context); 1.64 + printf ("file \"%s\" ", get_output_file (page->output_context)); 1.65 + if (label) 1.66 + { 1.67 + printf ("label "); 1.68 + if (label->prefix) 1.69 + printf ("\"%s\" ", label->prefix); 1.70 + if (label->style) 1.71 + printf ("'%c' ", label->style); 1.72 + } 1.73 printf ("page %d\n", i); 1.74 } 1.75 } 1.76 } 1.77 #endif /* SEMANTIC_DEBUG */ 1.78 1.79 + 1.80 +static inline int range_count (range_t range) 1.81 +{ 1.82 + return ((range.last - range.first) + 1); 1.83 +} 1.84 + 1.85 + 1.86 +void doit (void) 1.87 +{ 1.88 + input_image_t *image = NULL; 1.89 + output_page_t *page = NULL; 1.90 + int i = 0; 1.91 + int p = 0; 1.92 + int page_index = 0; 1.93 + input_attributes_t input_attributes; 1.94 + input_modifier_type_t parity; 1.95 + page_label_t *page_label; 1.96 + 1.97 + for (;;) 1.98 + { 1.99 + if ((! image) || (i >= range_count (image->range))) 1.100 + { 1.101 + if (image) 1.102 + image = image->next; 1.103 + else 1.104 + image = first_input_image; 1.105 + if (! image) 1.106 + return; 1.107 + i = 0; 1.108 + } 1.109 + 1.110 + if ((! page) || (p >= range_count (page->range))) 1.111 + { 1.112 + if (page) 1.113 + page = page->next; 1.114 + else 1.115 + page = first_output_page; 1.116 + p = 0; 1.117 + page_label = get_output_page_label (page->output_context); 1.118 + process_page_numbers (page_index, 1.119 + range_count (page->range), 1.120 + page->range.first, 1.121 + page_label); 1.122 + } 1.123 + 1.124 + parity = ((image->range.first + i) % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN; 1.125 + 1.126 + memset (& input_attributes, 0, sizeof (input_attributes)); 1.127 + input_attributes.rotation = get_input_rotation (image->input_context, 1.128 + parity);; 1.129 + 1.130 + process_page (image->range.first + i, 1.131 + input_attributes, 1.132 + page->bookmark_list); 1.133 + i++; 1.134 + p++; 1.135 + page_index++; 1.136 + } 1.137 +} 1.138 + 1.139 + 1.140 boolean parse_spec_file (char *fn) 1.141 { 1.142 boolean result = 0;
2.1 diff -r 6575fcfbdb1b -r 139b91f9a224 semantics.h 2.2 --- a/semantics.h Mon Dec 31 08:25:04 2001 +0000 2.3 +++ b/semantics.h Mon Dec 31 16:44:24 2001 +0000 2.4 @@ -18,6 +18,12 @@ 2.5 double bottom; 2.6 } crop_t; 2.7 2.8 +typedef struct 2.9 +{ 2.10 + char *prefix; 2.11 + char style; 2.12 +} page_label_t; 2.13 + 2.14 2.15 typedef enum 2.16 { 2.17 @@ -56,5 +62,5 @@ 2.18 void output_pop_context (void); 2.19 void output_set_file (char *name); 2.20 void output_set_bookmark (char *name); 2.21 -void output_set_page_number_format (char *format); 2.22 +void output_set_page_label (page_label_t label); 2.23 void output_pages (range_t range);
3.1 diff -r 6575fcfbdb1b -r 139b91f9a224 t2p.c 3.2 --- a/t2p.c Mon Dec 31 08:25:04 2001 +0000 3.3 +++ b/t2p.c Mon Dec 31 16:44:24 2001 +0000 3.4 @@ -1,7 +1,7 @@ 3.5 /* 3.6 * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 3.7 * Main program 3.8 - * $Id: t2p.c,v 1.6 2001/12/31 00:25:04 eric Exp $ 3.9 + * $Id: t2p.c,v 1.7 2001/12/31 08:44:24 eric Exp $ 3.10 * Copyright 2001 Eric Smith <eric@brouhaha.com> 3.11 * 3.12 * This program is free software; you can redistribute it and/or modify 3.13 @@ -80,9 +80,17 @@ 3.14 } 3.15 3.16 3.17 +void process_page_numbers (int page_index, 3.18 + int count, 3.19 + int base, 3.20 + page_label_t *page_label) 3.21 +{ 3.22 +} 3.23 + 3.24 + 3.25 boolean process_page (int image, /* range 1 .. n */ 3.26 input_attributes_t input_attributes, 3.27 - output_attributes_t output_attributes) 3.28 + bookmark_t *bookmarks) 3.29 { 3.30 u32 image_length, image_width; 3.31 #ifdef CHECK_DEPTH
4.1 diff -r 6575fcfbdb1b -r 139b91f9a224 t2p.h 4.2 --- a/t2p.h Mon Dec 31 08:25:04 2001 +0000 4.3 +++ b/t2p.h Mon Dec 31 16:44:24 2001 +0000 4.4 @@ -5,18 +5,17 @@ 4.5 crop_t crop; 4.6 } input_attributes_t; 4.7 4.8 -typedef struct 4.9 -{ 4.10 - char *page_number; 4.11 - bookmark_t *bookmarks; 4.12 -} output_attributes_t; 4.13 - 4.14 boolean open_tiff_input_file (char *name); 4.15 boolean close_tiff_input_file (void); 4.16 4.17 boolean open_pdf_output_file (char *name); 4.18 boolean close_pdf_output_file (void); 4.19 4.20 +void process_page_numbers (int page_index, 4.21 + int count, 4.22 + int base, 4.23 + page_label_t *page_label); 4.24 + 4.25 boolean process_page (int image, /* range 1 .. n */ 4.26 input_attributes_t input_attributes, 4.27 - output_attributes_t output_attributes); 4.28 + bookmark_t *bookmarks);
5.1 diff -r 6575fcfbdb1b -r 139b91f9a224 tumble.c 5.2 --- a/tumble.c Mon Dec 31 08:25:04 2001 +0000 5.3 +++ b/tumble.c Mon Dec 31 16:44:24 2001 +0000 5.4 @@ -1,7 +1,7 @@ 5.5 /* 5.6 * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 5.7 * Main program 5.8 - * $Id: tumble.c,v 1.6 2001/12/31 00:25:04 eric Exp $ 5.9 + * $Id: tumble.c,v 1.7 2001/12/31 08:44:24 eric Exp $ 5.10 * Copyright 2001 Eric Smith <eric@brouhaha.com> 5.11 * 5.12 * This program is free software; you can redistribute it and/or modify 5.13 @@ -80,9 +80,17 @@ 5.14 } 5.15 5.16 5.17 +void process_page_numbers (int page_index, 5.18 + int count, 5.19 + int base, 5.20 + page_label_t *page_label) 5.21 +{ 5.22 +} 5.23 + 5.24 + 5.25 boolean process_page (int image, /* range 1 .. n */ 5.26 input_attributes_t input_attributes, 5.27 - output_attributes_t output_attributes) 5.28 + bookmark_t *bookmarks) 5.29 { 5.30 u32 image_length, image_width; 5.31 #ifdef CHECK_DEPTH
6.1 diff -r 6575fcfbdb1b -r 139b91f9a224 tumble.h 6.2 --- a/tumble.h Mon Dec 31 08:25:04 2001 +0000 6.3 +++ b/tumble.h Mon Dec 31 16:44:24 2001 +0000 6.4 @@ -5,18 +5,17 @@ 6.5 crop_t crop; 6.6 } input_attributes_t; 6.7 6.8 -typedef struct 6.9 -{ 6.10 - char *page_number; 6.11 - bookmark_t *bookmarks; 6.12 -} output_attributes_t; 6.13 - 6.14 boolean open_tiff_input_file (char *name); 6.15 boolean close_tiff_input_file (void); 6.16 6.17 boolean open_pdf_output_file (char *name); 6.18 boolean close_pdf_output_file (void); 6.19 6.20 +void process_page_numbers (int page_index, 6.21 + int count, 6.22 + int base, 6.23 + page_label_t *page_label); 6.24 + 6.25 boolean process_page (int image, /* range 1 .. n */ 6.26 input_attributes_t input_attributes, 6.27 - output_attributes_t output_attributes); 6.28 + bookmark_t *bookmarks);