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