semantics.c

Tue, 01 Jan 2002 10:16:50 +0000

author
eric
date
Tue, 01 Jan 2002 10:16:50 +0000
changeset 32
3aac131058da
parent 30
35fad7ec7732
child 36
a338db73c6f4
permissions
-rw-r--r--

added start of page size support.

eric@18 1 #include <stdlib.h>
eric@18 2 #include <string.h>
eric@16 3 #include <stdio.h>
eric@16 4
eric@16 5 #include "type.h"
eric@18 6 #include "semantics.h"
eric@16 7 #include "parser.tab.h"
eric@25 8 #include "tiff2pdf.h"
eric@16 9
eric@16 10
eric@22 11 typedef struct
eric@22 12 {
eric@32 13 boolean has_page_size;
eric@32 14 page_size_t page_size;
eric@22 15
eric@22 16 boolean has_rotation;
eric@22 17 int rotation;
eric@22 18
eric@22 19 boolean has_crop;
eric@22 20 crop_t crop;
eric@22 21 } input_modifiers_t;
eric@22 22
eric@22 23
eric@22 24 typedef struct input_context_t
eric@22 25 {
eric@22 26 struct input_context_t *parent;
eric@22 27 struct input_context_t *next;
eric@22 28
eric@22 29 int image_count; /* how many pages reference this context,
eric@22 30 including those from subcontexts */
eric@22 31
eric@22 32 char *input_file;
eric@22 33
eric@22 34 input_modifiers_t modifiers [INPUT_MODIFIER_TYPE_COUNT];
eric@22 35 } input_context_t;
eric@22 36
eric@22 37
eric@22 38 typedef struct input_image_t
eric@22 39 {
eric@22 40 struct input_image_t *next;
eric@22 41 input_context_t *input_context;
eric@22 42 range_t range;
eric@22 43 } input_image_t;
eric@22 44
eric@22 45
eric@22 46 typedef struct output_context_t
eric@22 47 {
eric@22 48 struct output_context_t *parent;
eric@22 49 struct output_context_t *next;
eric@22 50
eric@22 51 int page_count; /* how many pages reference this context,
eric@22 52 including those from subcontexts */
eric@22 53
eric@22 54 char *output_file;
eric@30 55 pdf_file_attributes_t file_attributes;
eric@30 56
eric@22 57 bookmark_t *first_bookmark;
eric@22 58 bookmark_t *last_bookmark;
eric@25 59
eric@25 60 boolean has_page_label;
eric@25 61 page_label_t page_label;
eric@22 62 } output_context_t;
eric@22 63
eric@22 64
eric@22 65 typedef struct output_page_t
eric@22 66 {
eric@22 67 struct output_page_t *next;
eric@22 68 output_context_t *output_context;
eric@22 69 range_t range;
eric@22 70 bookmark_t *bookmark_list;
eric@22 71 } output_page_t;
eric@22 72
eric@22 73
eric@19 74 #define SEMANTIC_DEBUG
eric@19 75 #ifdef SEMANTIC_DEBUG
eric@19 76 #define SDBG(x) printf x
eric@19 77 #else
eric@19 78 #define SDBG(x)
eric@19 79 #endif
eric@19 80
eric@19 81
eric@16 82 FILE *yyin;
eric@16 83 int line; /* line number in spec file */
eric@16 84
eric@24 85 int bookmark_level;
eric@16 86
eric@20 87 input_context_t *first_input_context;
eric@20 88 input_context_t *last_input_context;
eric@20 89
eric@20 90 input_modifier_type_t current_modifier_context;
eric@18 91
eric@20 92 input_image_t *first_input_image;
eric@20 93 input_image_t *last_input_image;
eric@18 94
eric@20 95 output_context_t *first_output_context;
eric@20 96 output_context_t *last_output_context;
eric@20 97
eric@20 98 output_page_t *first_output_page;
eric@20 99 output_page_t *last_output_page;
eric@16 100
eric@16 101
eric@19 102 void input_push_context (void)
eric@16 103 {
eric@18 104 input_context_t *new_input_context;
eric@18 105
eric@18 106 new_input_context = malloc (sizeof (input_context_t));
eric@18 107 if (! new_input_context)
eric@18 108 {
eric@20 109 fprintf (stderr, "failed to malloc an input context\n");
eric@18 110 return;
eric@18 111 }
eric@18 112
eric@20 113 if (last_input_context)
eric@18 114 {
eric@20 115 memcpy (new_input_context, last_input_context, sizeof (input_context_t));
eric@20 116 new_input_context->image_count = 0;
eric@18 117 }
eric@18 118 else
eric@20 119 {
eric@20 120 memset (new_input_context, 0, sizeof (input_context_t));
eric@20 121 first_input_context = new_input_context;
eric@20 122 }
eric@18 123
eric@20 124 new_input_context->parent = last_input_context;
eric@20 125 last_input_context = new_input_context;
eric@16 126 };
eric@16 127
eric@16 128 void input_pop_context (void)
eric@16 129 {
eric@20 130 if (! last_input_context)
eric@18 131 {
eric@18 132 fprintf (stderr, "failed to pop an input context\n");
eric@18 133 return;
eric@18 134 }
eric@18 135
eric@20 136 last_input_context = last_input_context->parent;
eric@16 137 };
eric@16 138
eric@19 139 void input_set_modifier_context (input_modifier_type_t type)
eric@19 140 {
eric@19 141 current_modifier_context = type;
eric@19 142 #ifdef SEMANTIC_DEBUG
eric@19 143 SDBG(("modifier type "));
eric@19 144 switch (type)
eric@19 145 {
eric@19 146 case INPUT_MODIFIER_ALL: SDBG(("all")); break;
eric@19 147 case INPUT_MODIFIER_ODD: SDBG(("odd")); break;
eric@19 148 case INPUT_MODIFIER_EVEN: SDBG(("even")); break;
eric@19 149 default: SDBG(("unknown %d", type));
eric@19 150 }
eric@19 151 SDBG(("\n"));
eric@19 152 #endif /* SEMANTIC_DEBUG */
eric@19 153 }
eric@19 154
eric@22 155 static void input_clone (void)
eric@20 156 {
eric@20 157 input_context_t *new_input_context;
eric@20 158
eric@20 159 if (! last_input_context->image_count)
eric@20 160 return;
eric@20 161
eric@20 162 new_input_context = malloc (sizeof (input_context_t));
eric@20 163 if (! new_input_context)
eric@20 164 {
eric@20 165 fprintf (stderr, "failed to malloc an input context\n");
eric@20 166 return;
eric@20 167 }
eric@20 168
eric@20 169 memcpy (new_input_context, last_input_context, sizeof (input_context_t));
eric@20 170 new_input_context->image_count = 0;
eric@20 171 last_input_context->next = new_input_context;
eric@20 172 }
eric@20 173
eric@16 174 void input_set_file (char *name)
eric@16 175 {
eric@20 176 input_clone ();
eric@20 177 last_input_context->input_file = name;
eric@16 178 };
eric@16 179
eric@19 180 void input_set_rotation (int rotation)
eric@19 181 {
eric@20 182 last_input_context->modifiers [current_modifier_context].has_rotation = 1;
eric@20 183 last_input_context->modifiers [current_modifier_context].rotation = rotation;
eric@19 184 SDBG(("rotation %d\n", rotation));
eric@19 185 }
eric@19 186
eric@32 187 void input_set_page_size (page_size_t size)
eric@32 188 {
eric@32 189 last_input_context->modifiers [current_modifier_context].has_page_size = 1;
eric@32 190 last_input_context->modifiers [current_modifier_context].page_size = size;
eric@32 191 printf ("page size %f, %f\n", size.width, size.height);
eric@32 192 SDBG(("page size %f, %f\n", size.width, size.height));
eric@32 193 }
eric@32 194
eric@22 195 static void increment_input_image_count (int count)
eric@16 196 {
eric@20 197 input_context_t *context;
eric@20 198
eric@20 199 for (context = last_input_context; context; context = context->parent)
eric@20 200 context->image_count += count;
eric@20 201 }
eric@20 202
eric@20 203 void input_images (range_t range)
eric@20 204 {
eric@20 205 input_image_t *new_image;
eric@20 206 int count = ((range.last - range.first) + 1);
eric@20 207
eric@19 208 #ifdef SEMANTIC_DEBUG
eric@20 209 if (range.first == range.last)
eric@20 210 SDBG(("image %d\n", range.first));
eric@16 211 else
eric@20 212 SDBG(("images %d..%d\n", range.first, range.last));
eric@19 213 #endif /* SEMANTIC_DEBUG */
eric@20 214
eric@20 215 new_image = calloc (1, sizeof (input_image_t));
eric@20 216 if (! new_image)
eric@20 217 {
eric@20 218 fprintf (stderr, "failed to malloc an input image struct\n");
eric@20 219 return;
eric@20 220 }
eric@20 221 if (first_input_image)
eric@20 222 {
eric@20 223 last_input_image->next = new_image;
eric@20 224 last_input_image = new_image;
eric@20 225 }
eric@20 226 else
eric@20 227 {
eric@20 228 first_input_image = last_input_image = new_image;
eric@20 229 }
eric@20 230 new_image->range = range;
eric@20 231 new_image->input_context = last_input_context;
eric@20 232 increment_input_image_count (count);
eric@16 233 }
eric@16 234
eric@18 235
eric@18 236 void output_push_context (void)
eric@18 237 {
eric@20 238 output_context_t *new_output_context;
eric@20 239
eric@20 240 new_output_context = malloc (sizeof (output_context_t));
eric@20 241 if (! new_output_context)
eric@20 242 {
eric@20 243 fprintf (stderr, "failed to malloc an output context\n");
eric@20 244 return;
eric@20 245 }
eric@20 246
eric@20 247 if (last_output_context)
eric@20 248 {
eric@20 249 memcpy (new_output_context, last_output_context, sizeof (output_context_t));
eric@20 250 new_output_context->page_count = 0;
eric@21 251 new_output_context->first_bookmark = NULL;
eric@21 252 new_output_context->last_bookmark = NULL;
eric@20 253 }
eric@20 254 else
eric@20 255 {
eric@20 256 memset (new_output_context, 0, sizeof (output_context_t));
eric@20 257 first_output_context = new_output_context;
eric@20 258 }
eric@20 259
eric@20 260 new_output_context->parent = last_output_context;
eric@20 261 last_output_context = new_output_context;
eric@18 262 };
eric@18 263
eric@20 264 void output_pop_context (void)
eric@20 265 {
eric@20 266 if (! last_output_context)
eric@20 267 {
eric@20 268 fprintf (stderr, "failed to pop an output context\n");
eric@20 269 return;
eric@20 270 }
eric@20 271
eric@20 272 last_output_context = last_output_context->parent;
eric@20 273 };
eric@20 274
eric@22 275 static void output_clone (void)
eric@20 276 {
eric@20 277 output_context_t *new_output_context;
eric@20 278
eric@20 279 if (! last_output_context->page_count)
eric@20 280 return;
eric@20 281
eric@20 282 new_output_context = malloc (sizeof (output_context_t));
eric@20 283 if (! new_output_context)
eric@20 284 {
eric@20 285 fprintf (stderr, "failed to malloc an output context\n");
eric@20 286 return;
eric@20 287 }
eric@20 288
eric@20 289 memcpy (new_output_context, last_output_context, sizeof (output_context_t));
eric@20 290 new_output_context->page_count = 0;
eric@20 291 last_output_context->next = new_output_context;
eric@20 292 }
eric@20 293
eric@16 294 void output_set_file (char *name)
eric@16 295 {
eric@20 296 output_clone ();
eric@20 297 last_output_context->output_file = name;
eric@30 298 last_output_context->file_attributes.author = NULL;
eric@30 299 last_output_context->file_attributes.creator = NULL;
eric@30 300 last_output_context->file_attributes.title = NULL;
eric@30 301 last_output_context->file_attributes.subject = NULL;
eric@30 302 last_output_context->file_attributes.keywords = NULL;
eric@16 303 };
eric@16 304
eric@30 305 void output_set_author (char *author)
eric@30 306 {
eric@30 307 last_output_context->file_attributes.author = author;
eric@30 308 }
eric@30 309
eric@30 310 void output_set_creator (char *creator)
eric@30 311 {
eric@30 312 last_output_context->file_attributes.creator = creator;
eric@30 313 }
eric@30 314
eric@30 315 void output_set_title (char *title)
eric@30 316 {
eric@30 317 last_output_context->file_attributes.title = title;
eric@30 318 }
eric@30 319
eric@30 320 void output_set_subject (char *subject)
eric@30 321 {
eric@30 322 last_output_context->file_attributes.subject = subject;
eric@30 323 }
eric@30 324
eric@30 325 void output_set_keywords (char *keywords)
eric@30 326 {
eric@30 327 last_output_context->file_attributes.keywords = keywords;
eric@30 328 }
eric@30 329
eric@20 330 void output_set_bookmark (char *name)
eric@16 331 {
eric@20 332 bookmark_t *new_bookmark;
eric@20 333
eric@20 334 /* As the language is defined (parser.y), a bookmark can only appear
eric@20 335 at the beginning of a context! */
eric@20 336 if (last_output_context->page_count)
eric@20 337 {
eric@20 338 fprintf (stderr, "internal error, bookmark not at beginning of context\n");
eric@20 339 exit (2);
eric@20 340 }
eric@20 341
eric@20 342 new_bookmark = calloc (1, sizeof (bookmark_t));
eric@20 343 if (! new_bookmark)
eric@20 344 {
eric@20 345 fprintf (stderr, "failed to calloc a bookmark\n");
eric@20 346 return;
eric@20 347 }
eric@20 348
eric@24 349 new_bookmark->level = bookmark_level;
eric@20 350 new_bookmark->name = name;
eric@20 351 if (last_output_context->first_bookmark)
eric@20 352 last_output_context->last_bookmark->next = new_bookmark;
eric@20 353 else
eric@20 354 last_output_context->first_bookmark = new_bookmark;
eric@20 355 last_output_context->last_bookmark = new_bookmark;
eric@20 356 }
eric@20 357
eric@25 358 void output_set_page_label (page_label_t label)
eric@20 359 {
eric@20 360 output_clone ();
eric@25 361 last_output_context->has_page_label = 1;
eric@25 362 last_output_context->page_label = label;
eric@20 363 }
eric@20 364
eric@22 365 static void increment_output_page_count (int count)
eric@20 366 {
eric@20 367 output_context_t *context;
eric@20 368
eric@20 369 for (context = last_output_context; context; context = context->parent)
eric@20 370 context->page_count += count;
eric@20 371 }
eric@20 372
eric@21 373
eric@20 374 void output_pages (range_t range)
eric@20 375 {
eric@20 376 output_page_t *new_page;
eric@21 377 output_context_t *context;
eric@20 378 int count = ((range.last - range.first) + 1);
eric@20 379
eric@19 380 #ifdef SEMANTIC_DEBUG
eric@20 381 if (range.first == range.last)
eric@20 382 SDBG(("page %d\n", range.first));
eric@16 383 else
eric@20 384 SDBG(("pages %d..%d\n", range.first, range.last));
eric@19 385 #endif /* SEMANTIC_DEBUG */
eric@20 386
eric@20 387 new_page = calloc (1, sizeof (output_page_t));
eric@20 388 if (! new_page)
eric@20 389 {
eric@20 390 fprintf (stderr, "failed to malloc an output page struct\n");
eric@20 391 return;
eric@20 392 }
eric@20 393 if (first_output_page)
eric@20 394 {
eric@20 395 last_output_page->next = new_page;
eric@20 396 last_output_page = new_page;
eric@20 397 }
eric@20 398 else
eric@20 399 {
eric@20 400 first_output_page = last_output_page = new_page;
eric@20 401 }
eric@20 402 new_page->range = range;
eric@20 403 new_page->output_context = last_output_context;
eric@20 404
eric@21 405 /* transfer bookmarks from context(s) to page */
eric@21 406 for (context = last_output_context; context; context = context->parent)
eric@21 407 if (context->first_bookmark)
eric@21 408 {
eric@21 409 context->last_bookmark->next = new_page->bookmark_list;
eric@21 410 new_page->bookmark_list = context->first_bookmark;
eric@21 411 context->first_bookmark = NULL;
eric@21 412 context->last_bookmark = NULL;
eric@21 413 }
eric@20 414
eric@20 415 increment_output_page_count (count);
eric@16 416 }
eric@16 417
eric@16 418
eric@16 419 void yyerror (char *s)
eric@16 420 {
eric@16 421 fprintf (stderr, "%d: %s\n", line, s);
eric@16 422 }
eric@16 423
eric@16 424
eric@22 425 static char *get_input_file (input_context_t *context)
eric@20 426 {
eric@20 427 for (; context; context = context->parent)
eric@20 428 if (context->input_file)
eric@20 429 return (context->input_file);
eric@20 430 fprintf (stderr, "no input file name found\n");
eric@20 431 exit (2);
eric@20 432 }
eric@20 433
eric@32 434 static boolean get_input_rotation (input_context_t *context,
eric@32 435 input_modifier_type_t type,
eric@32 436 int *rotation)
eric@20 437 {
eric@20 438 for (; context; context = context->parent)
eric@20 439 {
eric@20 440 if (context->modifiers [type].has_rotation)
eric@32 441 {
eric@32 442 * rotation = context->modifiers [type].rotation;
eric@32 443 return (1);
eric@32 444 }
eric@20 445 if (context->modifiers [INPUT_MODIFIER_ALL].has_rotation)
eric@32 446 {
eric@32 447 * rotation = context->modifiers [INPUT_MODIFIER_ALL].rotation;
eric@32 448 return (1);
eric@32 449 }
eric@32 450 }
eric@32 451 return (0); /* default */
eric@32 452 }
eric@32 453
eric@32 454 static boolean get_input_page_size (input_context_t *context,
eric@32 455 input_modifier_type_t type,
eric@32 456 page_size_t *page_size)
eric@32 457 {
eric@32 458 for (; context; context = context->parent)
eric@32 459 {
eric@32 460 if (context->modifiers [type].has_page_size)
eric@32 461 {
eric@32 462 * page_size = context->modifiers [type].page_size;
eric@32 463 return (1);
eric@32 464 }
eric@32 465 if (context->modifiers [INPUT_MODIFIER_ALL].has_page_size)
eric@32 466 {
eric@32 467 * page_size = context->modifiers [INPUT_MODIFIER_ALL].page_size;
eric@32 468 return (1);
eric@32 469 }
eric@20 470 }
eric@20 471 return (0); /* default */
eric@20 472 }
eric@20 473
eric@22 474 static char *get_output_file (output_context_t *context)
eric@20 475 {
eric@20 476 for (; context; context = context->parent)
eric@20 477 if (context->output_file)
eric@20 478 return (context->output_file);
eric@30 479 fprintf (stderr, "no output file found\n");
eric@30 480 exit (2);
eric@30 481 }
eric@30 482
eric@30 483 static pdf_file_attributes_t *get_output_file_attributes (output_context_t *context)
eric@30 484 {
eric@30 485 for (; context; context = context->parent)
eric@30 486 if (context->output_file)
eric@30 487 return (& context->file_attributes);
eric@30 488 fprintf (stderr, "no output file found\n");
eric@20 489 exit (2);
eric@20 490 }
eric@20 491
eric@25 492 static page_label_t *get_output_page_label (output_context_t *context)
eric@20 493 {
eric@20 494 for (; context; context = context->parent)
eric@25 495 if (context->has_page_label)
eric@25 496 return (& context->page_label);
eric@20 497 return (NULL); /* default */
eric@20 498 }
eric@20 499
eric@20 500
eric@20 501 #ifdef SEMANTIC_DEBUG
eric@20 502 void dump_input_tree (void)
eric@20 503 {
eric@20 504 input_image_t *image;
eric@20 505 int i;
eric@20 506
eric@20 507 printf ("input images:\n");
eric@20 508 for (image = first_input_image; image; image = image->next)
eric@20 509 for (i = image->range.first; i <= image->range.last; i++)
eric@20 510 {
eric@20 511 input_modifier_type_t parity = (i % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN;
eric@32 512 boolean has_rotation, has_page_size;
eric@32 513 int rotation;
eric@32 514 page_size_t page_size;
eric@32 515
eric@32 516 has_rotation = get_input_rotation (image->input_context,
eric@32 517 parity,
eric@32 518 & rotation);
eric@32 519 has_page_size = get_input_page_size (image->input_context,
eric@32 520 parity,
eric@32 521 & page_size);
eric@32 522 printf ("file '%s' image %d",
eric@20 523 get_input_file (image->input_context),
eric@32 524 i);
eric@32 525 if (has_rotation)
eric@32 526 printf (" rotation %d", rotation);
eric@32 527 if (has_page_size)
eric@32 528 printf (" size %f, %f", page_size.width, page_size.height);
eric@32 529 printf ("\n");
eric@20 530 }
eric@20 531 }
eric@20 532
eric@20 533 void dump_output_tree (void)
eric@20 534 {
eric@20 535 int i;
eric@20 536 output_page_t *page;
eric@20 537 bookmark_t *bookmark;
eric@20 538
eric@20 539 printf ("output pages:\n");
eric@20 540 for (page = first_output_page; page; page = page->next)
eric@20 541 {
eric@20 542 if (page->bookmark_list)
eric@20 543 {
eric@20 544 for (bookmark = page->bookmark_list; bookmark; bookmark = bookmark->next)
eric@25 545 printf ("bookmark %d \"%s\"\n", bookmark->level, bookmark->name);
eric@20 546 }
eric@20 547 for (i = page->range.first; i <= page->range.last; i++)
eric@20 548 {
eric@25 549 page_label_t *label = get_output_page_label (page->output_context);
eric@25 550 printf ("file \"%s\" ", get_output_file (page->output_context));
eric@25 551 if (label)
eric@25 552 {
eric@25 553 printf ("label ");
eric@25 554 if (label->prefix)
eric@25 555 printf ("\"%s\" ", label->prefix);
eric@25 556 if (label->style)
eric@25 557 printf ("'%c' ", label->style);
eric@25 558 }
eric@20 559 printf ("page %d\n", i);
eric@20 560 }
eric@20 561 }
eric@20 562 }
eric@20 563 #endif /* SEMANTIC_DEBUG */
eric@20 564
eric@25 565
eric@25 566 static inline int range_count (range_t range)
eric@25 567 {
eric@25 568 return ((range.last - range.first) + 1);
eric@25 569 }
eric@25 570
eric@25 571
eric@16 572 boolean parse_spec_file (char *fn)
eric@16 573 {
eric@16 574 boolean result = 0;
eric@16 575
eric@16 576 yyin = fopen (fn, "r");
eric@16 577 if (! yyin)
eric@16 578 {
eric@16 579 fprintf (stderr, "can't open spec file '%s'\n", fn);
eric@16 580 goto fail;
eric@16 581 }
eric@16 582
eric@16 583 line = 1;
eric@16 584
eric@20 585 input_push_context (); /* create root input context */
eric@20 586 input_push_context (); /* create inital input context */
eric@20 587
eric@20 588 output_push_context (); /* create root output context */
eric@18 589 output_push_context (); /* create initial output context */
eric@18 590
eric@16 591 yyparse ();
eric@16 592
eric@20 593 if (first_input_context->image_count != first_output_context->page_count)
eric@18 594 {
eric@20 595 fprintf (stderr, "input image count %d != output page count %d\n",
eric@20 596 first_input_context->image_count,
eric@20 597 first_output_context->page_count);
eric@18 598 goto fail;
eric@18 599 }
eric@18 600
eric@20 601 fprintf (stderr, "%d pages specified\n", first_input_context->image_count);
eric@18 602
eric@16 603 result = 1;
eric@16 604
eric@20 605 #ifdef SEMANTIC_DEBUG
eric@20 606 dump_input_tree ();
eric@20 607 dump_output_tree ();
eric@20 608 #endif /* SEMANTIC_DEBUG */
eric@20 609
eric@16 610 fail:
eric@16 611 if (yyin)
eric@16 612 fclose (yyin);
eric@16 613
eric@16 614 return (result);
eric@16 615 }
eric@26 616
eric@26 617
eric@26 618 boolean process_specs (void)
eric@26 619 {
eric@26 620 input_image_t *image = NULL;
eric@26 621 output_page_t *page = NULL;
eric@26 622 int i = 0;
eric@26 623 int p = 0;
eric@26 624 int page_index = 0;
eric@26 625 input_attributes_t input_attributes;
eric@26 626 input_modifier_type_t parity;
eric@26 627 page_label_t *page_label;
eric@26 628
eric@26 629 for (;;)
eric@26 630 {
eric@26 631 if ((! image) || (i >= range_count (image->range)))
eric@26 632 {
eric@26 633 if (image)
eric@26 634 image = image->next;
eric@26 635 else
eric@26 636 image = first_input_image;
eric@26 637 if (! image)
eric@26 638 return (0);
eric@26 639 i = 0;
eric@26 640 if (! open_tiff_input_file (get_input_file (image->input_context)))
eric@26 641 return (0);
eric@26 642 }
eric@26 643
eric@26 644 if ((! page) || (p >= range_count (page->range)))
eric@26 645 {
eric@26 646 if (page)
eric@26 647 page = page->next;
eric@26 648 else
eric@26 649 page = first_output_page;
eric@26 650 p = 0;
eric@30 651 if (! open_pdf_output_file (get_output_file (page->output_context),
eric@30 652 get_output_file_attributes (page->output_context)))
eric@26 653 return (0);
eric@26 654 page_label = get_output_page_label (page->output_context);
eric@26 655 process_page_numbers (page_index,
eric@26 656 range_count (page->range),
eric@26 657 page->range.first,
eric@26 658 page_label);
eric@26 659 }
eric@26 660
eric@26 661 parity = ((image->range.first + i) % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN;
eric@26 662
eric@26 663 memset (& input_attributes, 0, sizeof (input_attributes));
eric@32 664
eric@32 665 input_attributes.rotation = 0;
eric@32 666 input_attributes.has_rotation = get_input_rotation (image->input_context,
eric@32 667 parity,
eric@32 668 & input_attributes.rotation);
eric@32 669
eric@32 670 input_attributes.has_page_size = get_input_page_size (image->input_context,
eric@32 671 parity,
eric@32 672 & input_attributes.page_size);
eric@26 673
eric@26 674 process_page (image->range.first + i,
eric@26 675 input_attributes,
eric@26 676 page->bookmark_list);
eric@26 677 i++;
eric@26 678 p++;
eric@26 679 page_index++;
eric@26 680 }
eric@26 681
eric@26 682 return (1);
eric@26 683 }