|
|
1.1 root 1: /*** file = ipfe.c ********************************************/
2:
3: /*** start of specifications ************************************
4: *
5: * name = ipfe
6: * descriptive name = interpress file editor
7: * filename = ipfe.c
8: * module type = main
9: * subsystem name = interpress toolkit
10: * copyright = (c) 1985, 1986, xerox corporation
11: * author = mark l. rollins
12: * date written = 10/oct/85
13: *
14: * change activity =
15: * 07/18/86 r1.05 mlr wrc: changed so Scale follows, rather than
16: * precedes, Rotate, BindingOffset, XOffset,
17: * and YOffset in output processing
18: * 06/16/86 r1.04 mlr wrc: add Scale processing
19: * 05/19/86 r1.03 mlr wrc: fixed bug in dsply of Y-offset values
20: * 04/22/86 r1.02 mlr wrc: fixed bug in pagerange parsing that gave
21: * error on terminating "]";
22: * add vers display
23: * 03/14/86 r1.01 mlr wrc: major enhancements
24: * 10/10/85 r1.00 mlr wrc: original date
25: *
26: * release = r1.05
27: * date = 18/jul/86
28: *
29: * function = provide the following skeleton- and page-level functions
30: * for editing interpress masters:
31: * . concatenate masters
32: * . merge pages from multiple masters into one master
33: * . overlay selected pages as a single page (may be
34: * combined with merge function)
35: * . chapterize a master into multiple masters
36: * . satisfy sequenceInsertFile & sequenceInsertMaster
37: * references
38: * . resolve alias and binding offset printing instructions
39: * . return information about the properties of a set of
40: * masters
41: *
42: * function description =
43: *
44: * Usage: ipfe [ options ] file [ pagerange] ... [ file [pagerange] ...]
45: * Options: [-l logfile] [-dDiLqrRsS] [-a alias:actual [-a alias:actual]
46: * ...] [-b offset:unit] [-c count:unit] [-o outfile]
47: * [-p level:propfile] [-S factor] [-X offset:unit]
48: * [-Y offset:unit]
49: *
50: * -a alias:actual
51: * (alias). If the -s option is specified,
52: * replace any SIF matching the string "alias"
53: * with the string "actual" before attempting
54: * to satisfy the SIF. If "actual" cannot be
55: * opened or there is some error, the SIF
56: * "alias" is preserved, unless the -r option
57: * is also specified.
58: * -b offset:unit (binding offset). Shift the image offset units
59: * in the x-direction, where unit may be: none
60: * (default centimeters), c (centimeters), i
61: * (inches), p (points), P (Picas). If the -L
62: * (Landscape) switch is set, the image offset
63: * is in the y-direction.
64: * -c count:unit (chapterize) every count units, where unit may
65: * be p (pages), k (kilobytes), or m (megabytes).
66: * -d (duplex). For resolving binding offset.
67: * -D (Debug). If the -p option is specified, also
68: * write to the properties file the offsets of
69: * each skeleton-level token encountered.
70: * -i (insert SIF for overlay). Insert (create) a
71: * SIF for any unresolvable overlays.
72: * -l logfile (log). Keep a running log.
73: * -L (Landscape). Rotate every page 90 degrees
74: * counterclockwise and preserve the upper left
75: * corner. Intended for printing text in
76: * landscape orientation.
77: * -o outfile (output). Where the output goes. If there is
78: * no -o and there is a -p, only the properties
79: * are written, else if there is no -o
80: * "infile.ip" is used if it doesn't already
81: * exist, else "infileN.ip" is used, where N
82: * is the lowest ordinal number such that
83: * "infileN.ip" does not already exist.
84: * -p level:propfile
85: * (properties). Where the properties are
86: * written. Increasing levels provide increasing
87: * information details.
88: * -q (quiet). Don't write info & error msgs (to
89: * STDERR).
90: * -r (remove SIFS). If -s is also specified, it
91: * takes precedence and a SIF reference is
92: * removed only if it is unresolved or there is
93: * some other error.
94: * -R (Rotate). Rotate every page 90 degrees
95: * clockwise and preserve the center point.
96: * Intended for rotating an image created for
97: * a "landscape printer" to print in portrait
98: * orientation.
99: * -s (satisfy SIFS). Replace any SIF references
100: * tokens found in the referenced file. If the
101: * referenced file cannot be opened, the SIF
102: * reference is preserved unless -r is also
103: * specified.
104: * -S factor (scale). Scale the image by factor.
105: * -X offset:unit (X-imageShift). Shift the image offset units
106: * in the x-direction, where unit may be: none
107: * (default centimeters), c (centimeters), i
108: * (inches), p (points), P (Picas). The shift
109: * is independent of the -L and -R switches
110: * (i.e., the x-direction is the same as the
111: * unrotated image).
112: * -Y offset:unit (Y-imageShift). Shift the image offset units
113: * in the y-direction, where unit may be: none
114: * (default centimeters), c (centimeters), i
115: * (inches), p (points), P (Picas). The shift
116: * is independent of the -L and -R switches
117: * (i.e., the y-direction is the same as the
118: * unrotated image).
119: * infile [pagerange]
120: * See the manual page for syntax details.
121: * Example:
122: * [1,4-6,9[pic1],10-11,12[pic2:2(2P,4P)][pic3(-4P,-2P)],15-]
123: * include page 1.
124: * skip pages 2-3.
125: * include pages 4-6.
126: * skip pages 7-8.
127: * include page 9, overlaying it with pic1.
128: * include pages 10-11.
129: * include pages 12, overlaying it with page 2 of
130: * pic2 at an offset of 2 Picas to the right
131: * and 4 Picas up, and pic3 at an offset of
132: * 4 Picas to the left and 2 Picas down.
133: * skip pages 13-14.
134: * include pages 15 thru the end of the master.
135: *
136: * linkage =
137: * entry = exec ipfe
138: * input = see cmd line options above
139: * output = interpress master(s), STDERR, log file, property file
140: * exit = exit(exit_status)
141: *
142: * publics =
143: *
144: * dependencies =
145: * src = iptokens.h, ipnames.h
146: * obj =
147: * lnk =
148: *
149: * environment =
150: * runtime = vax/masscomp unix/4.23bsd
151: * development = vax unix/4.23bsd
152: * processor = cc
153: * code = unix c mnemonics & linkages
154: *
155: *** end of specifications **************************************/
156:
157: #ifdef vax11c
158: # include stdio
159: # include setjmp
160: # include ctype
161: #else
162: # include <stdio.h>
163: /***
164: # include <sys/time.h>
165: # include <sys/resource.h>
166: ***/
167: # include <setjmp.h>
168: # include <ctype.h>
169: #endif
170:
171: #include "iptokens.h"
172: #include "ipnames.h"
173:
174:
175: #define IPFE_VERS "1.05"
176: #define IPFE_DATE "18 JUL 86"
177:
178: #define FALSE 0
179: #define TRUE 1
180: #define FLAG_OFF 0
181: #define FLAG_ON 1
182:
183: #define CR 13
184: #define BEL 07
185: #define BS 08
186: #define TAB 09
187: #define LF 10
188: #define FF 12
189: #define TOF 12
190: #define SPC 32
191: #define ESC 27
192: #define DEL 127
193:
194: #define STDIN stdin
195: #define STDOUT stdout
196: #define STDERR stderr
197: #define STDIN_DEV 0
198: #define STDOUT_DEV 1
199: #define STDERR_DEV 2
200: #define DEF_LOGFILENAME "ipfe.log"
201: #define DEF_OUTFILENAME "ipfe.ip"
202: #define DEF_PROPFILENAME "ipfe.prop"
203: #define DEF_WORKFILENAME "ipfe.wrk"
204: #define BUFSIZE 2048
205: #define OP_Mask 0xe0
206: #define OK 0
207: #define ERROR (-1)
208: #define DONT_FORMAT 0
209: #define FORMAT 1
210: #define MX_NO_INFILES 64
211: #define MX_NO_OUTFILES 64
212: #define MX_NO_OVLY_FILES 64
213: #define IP_HDR_CHKLEN 17
214: #define IP_VERS_OFFSET 17
215: #define IP_HDR_MASTERLEN 21
216: #define MX_HDR_BUFLEN 255
217: #define MX_NO_ALIASES 128
218: #define MX_NO_MPG_ENTRIES 128
219: #define MX_BLOCK_DEPTH 8
220: #define MX_BODY_DEPTH 8
221: #define MX_BOP_DEPTH 16 /* max # of nested body_operators */
222: #define MX_SIF_DEPTH 8 /* max sif nesting depth */
223: #define INDENT_INCR 3 /* # cols to incr indent each nesting depth */
224:
225: /*
226: * defines for ipfe fn types
227: */
228: #define CONCAT 0
229: #define CHAPTERIZE 1
230: #define SATISFY_SIFS 2
231: #define REMOVE_SIFS 3
232: #define PROPERTIES 4
233: #define INSERT_OVLY 5
234: #define DEBUG 6
235: #define PROC_LOG 7
236: #define FORCE_STDOUT 8
237: #define BINDING_OFFSET 9
238: #define DUPLEX 10
239: #define QUIET 11
240: #define LANDSCAPE 12
241: #define ROTATE 13
242: #define SCALE 14
243: #define X_OFFSET 15
244: #define Y_OFFSET 16
245: #define NUM_FNS 17
246:
247: /*
248: * defines for chapterization type
249: */
250: #define CH_PAGES 1
251: #define CH_KBYTES 2
252: #define CH_MBYTES 3
253:
254: #ifdef lcv2 /* if Lattice C vers 2.15 or earlier */
255: #define void int
256: #endif
257:
258: /*
259: * lattice C defines for fopen file types (binary & text)
260: */
261: #define BINARY_FILE 0x8000
262: #define TEXT_FILE 0
263:
264: FILE *input;
265: FILE *output;
266: FILE *workfile; /* work file for testing input file opens & storing
267: hdr/preamble for chapterizing */
268: FILE *ovly_file;
269: FILE *sif_file[MX_SIF_DEPTH];
270: FILE *siffile;
271: FILE *logfile;
272: FILE *propfile;
273:
274: jmp_buf next_file;
275:
276: extern int errno;
277:
278:
279: int _fmode = TEXT_FILE; /* lattice C file_mode */
280: int abort_flag, debug_flag;
281: int terrno;
282: int exit_status;
283:
284: long pos, in_offset, out_offset;
285: long out_beg_offset[MX_BLOCK_DEPTH],
286: out_end_offset[MX_BLOCK_DEPTH];
287: long chap_val;
288: long boff_num, boff_den; /* binding offset numerator, denominator */
289: long xoff_num, xoff_den; /* xOffset numerator, denominator */
290: long yoff_num, yoff_den; /* yOffset numerator, denominator */
291: long rxoff_num, rxoff_den, /* rotation xOffset numerator, denominator */
292: ryoff_num, ryoff_den; /* yOffset numerator, denominator */
293: long scale_num, scale_den; /* scale factor numerator, denominator */
294: long blk_num_bytes[MX_BLOCK_DEPTH];
295: long pg_num_bytes;
296:
297: int num_infiles, out_filnum;
298: int input_indx, output_indx, sif_indx;
299: int prop_level;
300:
301: int cur_indent, off_indent, cur_col;
302: int ovly_flag;
303: int proc_flag[NUM_FNS];
304: int chap_type;
305: int ipwrite_flag;
306: int rot_deg; /* rotation degrees */
307: int num_aliases;
308: int alias_indx;
309:
310: int begBody_flag;
311: int preamble_expected, endpreamble_expected, frstpg_flag,
312: bop_preamble_expected[MX_BOP_DEPTH];
313: /*
314: * MERGE & OVERLAY ARRAYS
315: * There are 2 second order arrays, one for merge pages and one for
316: * overlay files. The 1st order of both is indexed by input_indx, and
317: * the 2nd order by merge_indx. For overlay files, there are 3
318: * additional arrays, one for an overlay pagenum, one for page offset
319: * numerators, and one for page offset denominators. These 3 arrays
320: * are indexed by ovly_indx (the 1st order indexing for the numerator
321: * and denominator arrays is 0 for the x-offset and 1 for the y-offset).
322: *
323: * Each 2nd order vector of the merge_pg[][] array is initialized to
324: * (-1),0,0,... which indicates to include all pages, and each vector
325: * of the ovly_pg[][] array is initialized to (-1),(-1),(-1),... which
326: * indicates no overlay files.
327: * As IPFE scans the command line, an entry is put into the merge_pg[][]
328: * array for each pageNum specified in a pagerange for an infile (the
329: * value put into the entry is pageNum). If there is an overlay file
330: * specified for pageNum, the (-1) in the ovly_pg[][merge_indx] entry
331: * is replaced with the current value of ovly_indx and ovly_indx is
332: * incremented. If there is another overlay file specified for pageNum,
333: * the value pageNum is repeated in the next merge_pg[][] entry and the
334: * incremented ovly_indx is placed in the next ovly_pg[][] entry.
335: * Example:
336: * ipfe infile "[2,4-6,9[ovly1],12[ovly2][ovly3],15-]"
337: * will yield the following merge_pg[input_indx][] &
338: * ovly_pg[input_indx][] vectors:
339: * 0 1 2 3 4 5 6 7 8 9 10
340: * ----|----|----|----|----|----|----|----|----|----|----
341: * merge_pg: 2 , 4 ,(-1), 6 , 9 , 12 , 12 , 15 ,(-1), 0 , 0 ,...
342: * ovly_pg: (-1),(-1),(-1),(-1), 0 , 1 , 2 ,(-1),(-1),(-1),(-1),...
343: *
344: * The algorithm used to decode the merge_pg vector for each infile is
345: * as follows:
346: * Initialize merge_indx to 0;
347: * Loop:
348: * Current_entry = merge_pg[input_indx][merge_indx];
349: * If Current_entry = 0, we're all done with this infile;
350: * Else if Current_entry = (-1), look at next merge_indx entry;
351: * Next_entry = merge_pg[input_indx][merge_indx+1];
352: * If Next_entry = 0, include all pages to the end of infile;
353: * Else include all pages until the value of Next_entry is
354: * reached in infile; when it is, increment merge_indx (making
355: * Current_entry = Next_entry, and goto Loop;
356: * Else exclude all pages until Current_entry is reached in infile
357: * (it may already be reached); when it is, include that page and
358: * check the ovly_pg[][] entry;
359: * Ovly_entry = ovly_pg[input_indx][merge_indx];
360: * If Ovly_entry != (-1) do overlay processing;
361: * Increment merge_indx, and goto Loop;
362: */
363: int merge_indx, merge_pg[MX_NO_INFILES][MX_NO_MPG_ENTRIES];
364: int ovly_indx, ovly_pg[MX_NO_INFILES][MX_NO_MPG_ENTRIES];
365: int ovly_pgnum[MX_NO_OVLY_FILES];
366: long ovly_num[2][MX_NO_OVLY_FILES],
367: ovly_den[2][MX_NO_OVLY_FILES];
368:
369: int block_indx;
370: int block_flag;
371: int bproc_indx, bop_indx, bop_iindx[MX_BOP_DEPTH];
372: int bproc_flag, bop_flag;
373: int num_blocks, num_pages, num_sifs,
374: tnum_blocks, tnum_pages, tnum_sifs;
375: int out_numpages;
376:
377: int infile_flag[MX_NO_INFILES];
378:
379: int hdr_len;
380: char hdr_buf[MX_HDR_BUFLEN+1], hdr_workbuf[MX_HDR_BUFLEN+1];
381:
382: char input_name[MX_NO_INFILES][128], input_fnm[128], input_ext[128],
383: output_name[128], output_fnm[128], output_ext[128],
384: work_fname[128], sif_name[MX_SIF_DEPTH][128], prop_fname[128];
385: char ovly_fname[MX_NO_OVLY_FILES][128];
386: char alias_ref[MX_NO_ALIASES][128], alias_act[MX_NO_ALIASES][128];
387: char *inputname, *outputname, *sifname, *propfname;
388: char *logfilename = "ipfe.log";
389:
390: char *itostr(), lcase(), *op_name(), *strcat(), *strcpy();
391:
392: /****************************************************************
393: *
394: * main(argc, argv): ipfe mainline:
395: * main: interpress file editor
396: *
397: ****************************************************************/
398:
399: main(argc, argv)
400:
401: int argc;
402: char *argv[];
403: {
404: char msg[128];
405:
406:
407: (void)sprintf(msg,
408: "\nIPFE Version %s, %s -- Interpress File Editor\n",
409: IPFE_VERS, IPFE_DATE);
410: pip_error(msg);
411: pip_error("Copyright (c) 1985,1986 Xerox Corporation\n\n");
412: init_ipfe();
413: get_cmd_args(argc, argv);
414: init1_ipfe(); /* initialization after getting cmd args */
415:
416:
417: for (input_indx=0; input_indx < num_infiles; input_indx++)
418: {
419: init_proc_file();
420: inputname = input_name[input_indx];
421: (void)sprintf(msg, "-- File: %s--\n", inputname);
422: pip_error(msg);
423: pip_prop(msg);
424:
425: _fmode = BINARY_FILE;
426: input = fopen(inputname, "r");
427: if (input == NULL)
428: {
429: (void)sprintf(msg, "\nError opening input file: %s\n",
430: inputname);
431: pip_error(msg);
432: pip_prop(msg);
433: }
434: else
435: {
436: proc_file(); /* do the real work */
437: (void)fclose(input);
438: }
439: }
440:
441: if ((abort_flag == FLAG_OFF) &&
442: (proc_flag[CONCAT] == FLAG_ON))
443: {
444: ipwrite_flag = FLAG_ON; /* in case it was turned off by
445: last file processed */
446: put_op(OP_endBlock);
447: }
448:
449: cleanup();
450: exit(exit_status);
451: }
452:
453:
454: /****************************************************************
455: *
456: * cleanup: housecleaning
457: *
458: ****************************************************************/
459:
460: cleanup()
461: {
462: char msg[128];
463:
464:
465: if (proc_flag[CONCAT] == FLAG_ON)
466: {
467: (void)sprintf(msg, "\n--Total Number of Blocks:%4d\n", tnum_blocks);
468: pip_prop(msg);
469: (void)sprintf(msg, "--Total Number of Pages :%4d\n", tnum_pages);
470: pip_prop(msg);
471: (void)sprintf(msg, "--Total Number of SIFs :%4d\n", tnum_sifs);
472: pip_prop(msg);
473: }
474: mputc_prop('\n');
475:
476: (void)sprintf(msg, "\n-- Total Number of Input Pages :%4d\n",
477: tnum_pages);
478: pip_error(msg);
479: if ((output != NULL) || (out_numpages > 0))
480: {
481: (void)sprintf(msg, "-- Total Number of Output Pages:%4d\n",
482: out_numpages);
483: pip_error(msg);
484: }
485: pip_error("\n");
486:
487: if (logfile != NULL)
488: (void)fclose(logfile);
489:
490: if (propfile != NULL)
491: (void)fclose(propfile);
492:
493: if (output != NULL)
494: (void)fclose(output);
495:
496: }
497:
498:
499: /****************************************************************
500: *
501: * int count_int_bytes(val):
502: * int count_int_bytes: return the number of bytes in the
503: * specified int val
504: *
505: ****************************************************************/
506:
507: int count_int_bytes(val)
508:
509: long val;
510: {
511: long mask;
512: int i;
513:
514:
515: if ((val == 0) || (val == (-1)))
516: i = 1; /* avoid infinite looping */
517: else
518: {
519: if (val < 0)
520: val = ~(val); /* same # of bytes as one's complement */
521:
522: mask = 0xff800000;
523: for (i=4; ((val & mask) == 0); i--)
524: mask = mask >> 8;
525:
526: }
527:
528: return(i);
529: }
530:
531:
532: /****************************************************************
533: *
534: * create_SIF(fname):
535: * create_SIF: create a new SIF (for ovly handling)
536: *
537: ****************************************************************/
538:
539: create_SIF(fname)
540:
541: char *fname;
542: {
543: int not_created_flag;
544: char msg[128];
545:
546:
547: not_created_flag = FLAG_OFF;
548: if (proc_flag[INSERT_OVLY] == FLAG_ON)
549: {
550: if (ovly_pgnum[ovly_indx] < 2)
551: {
552: (void)sprintf(msg,
553: " --Creating SIF: %s\n", fname);
554: pip_error(msg);
555: put_seq_type_len(sequenceInsertFile, (long)strlen(fname));
556: ip_puts(fname);
557: }
558: else
559: {
560: pip_error(
561: " --Cannot create SIF for overlay with pageNum > 1\n");
562: not_created_flag = FLAG_ON;
563: }
564: }
565: else
566: {
567: pip_error(
568: " -i switch (Insert SIF for overlay) not specified\n");
569: not_created_flag = FLAG_ON;
570: }
571: if (not_created_flag == FLAG_ON)
572: {
573: (void)sprintf(msg,
574: " --SIF Not Created for: %s\n",
575: fname);
576: pip_error(msg);
577: }
578:
579: }
580:
581:
582: /****************************************************************
583: *
584: * get_cmd_args(argc, argv):
585: * get_cmd_args: get cmd_line arguments
586: * gca: label for editing
587: *
588: ****************************************************************/
589:
590: get_cmd_args(argc, argv)
591:
592: int argc;
593: char *argv[];
594: {
595: long val, val1, d;
596: int arg, opt, opt_len, ch_ctr, neg_flag, sep_flag, retcd;
597: int err_flag = FLAG_OFF;
598: char ch, sep_char, msg[128];
599:
600:
601: for (arg=1; arg < argc; arg++) /* look for cmd_arguments */
602: {
603: switch
604: (argv[arg][0])
605: {
606: case ('-'):
607: opt_len = strlen(argv[arg]); /* because arg can be */
608: /* modified below */
609: for (opt=1; opt < opt_len; opt++)
610: {
611: switch
612: (argv[arg][opt])
613: {
614: case ('-'):
615: opt = opt_len; /* to handle '--' switch */
616: break;
617:
618: case ('a'):
619: if (strlen(&(argv[arg][opt])) > 1)
620: ++opt;
621: else
622: {
623: ++arg;
624: opt = 0;
625: opt_len = strlen(argv[arg]);
626: }
627: proc_alias(&(argv[arg][opt]));
628: opt = opt_len; /* to get out of loop */
629: break;
630:
631: case ('b'):
632: if (strlen(&(argv[arg][opt])) > 1)
633: ++opt;
634: else
635: {
636: ++arg;
637: opt = 0;
638: opt_len = strlen(argv[arg]);
639: }
640: /*
641: * binding offset:unit
642: */
643: val = val1 = d = ch_ctr = 0;
644: neg_flag = FLAG_OFF;
645: while
646: (opt < opt_len)
647: {
648: ch = argv[arg][opt++];
649: if ((ch == '-') && (ch_ctr == 0))
650: neg_flag = FLAG_ON;
651: else
652: if ((ch >= '0') && (ch <= '9'))
653: {
654: ch = ch - '0';
655: if (d == 0)
656: val = (val * 10) + ch;
657: else
658: if (d <= 1000) /* prec = 10**(-3)
659: truncated */
660: {
661: val1 = (val1 * 10) + ch;
662: d = d * 10;
663: }
664: }
665: else
666: if (ch == '.')
667: d = 1;
668: else
669: {
670: if ((ch == ':') && (opt < opt_len))
671: ch = argv[arg][opt++];
672: break; /* exit loop */
673: }
674: ++ch_ctr;
675: }
676: /* end while (opt < opt_len) */
677:
678: if (d == 0)
679: d = 1;
680: else
681: val = (val * d) + val1;
682:
683: if (val != 0)
684: {
685: if (neg_flag == FLAG_ON)
686: val = -(val);
687: switch
688: (ch)
689: {
690: case ('c'):
691: d = d * 100;
692: break;
693: case ('i'):
694: val = val * 254;
695: d = d * 10000;
696: break;
697: case ('p'):
698: val = val * 254;
699: d = ((d * 720000) & 0x7fffffff);
700: break;
701: case ('P'):
702: val = val * 254;
703: d = ((d * 60000) & 0x7fffffff);
704: break;
705: default:
706: d = d * 100; /* def=cm */
707: break;
708: }
709: /* end switch (ch) */
710:
711: if (d != 0) /* last chk for div
712: by 0 just in case
713: of ovflw */
714: {
715: boff_num = val;
716: boff_den = d;
717: proc_flag[BINDING_OFFSET] =
718: FLAG_ON;
719: }
720: }
721: else
722: {
723: (void)sprintf(msg,
724: "--ipfe: No binding offset value specified in (%s)\n",
725: argv[arg]);
726: pip_error(msg);
727: err_flag = FLAG_ON;
728: }
729: --opt; /* to parse cur ch at cmd line */
730: break;
731:
732: case ('c'):
733: if (strlen(&(argv[arg][opt])) > 1)
734: ++opt;
735: else
736: {
737: ++arg;
738: opt = 0;
739: opt_len = strlen(argv[arg]);
740: }
741: ch = val = 0;
742: while
743: (opt < opt_len)
744: {
745: ch = argv[arg][opt];
746: if ((ch >= '0') && (ch <= '9'))
747: {
748: ch = ch - '0';
749: val = (val * 10) + ch;
750: ++opt;
751: }
752: else
753: break;
754: }
755: if (val == 0)
756: {
757: (void)sprintf(msg,
758: "--ipfe: No length specified for chapterize in %s\n",
759: argv[arg]);
760: pip_error(msg);
761: err_flag = FLAG_ON;
762: }
763: else
764: {
765: if ((ch == ':') && (opt < opt_len))
766: ch = argv[arg][++opt];
767:
768: switch
769: (ch)
770: {
771: case ('p'):
772: proc_flag[CHAPTERIZE] = FLAG_ON;
773: chap_type = CH_PAGES;
774: chap_val = val;
775: break;
776: case ('k'):
777: proc_flag[CHAPTERIZE] = FLAG_ON;
778: chap_type = CH_KBYTES;
779: chap_val = val * 1024;
780: break;
781: case ('m'):
782: proc_flag[CHAPTERIZE] = FLAG_ON;
783: chap_type = CH_MBYTES;
784: chap_val = ((val * 1048576) &
785: 0x7fffffff);
786: break;
787: default:
788: (void)sprintf(msg,
789: "--ipfe: No unit specified for chapterize in %s\n",
790: argv[arg]);
791: pip_error(msg);
792: err_flag = FLAG_ON;
793: --opt; /* parse opt again */
794: break;
795: }
796: }
797: break;
798:
799: case ('d'):
800: proc_flag[DUPLEX] = FLAG_ON;
801: break;
802:
803: case ('D'):
804: proc_flag[DEBUG] = FLAG_ON;
805: break;
806:
807: case ('i'):
808: proc_flag[INSERT_OVLY] = FLAG_ON;
809: break;
810:
811: case ('l'):
812: proc_flag[PROC_LOG] = FLAG_ON;
813: if (strlen(&(argv[arg][opt])) > 1)
814: ++opt;
815: else
816: {
817: ++arg;
818: opt = 0;
819: opt_len = strlen(argv[arg]);
820: }
821: ch = argv[arg][opt];
822: if ((ch != ':') && (ch != '-'))
823: {
824: logfilename = &(argv[arg][opt]);
825: opt = opt_len; /* to get out of lp */
826: }
827: open_logfile(argc, argv);
828: break;
829:
830: case ('L'):
831: rot_deg = 90;
832: rxoff_num = rxoff_den = 0;
833: ryoff_num = -(2794);
834: ryoff_den = 10000;
835: proc_flag[LANDSCAPE] = FLAG_ON;
836: break;
837:
838: case ('o'):
839: if (strlen(&(argv[arg][opt])) > 1)
840: outputname = &(argv[arg][opt+1]);
841: else
842: outputname = argv[++arg];
843: opt = opt_len; /* to get out of loop */
844: break;
845:
846: case ('p'):
847: proc_flag[PROPERTIES] = FLAG_ON;
848: if (strlen(&(argv[arg][opt])) > 1)
849: ++opt;
850: else
851: {
852: ++arg;
853: opt = 0;
854: opt_len = strlen(argv[arg]);
855: }
856: ch = argv[arg][opt];
857: if ((ch != ':') && (ch != '-'))
858: {
859: if ((ch >= '0') && (ch <= '9'))
860: {
861: prop_level = ch - '0';
862: ++opt;
863: if (argv[arg][opt] == ':')
864: ++opt;
865: if (opt < opt_len)
866: propfname = &(argv[arg][opt]);
867: opt = opt_len; /* to exit loop */
868: }
869: else
870: {
871: (void)sprintf(msg,
872: "--ipfe: *** warning -- property level not specified in %s\n",
873: argv[arg]);
874: pip_error(msg);
875: err_flag = FLAG_ON;
876: propfname = &(argv[arg][opt]);
877: opt = opt_len; /* to exit loop */
878: }
879: }
880: break;
881:
882: case ('q'):
883: proc_flag[QUIET] = FLAG_ON;
884: break;
885:
886: case ('r'):
887: proc_flag[REMOVE_SIFS] = FLAG_ON;
888: break;
889:
890: case ('R'):
891: rot_deg = -(90);
892: rxoff_num = -(2477); /* xOff = -(9 3/4") */
893: ryoff_num = -(318); /* yOff = -(1 1/4") */
894: rxoff_den = ryoff_den = 10000;
895: proc_flag[ROTATE] = FLAG_ON;
896: break;
897:
898: case ('s'):
899: proc_flag[SATISFY_SIFS] = FLAG_ON;
900: break;
901:
902: case ('S'):
903: if (strlen(&(argv[arg][opt])) > 1)
904: ++opt;
905: else
906: {
907: ++arg;
908: opt = 0;
909: opt_len = strlen(argv[arg]);
910: }
911: /*
912: * scale
913: */
914: val = val1 = d = ch_ctr = 0;
915: neg_flag = sep_flag = FLAG_OFF;
916: while
917: (opt < opt_len)
918: {
919: ch = argv[arg][opt++];
920: if ((ch == '-') && (ch_ctr == 0))
921: neg_flag = FLAG_ON;
922: else
923: if ((ch >= '0') && (ch <= '9'))
924: {
925: ch = ch - '0';
926: if (d == 0)
927: val = (val * 10) + ch;
928: else
929: if (d <= 1000) /* prec = 10**(-3)
930: truncated */
931: {
932: val1 = (val1 * 10) + ch;
933: d = d * 10;
934: }
935: }
936: else
937: if ((ch == '.') || (ch == '/'))
938: {
939: if (sep_flag == FLAG_OFF)
940: {
941: d = 1;
942: sep_char = ch;
943: sep_flag = FLAG_ON;
944: }
945: else
946: {
947: (void)sprintf(msg,
948: "--ipfe: Scale factor cannot have BOTH a '.' AND a '/' in (%s)\n",
949: argv[arg]);
950: pip_error(msg);
951: err_flag = FLAG_ON;
952: break; /* exit loop */
953: }
954: }
955: else
956: {
957: if ((ch == ':') && (opt < opt_len))
958: ch = argv[arg][opt++];
959: break; /* exit loop */
960: }
961: ++ch_ctr;
962: }
963: /* end while (opt < opt_len) */
964:
965: if (d == 0)
966: d = 1;
967: else
968: if (sep_char == '/')
969: d = val1;
970: else
971: val = (val * d) + val1;
972:
973: if ((val != 0) && (err_flag == FLAG_OFF))
974: {
975: if (neg_flag == FLAG_ON)
976: val = -(val);
977:
978: if (d != 0) /* last chk for div
979: by 0 just in case
980: of ovflw */
981: {
982: scale_num = val;
983: scale_den = d;
984: proc_flag[SCALE] = FLAG_ON;
985: }
986: }
987: else
988: {
989: (void)sprintf(msg,
990: "--ipfe: No scale factor value specified in (%s)\n",
991: argv[arg]);
992: pip_error(msg);
993: err_flag = FLAG_ON;
994: }
995: --opt; /* to parse cur ch at cmd line */
996: break;
997:
998: case ('X'):
999: if (strlen(&(argv[arg][opt])) > 1)
1000: ++opt;
1001: else
1002: {
1003: ++arg;
1004: opt = 0;
1005: opt_len = strlen(argv[arg]);
1006: }
1007: /*
1008: * xOffset:unit
1009: */
1010: val = val1 = d = ch_ctr = 0;
1011: neg_flag = FLAG_OFF;
1012: while
1013: (opt < opt_len)
1014: {
1015: ch = argv[arg][opt++];
1016: if ((ch == '-') && (ch_ctr == 0))
1017: neg_flag = FLAG_ON;
1018: else
1019: if ((ch >= '0') && (ch <= '9'))
1020: {
1021: ch = ch - '0';
1022: if (d == 0)
1023: val = (val * 10) + ch;
1024: else
1025: if (d <= 1000) /* prec = 10**(-3)
1026: truncated */
1027: {
1028: val1 = (val1 * 10) + ch;
1029: d = d * 10;
1030: }
1031: }
1032: else
1033: if (ch == '.')
1034: {
1035: d = 1;
1036: val1 = 0;
1037: }
1038: else
1039: {
1040: if ((ch == ':') && (opt < opt_len))
1041: ch = argv[arg][opt++];
1042: break; /* exit loop */
1043: }
1044: ++ch_ctr;
1045: }
1046: /* end while (opt < opt_len) */
1047:
1048: if (d == 0)
1049: d = 1;
1050: else
1051: val = (val * d) + val1;
1052:
1053: if (val != 0)
1054: {
1055: if (neg_flag == FLAG_ON)
1056: val = -(val);
1057: switch
1058: (ch)
1059: {
1060: case ('c'):
1061: d = d * 100;
1062: break;
1063: case ('i'):
1064: val = val * 254;
1065: d = d * 10000;
1066: break;
1067: case ('p'):
1068: val = val * 254;
1069: d = ((d * 720000) & 0x7fffffff);
1070: break;
1071: case ('P'):
1072: val = val * 254;
1073: d = ((d * 60000) & 0x7fffffff);
1074: break;
1075: default:
1076: d = d * 100; /* def=cm */
1077: break;
1078: }
1079: /* end switch (ch) */
1080:
1081: if (d != 0) /* last chk for div
1082: by 0 just in case
1083: of ovflw */
1084: {
1085: xoff_num = val;
1086: xoff_den = d;
1087: proc_flag[X_OFFSET] = FLAG_ON;
1088: }
1089: }
1090: else
1091: {
1092: (void)sprintf(msg,
1093: "--ipfe: No xOffset value specified in (%s)\n",
1094: argv[arg]);
1095: pip_error(msg);
1096: err_flag = FLAG_ON;
1097: }
1098: --opt; /* to parse cur ch at cmd line */
1099: break;
1100:
1101: case ('Y'):
1102: if (strlen(&(argv[arg][opt])) > 1)
1103: ++opt;
1104: else
1105: {
1106: ++arg;
1107: opt = 0;
1108: opt_len = strlen(argv[arg]);
1109: }
1110: /*
1111: * yOffset:unit
1112: */
1113: val = val1 = d = ch_ctr = 0;
1114: neg_flag = FLAG_OFF;
1115: while
1116: (opt < opt_len)
1117: {
1118: ch = argv[arg][opt++];
1119: if ((ch == '-') && (ch_ctr == 0))
1120: neg_flag = FLAG_ON;
1121: else
1122: if ((ch >= '0') && (ch <= '9'))
1123: {
1124: ch = ch - '0';
1125: if (d == 0)
1126: val = (val * 10) + ch;
1127: else
1128: if (d <= 1000) /* prec = 10**(-3)
1129: truncated */
1130: {
1131: val1 = (val1 * 10) + ch;
1132: d = d * 10;
1133: }
1134: }
1135: else
1136: if (ch == '.')
1137: {
1138: d = 1;
1139: val1 = 0;
1140: }
1141: else
1142: {
1143: if ((ch == ':') && (opt < opt_len))
1144: ch = argv[arg][opt++];
1145: break; /* exit loop */
1146: }
1147: ++ch_ctr;
1148: }
1149: /* end while (opt < opt_len) */
1150:
1151: if (d == 0)
1152: d = 1;
1153: else
1154: val = (val * d) + val1;
1155:
1156: if (val != 0)
1157: {
1158: if (neg_flag == FLAG_ON)
1159: val = -(val);
1160: switch
1161: (ch)
1162: {
1163: case ('c'):
1164: d = d * 100;
1165: break;
1166: case ('i'):
1167: val = val * 254;
1168: d = d * 10000;
1169: break;
1170: case ('p'):
1171: val = val * 254;
1172: d = ((d * 720000) & 0x7fffffff);
1173: break;
1174: case ('P'):
1175: val = val * 254;
1176: d = ((d * 60000) & 0x7fffffff);
1177: break;
1178: default:
1179: d = d * 100; /* def=cm */
1180: break;
1181: }
1182: /* end switch (ch) */
1183:
1184: if (d != 0) /* last chk for div
1185: by 0 just in case
1186: of ovflw */
1187: {
1188: yoff_num = val;
1189: yoff_den = d;
1190: proc_flag[Y_OFFSET] = FLAG_ON;
1191: }
1192: }
1193: else
1194: {
1195: (void)sprintf(msg,
1196: "--ipfe: No yOffset value specified in (%s)\n",
1197: argv[arg]);
1198: pip_error(msg);
1199: err_flag = FLAG_ON;
1200: }
1201: --opt; /* to parse cur ch at cmd line */
1202: break;
1203:
1204: default:
1205: (void)sprintf(msg,
1206: "--ipfe: Invalid option in %s (%s)\n",
1207: argv[arg], &(argv[arg][opt]));
1208: pip_error(msg);
1209: err_flag = FLAG_ON;
1210: break;
1211: }
1212: }
1213: break;
1214:
1215: case ('['):
1216: break;
1217:
1218: case ('>'):
1219: break;
1220:
1221: default:
1222: /*
1223: * the current arg is an input file; try to open it
1224: */
1225: if (input_indx < MX_NO_INFILES)
1226: {
1227: _fmode = BINARY_FILE;
1228: workfile = fopen(argv[arg], "r");
1229: if (workfile == NULL)
1230: {
1231: (void)sprintf(msg,
1232: "--ipfe: Error opening input file: %s\n",
1233: argv[arg]);
1234: pip_error(msg);
1235: err_flag = FLAG_ON;
1236: }
1237: else
1238: {
1239: /*
1240: * check for valid hdr
1241: */
1242: retcd = get_ip_hdr(workfile, argv[arg]);
1243: if (retcd == OK)
1244: {
1245: (void)strcpy(input_name[input_indx],
1246: argv[arg]);
1247: /*
1248: * check for page range
1249: */
1250: if (((arg + 1) < argc) &&
1251: ((argv[arg+1][0] == '[') ||
1252: (argv[arg+1][0] == '+') ||
1253: (argv[arg+1][0] == '#')))
1254: {
1255: ++arg;
1256: get_pagerange(arg, argv);
1257: }
1258: else
1259: merge_pg[input_indx][0] = (-1);
1260: infile_flag[input_indx] = FLAG_ON;
1261: ++input_indx;
1262: ++num_infiles;
1263: }
1264: else
1265: err_flag = FLAG_ON;
1266: (void)fclose(workfile);
1267: }
1268: }
1269: else
1270: {
1271: (void)sprintf(msg,
1272: "--ipfe: Maximum # of input files = %d; File: %s not processed\n",
1273: MX_NO_INFILES, argv[arg]);
1274: pip_error(msg);
1275: err_flag = FLAG_ON;
1276: }
1277: break;
1278: }
1279: /* end switch (argv[arg][0]) */
1280: }
1281: /* end for (arg=1; arg < argc; arg++) */
1282: if (err_flag == FLAG_ON)
1283: pip_error("\n");
1284:
1285: }
1286:
1287:
1288: /****************************************************************
1289: *
1290: * int get_ip_hdr(file, filename):
1291: * int get_ip_hdr: get the ip_hdr from the specified
1292: * file into a work_buf & return a
1293: * ptr to the buf
1294: *
1295: ****************************************************************/
1296:
1297: int get_ip_hdr(file, filename)
1298:
1299: FILE *file;
1300: char *filename;
1301: {
1302: int i, retcd, hdr_flag;
1303: int c; /* must be int for stdio EOF compare */
1304: char *ptr, msg[128];
1305:
1306:
1307: retcd = OK;
1308: /*
1309: * get the header
1310: */
1311: ptr = hdr_workbuf;
1312: hdr_flag = FLAG_OFF;
1313: for (i=0; i < MX_HDR_BUFLEN; i++)
1314: {
1315: c = getc_testeof(file, filename); /* get a char, */
1316: *ptr++ = c; /* & stick it in the buffer */
1317: if (c == ' ') /* if c=ip_hdr_terminate_char, */
1318: {
1319: hdr_flag = FLAG_ON; /* set hdr_ok flag, */
1320: break; /* & exit the loop */
1321: }
1322: }
1323: *ptr = '\0';
1324: /*
1325: * ... & check its validity
1326: */
1327: if (hdr_flag == FLAG_OFF)
1328: {
1329: (void)sprintf(msg, "--ipfe: Hdr length > %d chars in file: %s\n",
1330: MX_HDR_BUFLEN, filename);
1331: pip_error(msg);
1332: retcd = ERROR;
1333: }
1334: if (mstrncmp(hdr_workbuf, IP_Header, IP_HDR_CHKLEN) != 0)
1335: {
1336: (void)sprintf(msg, "--ipfe: INVALID HEADER! in file: %s\n",
1337: filename);
1338: pip_error(msg);
1339: retcd = ERROR;
1340: }
1341:
1342: return(retcd);
1343: }
1344:
1345:
1346: /****************************************************************
1347: *
1348: * get_pagerange(arg, argv):
1349: * get_pagerange: get cmd_line page range argument
1350: * for current input_indx from
1351: * specified argument
1352: *
1353: ****************************************************************/
1354:
1355: get_pagerange(arg, argv)
1356:
1357: int arg;
1358: char *argv[];
1359: {
1360: int i, opt, opt_len, d, val, val1, lp_ctr, ch_ctr,
1361: prv_mpg_num, err_flag, neg_flag;
1362: char ch, nc;
1363: char msg[128], name_buf[128];
1364:
1365:
1366: merge_indx = val = 0;
1367: prv_mpg_num = 0;
1368: opt_len = strlen(argv[arg]);
1369: err_flag = FLAG_OFF;
1370: for (opt=1; ((opt < opt_len) && (err_flag == FLAG_OFF)); opt++)
1371: {
1372: switch
1373: (argv[arg][opt])
1374: {
1375: case ('-'):
1376: merge_pg[input_indx][merge_indx] = (-1);
1377: ++merge_indx;
1378: break;
1379: /*
1380: * all of the following can just be ignored at this level
1381: */
1382: case (','):
1383: case (']'):
1384: case (')'):
1385: case (SPC):
1386: case ('\n'):
1387: break;
1388:
1389: case ('['):
1390: case ('+'):
1391: /*
1392: * overlay filename
1393: */
1394: if (strlen(&(argv[arg][opt])) > 1)
1395: {
1396: ch = '\0';
1397: i = 0;
1398: ++opt;
1399: while
1400: (opt < opt_len)
1401: {
1402: ch = argv[arg][opt];
1403: if ((ch == ':') || (ch == '(') || (ch == '@') ||
1404: (ch == '+'))
1405: {
1406: --opt; /* reparse opt at switch level */
1407: break;
1408: }
1409: else
1410: if ((ch == ']') || (ch == ','))
1411: break; /* don't bother reparsing */
1412: else
1413: {
1414: name_buf[i++] = ch;
1415: ++opt;
1416: }
1417: }
1418: name_buf[i] = '\0';
1419: if (i > 0)
1420: {
1421: if (merge_indx == 0)
1422: {
1423: merge_pg[input_indx][0] = 1;
1424: ++merge_indx;
1425: }
1426: if (merge_pg[input_indx][(merge_indx-1)] > 0)
1427: {
1428: if (ovly_pg[input_indx][(merge_indx-1)] !=
1429: (-1))
1430: {
1431: merge_pg[input_indx][merge_indx] =
1432: merge_pg[input_indx][(merge_indx-1)];
1433: ++merge_indx;
1434: }
1435: ovly_pg[input_indx][(merge_indx-1)] =
1436: ovly_indx;
1437: (void)strcpy(ovly_fname[ovly_indx], name_buf);
1438: ++ovly_indx;
1439: }
1440: else
1441: err_flag = FLAG_ON;
1442: }
1443: else
1444: err_flag = FLAG_ON;
1445: }
1446: else
1447: err_flag = FLAG_ON;
1448: break;
1449:
1450: case (':'):
1451: /*
1452: * overlay pagenum
1453: */
1454: if ((ovly_indx == 0) ||
1455: (ovly_pg[input_indx][merge_indx-1] == (-1)) ||
1456: (ovly_pgnum[ovly_indx-1] != 0))
1457: err_flag = FLAG_ON;
1458: else
1459: if (strlen(&(argv[arg][opt])) > 1)
1460: {
1461: val = 0;
1462: ++opt;
1463: while
1464: (opt < opt_len)
1465: {
1466: ch = argv[arg][opt];
1467: if ((ch >= '0') && (ch <= '9'))
1468: {
1469: ch = ch - '0';
1470: val = (val * 10) + ch;
1471: ++opt;
1472: }
1473: else
1474: {
1475: --opt; /* reparse everything else at the
1476: switch level */
1477: break;
1478: }
1479: }
1480: /*
1481: * if the pagenum is good, process it
1482: */
1483: if (val > 0)
1484: ovly_pgnum[ovly_indx-1] = val;
1485: }
1486: else
1487: err_flag = FLAG_ON;
1488: break;
1489:
1490: case ('('):
1491: case ('@'):
1492: /*
1493: * overlay page offset
1494: */
1495: if ((ovly_indx == 0) ||
1496: (ovly_pg[input_indx][merge_indx-1] == (-1)))
1497: err_flag = FLAG_ON;
1498: else
1499: if (strlen(&(argv[arg][opt])) > 1)
1500: {
1501: val = val1 = d = lp_ctr = ch_ctr = 0;
1502: neg_flag = FLAG_OFF;
1503: ++opt;
1504: while
1505: ((opt < opt_len) && (lp_ctr < 2))
1506: {
1507: ch = argv[arg][opt++];
1508: if ((ch == '-') && (ch_ctr == 0))
1509: neg_flag = FLAG_ON;
1510: else
1511: if ((ch >= '0') && (ch <= '9'))
1512: {
1513: ch = ch - '0';
1514: if (d == 0)
1515: val = (val * 10) + ch;
1516: else
1517: if (d <= 1000) /* precision = 10**(-3)
1518: truncated */
1519: {
1520: val1 = (val1 * 10) + ch;
1521: d = d * 10;
1522: }
1523: }
1524: else
1525: if (ch == '.')
1526: {
1527: d = 1;
1528: val1 = 0;
1529: }
1530: else
1531: {
1532: if (d != 0)
1533: val = (val * d) + val1;
1534: else
1535: d = 1;
1536: if (val != 0)
1537: {
1538: if (neg_flag == FLAG_ON)
1539: val = -(val);
1540: switch
1541: (ch)
1542: {
1543: case ('c'):
1544: d = d * 100;
1545: break;
1546: case ('i'):
1547: val = val * 254;
1548: d = d * 10000;
1549: break;
1550: case ('p'):
1551: val = val * 254;
1552: d = ((d * 720000) & 0x7fffffff);
1553: break;
1554: case ('P'):
1555: val = val * 254;
1556: d = ((d * 60000) & 0x7fffffff);
1557: break;
1558: default:
1559: d = d * 100; /* assume cm */
1560: break;
1561: }
1562: if (d != 0) /* last chk for div by 0
1563: just in case of ovflw */
1564: {
1565: ovly_num[lp_ctr][ovly_indx-1] = val;
1566: ovly_den[lp_ctr][ovly_indx-1] = d;
1567: }
1568: if (lp_ctr == 0)
1569: {
1570: nc = argv[arg][opt];
1571: if (((nc < '0') && (nc != '-')) ||
1572: (nc > '9'))
1573: ++opt; /* assume only 1 separator
1574: after scale char */
1575: }
1576: }
1577: val = d = 0;
1578: neg_flag = FLAG_OFF;
1579: ++lp_ctr;
1580: ch_ctr = (-1);
1581: if ((lp_ctr == 2) &&
1582: ((ch == '+') || (ch == '[') ||
1583: (ch == '-')))
1584: --opt; /* reparse at switch level */
1585: }
1586: ++ch_ctr;
1587: }
1588: --opt; /* to undo the automatic incr above */
1589: }
1590: else
1591: err_flag = FLAG_ON;
1592: break;
1593:
1594: default:
1595: /*
1596: * current opt should be a pageNum
1597: */
1598: val = 0;
1599: while
1600: (opt < opt_len)
1601: {
1602: ch = argv[arg][opt];
1603: if ((ch >= '0') && (ch <= '9'))
1604: {
1605: ch = ch - '0';
1606: val = (val * 10) + ch;
1607: ++opt;
1608: }
1609: else
1610: if ((ch == '-') || (ch == ',') || (ch == '[') ||
1611: (ch == ']') || (ch == '+'))
1612: {
1613: --opt; /* reparse opt at switch level */
1614: break;
1615: }
1616: else
1617: if ((ch == SPC) || (ch == '\n'))
1618: break; /* don't bother to reparse */
1619: else
1620: {
1621: err_flag = FLAG_ON;
1622: break;
1623: }
1624: }
1625: /*
1626: * if the val is good, process it
1627: */
1628: if (val > prv_mpg_num)
1629: {
1630: merge_pg[input_indx][merge_indx] = val;
1631: prv_mpg_num = val;
1632: ++merge_indx;
1633: }
1634: else
1635: err_flag = FLAG_ON;
1636: break;
1637: }
1638: /* end of switch (argv[arg][opt]) */
1639:
1640: if (err_flag == FLAG_ON)
1641: {
1642: (void)sprintf(msg,
1643: "--ipfe: Invalid pagerange specification in %s (%s)\n",
1644: argv[arg], &(argv[arg][opt]));
1645: pip_error(msg);
1646: exit_status = 5;
1647: }
1648: }
1649: /* end of for (opt=1; ((opt < opt_len) && (err_flag == FLAG_OFF));
1650: ++ opt) */
1651:
1652: }
1653:
1654:
1655: /****************************************************************
1656: *
1657: * int getc_testeof(file, filename):
1658: * int getc_testeof: get a char from input file;
1659: * if we get an EOF here,
1660: * it's an error;
1661: * else,
1662: * return the char as an int
1663: *
1664: ****************************************************************/
1665:
1666: int getc_testeof(file, filename)
1667:
1668: FILE *file;
1669: char *filename;
1670: {
1671: int val;
1672: char msg[128];
1673:
1674:
1675: val = mgetc(file);
1676: if (feof(file))
1677: {
1678: (void)sprintf(msg, "\nUnexpected EOF! in file: %s\n", filename);
1679: pip_error(msg);
1680: longjmp(next_file, 1);
1681: }
1682:
1683: return(val);
1684: }
1685:
1686:
1687: /****************************************************************
1688: *
1689: * indent(cnt, file):
1690: * indent: put <cnt> spcs to specified file
1691: *
1692: ****************************************************************/
1693:
1694: indent(cnt, file)
1695:
1696: FILE *file;
1697: int cnt;
1698: {
1699: if (file != NULL)
1700: {
1701: if ((file == propfile) && (cnt > 0))
1702: cur_col = cur_col + cnt;
1703:
1704: while
1705: (cnt-- > 0)
1706: {
1707: putc(' ', file);
1708: }
1709: }
1710: }
1711:
1712:
1713: /****************************************************************
1714: *
1715: * init:
1716: * init_ipfe: initialization
1717: *
1718: ****************************************************************/
1719:
1720: init_ipfe()
1721: {
1722: int i, j;
1723:
1724:
1725: abort_flag = debug_flag = FLAG_OFF;
1726: exit_status = 0;
1727: ovly_flag = FLAG_OFF;
1728: frstpg_flag = FLAG_OFF;
1729: num_infiles = out_filnum = 0;
1730: input_indx = output_indx = sif_indx = 0;
1731: num_aliases = 0;
1732: alias_indx = 0;
1733: prop_level = 0;
1734: hdr_len = 0;
1735: pos = in_offset = 0;
1736: block_indx = 0;
1737: block_flag = FLAG_OFF;
1738: out_beg_offset[block_indx] = 0;
1739: tnum_blocks = tnum_pages = tnum_sifs = 0;
1740: for (i=0; i < NUM_FNS; i++)
1741: proc_flag[i] = FLAG_OFF;
1742: chap_type = chap_val = 0;
1743: ipwrite_flag = FLAG_ON;
1744: merge_indx = ovly_indx = 0;
1745:
1746: for (i=0; i < MX_NO_INFILES; i++)
1747: {
1748: merge_pg[i][0] = (-1); /* init to all pages */
1749: ovly_pg[i][0] = (-1); /* init to no overlay */
1750: for (j=1; j < MX_NO_MPG_ENTRIES; j++)
1751: {
1752: merge_pg[i][j] = 0;
1753: ovly_pg[i][j] = (-1);
1754: }
1755: }
1756:
1757: for (i=0; i < MX_BLOCK_DEPTH; i++)
1758: blk_num_bytes[i] = 0;
1759: pg_num_bytes = 0;
1760:
1761: for (i=0; i < MX_NO_INFILES; i++)
1762: infile_flag[i] = 0;
1763:
1764: outputname = propfname = 0;
1765:
1766: /*
1767: * make the beginBlock & endBlock names upper case
1768: */
1769: op_names[OP_beginBlock] = "BEGIN";
1770: op_names[OP_endBlock] = "END";
1771:
1772: }
1773:
1774:
1775: /****************************************************************
1776: *
1777: * init_proc_file: initialize proc_file() loop
1778: *
1779: ****************************************************************/
1780:
1781: init_proc_file()
1782: {
1783:
1784: sif_indx = 0;
1785: cur_indent = cur_col = 0;
1786: in_offset = 0;
1787: num_blocks = num_pages = num_sifs = 0;
1788: preamble_expected = FLAG_OFF;
1789: merge_indx = 0;
1790: bproc_indx = bop_indx = 0;
1791: bproc_flag = bop_flag = FLAG_OFF;
1792: ipwrite_flag = FLAG_ON;
1793:
1794: }
1795:
1796:
1797: /****************************************************************
1798: *
1799: * init1:
1800: * init1_ipfe: initialization after getting cmd args
1801: *
1802: ****************************************************************/
1803:
1804: init1_ipfe()
1805:
1806: {
1807: int i, tval, procflag, exit_flag;
1808: char msg[128];
1809:
1810:
1811: if (num_infiles == 0) /* input_name req'd for now */
1812: Usage();
1813: else
1814: {
1815: /*
1816: * split the 1st input_name into input_fnm & input_ext
1817: */
1818: i = mrstrichr(input_name[0], '.');
1819: if (i != (-1))
1820: {
1821: (void)mstrncpy(input_fnm, input_name[0], i);
1822: (void)strcpy(input_ext, (input_name[0] + i));
1823: }
1824: else
1825: (void)strcpy(input_fnm, input_name[0]);
1826: /*
1827: * Open properties file
1828: */
1829: if (proc_flag[PROPERTIES] == FLAG_ON)
1830: open_propfile();
1831: /*
1832: * Tell about rotate, xOffset, yOffset, binding offset, duplex, and scale
1833: */
1834: if ((proc_flag[LANDSCAPE] == FLAG_ON) ||
1835: (proc_flag[ROTATE] == FLAG_ON))
1836: {
1837: (void)sprintf(msg, "--ipfe: Rotate %d degrees\n",
1838: rot_deg);
1839: pip_error(msg);
1840: }
1841: if (proc_flag[X_OFFSET] == FLAG_ON)
1842: {
1843: (void)sprintf(msg, "--ipfe: xOffset = %ld/%ld meters\n",
1844: xoff_num, xoff_den);
1845: pip_error(msg);
1846: }
1847: if (proc_flag[Y_OFFSET] == FLAG_ON)
1848: {
1849: (void)sprintf(msg, "--ipfe: yOffset = %ld/%ld meters\n",
1850: yoff_num, yoff_den);
1851: pip_error(msg);
1852: }
1853: if (proc_flag[BINDING_OFFSET] == FLAG_ON)
1854: {
1855: (void)sprintf(msg,
1856: "--ipfe: Binding offset = %ld/%ld meters\n",
1857: boff_num, boff_den);
1858: pip_error(msg);
1859: if (proc_flag[DUPLEX] == FLAG_ON)
1860: pip_error("--ipfe: Duplex processing set\n");
1861: }
1862: if (proc_flag[SCALE] == FLAG_ON)
1863: {
1864: (void)sprintf(msg, "--ipfe: Scale = %ld/%ld\n",
1865: scale_num, scale_den);
1866: pip_error(msg);
1867: }
1868: /*
1869: * Tell about chapterizing
1870: */
1871: if (proc_flag[CHAPTERIZE] == FLAG_ON)
1872: {
1873: (void)sprintf(msg, "--ipfe: Chapterize every %d ", chap_val);
1874: pip_error(msg);
1875: switch
1876: (chap_type)
1877: {
1878: case (CH_PAGES):
1879: pip_error("pages");
1880: break;
1881: case (CH_KBYTES):
1882: (void)sprintf(msg, "bytes (%d kbytes)",
1883: (chap_val / 1024));
1884: pip_error(msg);
1885: break;
1886: case (CH_MBYTES):
1887: (void)sprintf(msg, "bytes (%d mbytes)",
1888: (chap_val / 1048576));
1889: pip_error(msg);
1890: break;
1891: }
1892: pip_error("\n");
1893: }
1894: /*
1895: * Show any aliases
1896: */
1897: for (i=0; i < num_aliases; i++)
1898: {
1899: if (i == 0)
1900: pip_error("--ipfe: ");
1901: else
1902: pip_error("-- ");
1903: (void)sprintf(msg, "Alias: %s=%s\n",
1904: alias_ref[i], alias_act[i]);
1905: pip_error(msg);
1906: }
1907:
1908: if (num_infiles > 1)
1909: proc_flag[CONCAT] = FLAG_ON;
1910:
1911: if (proc_flag[DEBUG] == FLAG_ON)
1912: off_indent = 10;
1913: else
1914: off_indent = 0;
1915:
1916: /*
1917: * For now, IF the properties option flag is SET AND there is no output
1918: * file specified,
1919: * THEN set the environment for properties only (don't open output)
1920: */
1921: if ((proc_flag[PROPERTIES] == FLAG_ON) &&
1922: (outputname == 0))
1923: ; /* process properties only; no output */
1924: else
1925: {
1926: /*
1927: * open the output file
1928: */
1929: if (outputname == 0)
1930: {
1931: /*
1932: * construct a default output filename by concatenating ".ip" to the
1933: * fnm component of the 1st input filename, making sure the resulting
1934: * filename doesn't already exist; if it does exist, append "1" to
1935: * the fnm, then "2" to the fnm, etc. until the filename doesn't exist
1936: */
1937: tval = 0;
1938: exit_flag = procflag = FLAG_OFF;
1939: while
1940: (exit_flag == FLAG_OFF)
1941: {
1942: (void)strcpy(work_fname, input_fnm);
1943: if (procflag == FLAG_ON)
1944: (void)strcat(work_fname, itostr(tval));
1945: (void)strcat(work_fname, ".ip");
1946: _fmode = BINARY_FILE;
1947: workfile = fopen(work_fname, "r");
1948: if (workfile == NULL)
1949: {
1950: outputname = work_fname;
1951: exit_flag = FLAG_ON;
1952: }
1953: else
1954: {
1955: (void)fclose(workfile);
1956: ++tval;
1957: procflag = FLAG_ON;
1958: }
1959: }
1960: }
1961:
1962: (void)strcpy(output_name, outputname);
1963: outputname = output_name;
1964: i = mrstrichr(outputname, '.');
1965: if (i != (-1))
1966: {
1967: (void)mstrncpy(output_fnm, outputname, i);
1968: (void)strcpy(output_ext, (outputname + i));
1969: }
1970: else
1971: (void)strcpy(output_fnm, outputname);
1972:
1973: if (proc_flag[CHAPTERIZE] == FLAG_ON)
1974: {
1975: (void)strcpy(output_name, output_fnm);
1976: out_filnum = 1;
1977: (void)strcat(output_name, itostr(out_filnum));
1978: (void)strcat(output_name, output_ext);
1979: }
1980:
1981: open_output();
1982: }
1983: }
1984:
1985: }
1986:
1987:
1988: /****************************************************************
1989: *
1990: * iocopyn(length, file, filename):
1991: * iocopyn: copy <length> bytes from specified
1992: * file to output, checking for
1993: * unexpected EOF
1994: *
1995: ****************************************************************/
1996:
1997: iocopyn(length, file, filename)
1998:
1999: FILE *file;
2000: long length;
2001: char *filename;
2002: {
2003:
2004: while
2005: (length-- > 0)
2006: {
2007: ip_putc(getc_testeof(file, filename));
2008: }
2009: }
2010:
2011:
2012: /****************************************************************
2013: *
2014: * iogetn(length, file, filename, buf):
2015: * iogetn: read <length> bytes from specified
2016: * file into specified buf, checking
2017: * for unexpected EOF
2018: * -- throw the bytes away, for now
2019: *
2020: ****************************************************************/
2021:
2022: iogetn(length, file, filename, buf)
2023:
2024: FILE *file;
2025: long length;
2026: char *filename, *buf;
2027: {
2028: while
2029: (length-- > 0)
2030: {
2031: *buf++ = getc_testeof(file, filename);
2032: }
2033: *buf = '\0';
2034: }
2035:
2036:
2037: /****************************************************************
2038: *
2039: * ioputn(length, buf):
2040: * ioputn: put <length> bytes from specified
2041: * buf to output
2042: *
2043: ****************************************************************/
2044:
2045: ioputn(length, buf)
2046:
2047: long length;
2048: char *buf;
2049: {
2050: while
2051: (length-- > 0)
2052: {
2053: ip_putc(*buf++);
2054: }
2055: }
2056:
2057:
2058: /****************************************************************
2059: *
2060: * ioreadn(length, file, filename):
2061: * ioreadn: read <length> bytes from specified
2062: * file, checking for unexpected EOF
2063: * -- throw the bytes away, for now
2064: *
2065: ****************************************************************/
2066:
2067: ioreadn(length, file, filename)
2068:
2069: FILE *file;
2070: long length;
2071: char *filename;
2072: {
2073:
2074: while
2075: (length-- > 0)
2076: {
2077: (void)getc_testeof(file, filename); /* throw it away */
2078: }
2079: }
2080:
2081:
2082: /****************************************************************
2083: *
2084: * ip_putc(ch):
2085: * ip_putc: put char to (interpress) output &
2086: * bump out_offset
2087: *
2088: ****************************************************************/
2089:
2090: ip_putc(ch)
2091:
2092: char ch;
2093: {
2094: if ((output != NULL) && (ipwrite_flag == FLAG_ON))
2095: {
2096: putc(ch, output);
2097: ++out_offset;
2098: }
2099: }
2100:
2101:
2102:
2103: /****************************************************************
2104: *
2105: * ip_puts(string):
2106: * ip_puts: put string to (interpress) output
2107: * & add strlen(string) to out_offset
2108: *
2109: ****************************************************************/
2110:
2111: ip_puts(string)
2112:
2113: char *string;
2114: {
2115: if ((output != NULL) && (ipwrite_flag == FLAG_ON))
2116: {
2117: fprintf(output, string);
2118: out_offset = out_offset + strlen(string);
2119: }
2120:
2121: }
2122:
2123:
2124: /****************************************************************
2125: *
2126: * char *itostr(ival):
2127: * char *itostr: cvt int to ascii string; return ptr
2128: *
2129: ****************************************************************/
2130:
2131: char *itostr(ival)
2132:
2133: int ival;
2134: {
2135: int i, digit, digit_flag;
2136: char num_buf[17], *s;
2137:
2138:
2139: s = num_buf;
2140: digit_flag = FLAG_OFF;
2141: for (i=10000; i > 0; i=i/10)
2142: {
2143: digit = ival / i;
2144: if ((digit == 0) && (digit_flag == FLAG_OFF) && (i > 1))
2145: ; /* do nothing */
2146: else
2147: {
2148: *s = digit + '0';
2149: ++s;
2150: ival = ival - (digit * i);
2151: digit_flag = FLAG_ON;
2152: }
2153: }
2154: *s = '\0';
2155:
2156: return(num_buf);
2157: }
2158:
2159:
2160: /****************************************************************
2161: *
2162: * mgetc(file):
2163: * mgetc: get char from input & bump
2164: * appropriate counters
2165: *
2166: ****************************************************************/
2167:
2168: int mgetc(file)
2169:
2170: FILE *file;
2171: {
2172: int val;
2173:
2174:
2175: val = getc(file);
2176: if (!(feof(file)))
2177: {
2178: val = val & 0xff;
2179: ++in_offset;
2180: ++blk_num_bytes[block_indx];
2181: ++pg_num_bytes;
2182: }
2183:
2184: return(val);
2185: }
2186:
2187:
2188: /****************************************************************
2189: *
2190: * mputc_prop(ch):
2191: * mputc_prop: put char to propfile
2192: *
2193: ****************************************************************/
2194:
2195: mputc_prop(ch)
2196: {
2197: if ((propfile != NULL) && (ovly_flag == FLAG_OFF))
2198: {
2199: putc(ch, propfile);
2200: if (ch == '\n')
2201: cur_col = 0;
2202: }
2203:
2204: }
2205:
2206: /****************************************************************
2207: *
2208: * int mrstrichr(str, ch):
2209: * int mrstrichr: reverse srch for char in string;
2210: * if fnd,
2211: * return its pos (indexed from 0);
2212: * else
2213: * return (-1)
2214: *
2215: ****************************************************************/
2216:
2217: int mrstrichr(str, ch)
2218:
2219: char *str, ch;
2220: {
2221: int i, indx, retcd;
2222:
2223:
2224: retcd = (-1);
2225: indx = strlen(str) - 1;
2226: str = str + indx;
2227: for (i=indx; i >= 0; i--, str--)
2228: {
2229: if (*str == ch)
2230: {
2231: retcd = i;
2232: break;
2233: }
2234: }
2235:
2236: return(retcd);
2237: }
2238:
2239:
2240: /****************************************************************
2241: *
2242: * int mstrncmp(s1, s2, len):
2243: * int mstrncmp: cmp s1 to s2 for max of len bytes
2244: * (byte-wise compare, left to right);
2245: * if *s1 != *s2,
2246: * return (int)(*s1 - *s2)
2247: * (i.e., <0 if s1<s2, >0 if s1>s2)
2248: * else
2249: * return 0
2250: *
2251: ****************************************************************/
2252:
2253: int mstrncmp(s1, s2, len)
2254:
2255: int len;
2256: char *s1, *s2;
2257: {
2258: int i, retcd;
2259:
2260:
2261: retcd = 0;
2262: for (i=0; i < len; i++, s1++, s2++)
2263: {
2264: if (*s1 != *s2)
2265: {
2266: retcd = (int)(*s1 - *s2);
2267: break;
2268: }
2269: }
2270:
2271: return(retcd);
2272: }
2273:
2274:
2275: /****************************************************************
2276: *
2277: * int mstrncpy(to, from, len):
2278: * int mstrncpy: copy from -> to for len; return
2279: * actual # bytes copied (will be
2280: * < len if <from> is null-terminated
2281: * shorter than len);
2282: * guarantees not overwriting allocated
2283: * space for <to> if sizeof(to) is at
2284: * least len + 1 (i.e., if len =
2285: * sizeof(to) - 1;
2286: * destination <to> is always null-
2287: * terminated
2288: *
2289: ****************************************************************/
2290:
2291: int mstrncpy(to, from, len)
2292:
2293: int len;
2294: char *to, *from;
2295: {
2296: int cnt;
2297:
2298:
2299: cnt = 0;
2300: while
2301: ((len-- > 0) && (*from != '\0'))
2302: {
2303: *to++ = *from++;
2304: ++cnt;
2305: }
2306: *to = '\0';
2307:
2308: return(cnt);
2309: }
2310:
2311:
2312: /****************************************************************
2313: *
2314: * open_logfile(argc, argv):
2315: * open_logfile: open the logfile for processing
2316: *
2317: ****************************************************************/
2318:
2319: open_logfile(argc, argv)
2320:
2321: int argc;
2322: char *argv[];
2323: {
2324: int i;
2325:
2326:
2327: _fmode = TEXT_FILE;
2328: logfile = fopen(logfilename, "w");
2329: if (logfile == NULL)
2330: {
2331: fprintf(STDERR,
2332: "--ipfe: Can't open log file: %s\n", logfilename);
2333: *logfilename = '\0';
2334: }
2335: else
2336: {
2337: fprintf(STDERR, "--ipfe: Log file: %s is open\n", logfilename);
2338:
2339: fprintf(logfile, "\n");
2340: for (i=0; i < argc; i++)
2341: fprintf(logfile, "%s ", argv[i]);
2342: fprintf(logfile, "\n\n");
2343: }
2344:
2345: }
2346:
2347:
2348: /****************************************************************
2349: *
2350: * open_output: open the output for processing
2351: *
2352: ****************************************************************/
2353:
2354: open_output()
2355: {
2356: char msg[128];
2357:
2358:
2359: _fmode = BINARY_FILE;
2360: output = fopen(outputname, "w");
2361: if (output == NULL)
2362: {
2363: terrno = errno; /* save errno */
2364: (void)sprintf(msg,
2365: "--ipfe: Error opening output file: %s, retcd=%d\n",
2366: outputname, errno);
2367: pip_error(msg);
2368: errno = terrno;
2369: exit(2);
2370: }
2371:
2372: }
2373:
2374:
2375: /****************************************************************
2376: *
2377: * open_propfile: open the properties file for processing
2378: *
2379: ****************************************************************/
2380:
2381: open_propfile()
2382: {
2383: char msg[128];
2384:
2385:
2386: _fmode = TEXT_FILE;
2387: if (propfname == 0)
2388: {
2389: (void)strcpy(prop_fname, input_fnm);
2390: (void)strcat(prop_fname, ".prop");
2391: propfname = prop_fname;
2392:
2393: (void)sprintf(msg,
2394: "--ipfe: No properties filename specified. Using: %s\n",
2395: propfname);
2396: pip_error(msg);
2397: }
2398:
2399: propfile = fopen(propfname, "w");
2400: if (propfile == NULL)
2401: {
2402: (void)sprintf(msg,
2403: "--ipfe: Can't open properties file: %s\n", propfname);
2404: pip_error(msg);
2405: *propfname = '\0';
2406: }
2407: else
2408: {
2409: (void)sprintf(msg,
2410: "--ipfe: Properties file: %s is open\n", propfname);
2411: pip_error(msg);
2412: }
2413:
2414: }
2415:
2416:
2417: /****************************************************************
2418: *
2419: * char *op_name(op):
2420: * char *op_name: check op_names[] table of op_code
2421: * name strings for non-null entry;
2422: * if non_null,
2423: * return ptr to the string,
2424: * else,
2425: * return ptr to string
2426: * "--Unknown op: <op>"
2427: *
2428: ****************************************************************/
2429:
2430: char *op_name(op)
2431:
2432: int op;
2433: {
2434: char buf[20];
2435:
2436: if (op_names[op] == NULL)
2437: {
2438: (void)sprintf(buf, "--Unknown op: %d --", op);
2439: return(buf);
2440: }
2441: else
2442: return(op_names[op]);
2443: }
2444:
2445:
2446: /****************************************************************
2447: *
2448: * pip_error(msg):
2449: * pip_error: put error msg to stdout & logfile
2450: *
2451: ****************************************************************/
2452:
2453: pip_error(msg)
2454:
2455: char *msg;
2456: {
2457: if (proc_flag[QUIET] != FLAG_ON)
2458: fprintf(STDERR, msg);
2459: if (logfile != NULL)
2460: fprintf(logfile, msg);
2461: }
2462:
2463:
2464:
2465: /****************************************************************
2466: *
2467: * pip_prop(msg):
2468: * pip_prop: put msg to propfile
2469: *
2470: ****************************************************************/
2471:
2472: pip_prop(msg)
2473:
2474: char *msg;
2475: {
2476: if ((propfile != NULL) && (ovly_flag == FLAG_OFF))
2477: {
2478: fprintf(propfile, msg);
2479: if (*(msg + strlen(msg) - 1) == '\n')
2480: cur_col = 0;
2481: else
2482: cur_col = cur_col + strlen(msg);
2483:
2484: }
2485:
2486: }
2487:
2488:
2489: /****************************************************************
2490: *
2491: * preserve_SIF_copy(type_byte, length, file, filename):
2492: * preserve_SIF_copy: preserve SIF reference by copying
2493: * from specified input file to output
2494: *
2495: ****************************************************************/
2496:
2497: copy_preserve_SIF(type_byte, length, file, filename)
2498:
2499: FILE *file;
2500: long length;
2501: int type_byte;
2502: char *filename;
2503: {
2504: put_seq_type_len(type_byte, length);
2505: iocopyn(length, file, filename);
2506: }
2507:
2508:
2509:
2510: /****************************************************************
2511: *
2512: * preserve_SIF_put(type_byte, length, buf):
2513: * preserve_SIF_put: preserve SIF reference by copying
2514: * from specified buffer to output
2515: *
2516: ****************************************************************/
2517:
2518: put_preserve_SIF(type_byte, length, buf)
2519:
2520: long length;
2521: int type_byte;
2522: char *buf;
2523: {
2524: put_seq_type_len(type_byte, length);
2525: ioputn(length, buf);
2526: }
2527:
2528:
2529: /****************************************************************
2530: *
2531: * proc_alias(alias_string):
2532: * proc_alias: process alias argument
2533: *
2534: ****************************************************************/
2535:
2536: proc_alias(alias_string)
2537:
2538: char *alias_string;
2539: {
2540: int indx, len;
2541: char msg[128];
2542:
2543:
2544: len = strlen(alias_string);
2545: indx = mrstrichr(alias_string, ':');
2546: if ((indx > 0) && (indx < (len - 1))) /* past beg & before end */
2547: {
2548: (void)mstrncpy(alias_ref[alias_indx], alias_string, indx);
2549: ++indx;
2550: (void)mstrncpy(alias_act[alias_indx], (alias_string + indx),
2551: (len - indx));
2552: ++alias_indx;
2553: ++num_aliases;
2554: }
2555: else
2556: {
2557: (void)sprintf(msg,
2558: "--ipfe: *** warning -- invalid alias specification (%s)\n",
2559: alias_string);
2560: pip_error(msg);
2561: exit_status = 4;
2562: }
2563:
2564: }
2565:
2566:
2567: /****************************************************************
2568: *
2569: * proc_chapterize: test for & process chapterizing
2570: *
2571: ****************************************************************/
2572:
2573: proc_chapterize()
2574: {
2575: long len, temp_end_offset;
2576: int i, op, terrno, tblock_indx, proc_op_flag, eof_flag, proc_type;
2577: int type_byte; /* must be int for stdio EOF */
2578: char msg[128];
2579:
2580:
2581: if ((proc_flag[CHAPTERIZE] == FLAG_ON) &&
2582: (((chap_type == CH_PAGES) && (out_numpages == chap_val)) ||
2583: (((chap_type == CH_KBYTES) || (chap_type == CH_MBYTES)) &&
2584: (out_offset >= chap_val))))
2585: {
2586:
2587: /*
2588: * Eventually, the next two lines should be rewritten to check to see
2589: * if we might somehow be nested in a body before putting the
2590: * OP_endblock(s)
2591: */
2592:
2593: for (i=0; i < block_indx; i++)
2594: put_op(OP_endBlock);
2595:
2596: (void)fclose(output);
2597:
2598: /*
2599: * Now, check for OP_endBlock(s) appearing immediately in the input
2600: * file. If so, skip them: they were already put out above. In looking,
2601: * if we get an EOF and there are no more input files, don't open a
2602: * new output file.
2603: */
2604:
2605: proc_op_flag = eof_flag = FLAG_OFF;
2606: tblock_indx = block_indx; /* because the actual block_indx can
2607: be dcr'd in the loop */
2608: for (i=0; i <= tblock_indx; i++)
2609: {
2610: type_byte = mgetc(input);
2611: if (feof(input))
2612: {
2613: /*
2614: * set eof_flag only if there are no more input files
2615: */
2616: if (input_indx >= (num_infiles - 1))
2617: eof_flag = FLAG_ON;
2618: break;
2619: }
2620: else
2621: if ((type_byte & OP_Mask) == (LONG_OP & OP_Mask))
2622: {
2623: op = ((type_byte & 0x1f) << 8) +
2624: getc_testeof(input, inputname);
2625: if ((op == OP_endBlock) && (i < block_indx))
2626: --block_indx;
2627: else
2628: {
2629: proc_op_flag = FLAG_ON; /* set flag for use below */
2630: proc_type = LONG_OP;
2631: break;
2632: }
2633: }
2634: else
2635: {
2636: proc_op_flag = FLAG_ON; /* set flag for use below */
2637: proc_type = ~(LONG_OP);
2638: break;
2639: }
2640: }
2641: if (eof_flag == FLAG_OFF)
2642: {
2643: (void)strcpy(work_fname, outputname);
2644: workfile = fopen(work_fname, "r");
2645: if (workfile == NULL)
2646: {
2647: terrno = errno; /* save errno */
2648: pip_error(
2649: "Chapterize error opening previous output file as input\n");
2650: (void)sprintf(msg, " file=%s, retcd=%d\n",
2651: outputname, errno);
2652: pip_error(msg);
2653: pip_error(" Can't complete chapterization --\n\n");
2654: pip_error(" *** ABORTING ***\n");
2655: errno = terrno;
2656: exit(3);
2657: }
2658: else
2659: {
2660: ++out_filnum;
2661: (void)strcpy(output_name, output_fnm);
2662: (void)strcat(output_name, itostr(out_filnum));
2663: (void)strcat(output_name, output_ext);
2664: (void)sprintf(msg,
2665: "--ipfe: Processing output file: %s\n",
2666: outputname);
2667: pip_error(msg);
2668:
2669: _fmode = BINARY_FILE;
2670: output = fopen(outputname, "w");
2671: if (output == NULL)
2672: {
2673: terrno = errno; /* save errno */
2674: (void)sprintf(msg,
2675: "--ipfe: Error opening output file=%s, retcd=%d\n",
2676: outputname, errno);
2677: pip_error(msg);
2678: errno = terrno;
2679: exit(4);
2680: }
2681: else
2682: {
2683: /*
2684: * Then, copy Hdr & BEGIN/Preamble(s) to new output
2685: */
2686: out_numpages = 0;
2687: out_offset = 0;
2688: for (i=0; i <= block_indx; i++)
2689: {
2690: len = out_end_offset[i] - out_beg_offset[i] + 1;
2691: out_beg_offset[i] = out_offset;
2692: iocopyn(len, workfile, work_fname);
2693: temp_end_offset = out_end_offset[i];
2694: out_end_offset[i] = out_offset - 1;
2695: if (i < block_indx) /* if there is more to do */
2696: {
2697: len = out_beg_offset[i+1] -
2698: temp_end_offset - 1;
2699: ioreadn(len, workfile, work_fname);
2700: }
2701: }
2702: }
2703: (void)fclose(workfile);
2704: /*
2705: * Finally, if a token other than OP_endBlock token was read above,
2706: * process it
2707: */
2708: if (proc_op_flag == FLAG_ON)
2709: {
2710: if (proc_type == LONG_OP)
2711: proc_long_op(op);
2712: else
2713: proc_ip_token(type_byte, input, inputname);
2714: }
2715: }
2716: }
2717: }
2718:
2719: }
2720:
2721:
2722: /****************************************************************
2723: *
2724: * proc_file: process the input file
2725: *
2726: ****************************************************************/
2727:
2728: proc_file()
2729:
2730: {
2731: long offset;
2732: int i, op, retcd, exit_flag;
2733: int type_byte; /* must be int for stdio EOF */
2734: char msg[128];
2735:
2736:
2737: if (setjmp(next_file) != 0) /* for error recovery of */
2738: { /* unexpected EOF */
2739: return;
2740: }
2741:
2742:
2743: offset = in_offset;
2744: retcd = get_ip_hdr(input, inputname); /* get the hdr */
2745: if (retcd == OK)
2746: {
2747: (void)sprintf(msg, "-- Hdr : %s--\n", hdr_workbuf);
2748: pip_error(msg);
2749: mputc_prop('\n');
2750: put_offset_msg_to_prop(offset, hdr_workbuf);
2751: pip_prop("--\n");
2752:
2753: if (input_indx == 0) /* if 1st file, */
2754: {
2755: if (proc_flag[CONCAT] == FLAG_ON)
2756: (void)strcpy((hdr_workbuf+IP_VERS_OFFSET), "2.1 ");
2757: (void)strcpy(hdr_buf, hdr_workbuf); /* save hdr */
2758: if (output != NULL)
2759: {
2760: (void)sprintf(msg, "\nProcessing output file: %s\n",
2761: outputname);
2762: pip_error(msg);
2763: (void)sprintf(msg, "-- Output Hdr: %s--\n", hdr_workbuf);
2764: pip_error(msg);
2765: ip_puts(hdr_workbuf); /* copy hdr & add len to
2766: out_offset */
2767: }
2768:
2769: /*
2770: * copy everything up to, but NOT including (will include later),
2771: * OP_beginBlock
2772: */
2773: exit_flag = FLAG_OFF;
2774: while
2775: (exit_flag == FLAG_OFF)
2776: {
2777: type_byte = getc_testeof(input, inputname);
2778: if ((type_byte & OP_Mask) == (LONG_OP & OP_Mask))
2779: {
2780: op = ((type_byte & 0x1f) << 8) +
2781: getc_testeof(input, inputname);
2782: if (op == OP_beginBlock)
2783: exit_flag = FLAG_ON;
2784: else
2785: {
2786: ip_putc(type_byte);
2787: ip_putc(op);
2788: }
2789: }
2790: else
2791: proc_ip_token(type_byte, input, inputname);
2792: }
2793: out_end_offset[0] = out_offset - 1;
2794: /*
2795: * if concatenating, wrap a BEGIN empty_preamble END after the hdr &
2796: * instructionsBody and around the rest of the output
2797: */
2798: if (proc_flag[CONCAT] == FLAG_ON)
2799: {
2800: ++block_indx;
2801: out_beg_offset[block_indx] = out_offset;
2802: put_op(OP_beginBlock);
2803: put_op(OP_beginBody);
2804: put_op(OP_endBody);
2805: out_end_offset[block_indx] = out_offset - 1;
2806: }
2807: /*
2808: * NOW include the OP_beginBlock, & process the rest of the master
2809: */
2810: proc_long_op(OP_beginBlock);
2811: }
2812: prc_ip_tokens(input, inputname);
2813:
2814: mputc_prop('\n');
2815: indent(off_indent, propfile);
2816: (void)sprintf(msg, "--Number of Blocks:%4d\n", num_blocks);
2817: pip_prop(msg);
2818: indent(off_indent, propfile);
2819: (void)sprintf(msg, "--Number of Pages :%4d\n", num_pages);
2820: pip_prop(msg);
2821: indent(off_indent, propfile);
2822: (void)sprintf(msg, "--Number of SIFs :%4d\n", num_sifs);
2823: pip_prop(msg);
2824:
2825: for (i=0; merge_pg[input_indx][i] != 0; i++)
2826: {
2827: if (merge_pg[input_indx][i] > num_pages)
2828: {
2829: (void)sprintf(msg,
2830: "\n--ipfe: *** Page %d selected > # of pages in %s (%d)\n",
2831: merge_pg[input_indx][i], inputname,
2832: num_pages);
2833: pip_error(msg);
2834: break;
2835: }
2836: }
2837: }
2838: /***
2839: else
2840: {
2841: (void)sprintf(msg, "(*** PROCESSING ABORTED ***)\n");
2842: pip_error(msg);
2843: input_indx = num_infiles;
2844: abort_flag = FLAG_ON;
2845: }
2846: ***/
2847: }
2848:
2849:
2850: /****************************************************************
2851: *
2852: * prc_IF_bof(ifile, ifilename):
2853: * prc_IF_bof: read specified Interpress file &
2854: * discard everything up to, and
2855: * including, first OP_beginBlock
2856: *
2857: ****************************************************************/
2858:
2859: prc_IF_bof(ifile, ifilename)
2860:
2861: FILE *ifile;
2862: char *ifilename;
2863: {
2864: int op, exit_flag;
2865: int type_byte; /* must be int for stdio EOF */
2866:
2867:
2868: exit_flag = FLAG_OFF;
2869: while
2870: (exit_flag == FLAG_OFF)
2871: {
2872: type_byte = getc_testeof(ifile, ifilename);
2873: if ((type_byte & OP_Mask) == (LONG_OP & OP_Mask))
2874: {
2875: op = ((type_byte & 0x1f) << 8) +
2876: getc_testeof(ifile, ifilename);
2877: if (op == OP_beginBlock)
2878: exit_flag = FLAG_ON;
2879: }
2880: }
2881: }
2882:
2883:
2884: /****************************************************************
2885: *
2886: * prc_IF_fragment(ifile, ifilename):
2887: * prc_IF_fragment: process specified Interpress fragment
2888: * (i.e., skip everything up to, and
2889: * including the first OP_beginBlock;
2890: * then include everything up to, but
2891: * not including, the next OP_endBlock)
2892: *
2893: ****************************************************************/
2894:
2895: prc_IF_fragment(ifile, ifilename)
2896:
2897: FILE *ifile;
2898: char *ifilename;
2899: {
2900: int op, exit_flag;
2901: int type_byte; /* must be int for stdio EOF */
2902:
2903:
2904: /*
2905: * read & discard everything up to, and including, OP_beginBlock
2906: */
2907: prc_IF_bof(ifile, ifilename);
2908:
2909: /*
2910: * read & copy everything up to, but NOT including OP_endBlock
2911: */
2912: exit_flag = FLAG_OFF;
2913: while
2914: (exit_flag == FLAG_OFF)
2915: {
2916: type_byte = getc_testeof(ifile, ifilename);
2917: if ((type_byte & OP_Mask) == (LONG_OP & OP_Mask))
2918: {
2919: op = ((type_byte & 0x1f) << 8) +
2920: getc_testeof(ifile, ifilename);
2921: if (op == OP_endBlock)
2922: exit_flag = FLAG_ON;
2923: else
2924: put_op(op);
2925: }
2926: else
2927: proc_ip_token(type_byte, ifile, ifilename);
2928: }
2929: }
2930:
2931:
2932: /****************************************************************
2933: *
2934: * prc_IF_master(ifile, ifilename, pg):
2935: * prc_IF_master: process specified page of the
2936: * specified Interpress master
2937: * (i.e., skip everything up to, and
2938: * including the first OP_beginBlock;
2939: * then include the contents of the
2940: * preamble and the specified page,
2941: * without including the body tokens)
2942: *
2943: ****************************************************************/
2944:
2945: prc_IF_master(ifile, ifilename, pg)
2946:
2947: FILE *ifile;
2948: int pg;
2949: char *ifilename;
2950: {
2951: int op, exit_flag, wrt_flag, blk_indx, pg_cnt;
2952: int level[MX_BLOCK_DEPTH], ctr[MX_BLOCK_DEPTH];
2953: int type_byte; /* must be int for stdio EOF */
2954:
2955:
2956: /*
2957: * read & discard everything up to, and including, OP_beginBlock
2958: */
2959: prc_IF_bof(ifile, ifilename);
2960:
2961: /*
2962: * read & copy the contents of the preamble; then, copy only the
2963: * contents of the specified page
2964: */
2965: blk_indx = pg_cnt = 0;
2966: level[blk_indx] = ctr[blk_indx] = 0;
2967: wrt_flag = FLAG_OFF;
2968: exit_flag = FLAG_OFF;
2969: while
2970: (exit_flag == FLAG_OFF)
2971: {
2972: type_byte = getc_testeof(ifile, ifilename);
2973: if ((type_byte & OP_Mask) == (LONG_OP & OP_Mask))
2974: {
2975: op = ((type_byte & 0x1f) << 8) +
2976: getc_testeof(ifile, ifilename);
2977: if (op == OP_beginBlock)
2978: {
2979: ++blk_indx;
2980: level[blk_indx] = ctr[blk_indx] = 0;
2981: }
2982: else
2983: if (op == OP_endBlock)
2984: {
2985: if (blk_indx > 0)
2986: --blk_indx;
2987: else
2988: exit_flag = FLAG_ON;
2989: }
2990: else
2991: if (op == OP_beginBody)
2992: {
2993: if (level[blk_indx] == 0)
2994: {
2995: if (ctr[blk_indx] == 0)
2996: wrt_flag = FLAG_ON; /* processing preamble */
2997: else
2998: {
2999: ++pg_cnt;
3000: if (pg == pg_cnt)
3001: wrt_flag = FLAG_ON; /* got the right pg */
3002: }
3003: ++ctr[blk_indx];
3004: }
3005: else
3006: if (wrt_flag == FLAG_ON)
3007: put_op(op);
3008: ++level[blk_indx];
3009: }
3010: else
3011: if (op == OP_endBody)
3012: {
3013: --level[blk_indx];
3014: if (level[blk_indx] == 0)
3015: {
3016: wrt_flag = FLAG_OFF;
3017: if (pg == pg_cnt)
3018: exit_flag = FLAG_ON;
3019: }
3020: else
3021: if (wrt_flag == FLAG_ON)
3022: put_op(op);
3023: }
3024: else
3025: if (wrt_flag == FLAG_ON)
3026: put_op(op);
3027: }
3028: else
3029: if (wrt_flag == FLAG_ON)
3030: proc_ip_token(type_byte, ifile, ifilename);
3031: }
3032: }
3033:
3034:
3035: /****************************************************************
3036: *
3037: * proc_ip_token(type_byte, file, filename):
3038: * proc_ip_token: process interpress token of specified
3039: * type from specified file
3040: *
3041: ****************************************************************/
3042:
3043: proc_ip_token(type_byte, file, filename)
3044:
3045: FILE *file;
3046: int type_byte;
3047: char *filename;
3048: {
3049: long len;
3050: int op;
3051:
3052:
3053: if (type_byte != EOF)
3054: {
3055: if ((type_byte & 0x80) == 0) /* token is a SHORT NUMBER */
3056: {
3057: ip_putc(type_byte); /* 2-byte token */
3058: ip_putc(getc_testeof(file, filename));
3059: }
3060: else /* token is something else */
3061: {
3062: switch
3063: (type_byte & OP_Mask)
3064: {
3065: case (SHORT_OP & OP_Mask):
3066: ip_putc(type_byte); /* 1-byte token */
3067: break;
3068:
3069: case (LONG_OP & OP_Mask):
3070: op = ((type_byte & 0x1f) << 8) +
3071: getc_testeof(file, filename); /* 2-byte token */
3072: proc_long_op(op);
3073: break;
3074:
3075: case (SHORT_SEQUENCE & OP_Mask):
3076: len = getc_testeof(file, filename);
3077: proc_sequence(type_byte, len, file, filename);
3078: break;
3079:
3080: case (LONG_SEQUENCE & OP_Mask):
3081: len = getc_testeof(file, filename) << 16;
3082: len = len + (getc_testeof(file, filename) << 8);
3083: len = len + getc_testeof(file, filename);
3084: proc_sequence(type_byte, len, file, filename);
3085: break;
3086: }
3087: }
3088: }
3089:
3090: }
3091:
3092:
3093: /****************************************************************
3094: *
3095: * prc_ip_tokens(file, filename):
3096: * prc_ip_tokens: process interpress tokens
3097: * specified file
3098: *
3099: ****************************************************************/
3100:
3101: prc_ip_tokens(file, filename)
3102:
3103: FILE *file;
3104: char *filename;
3105: {
3106: int type_byte; /* must be int for stdio EOF */
3107:
3108:
3109: while
3110: ((type_byte = mgetc(file)) != EOF)
3111: {
3112: proc_ip_token(type_byte, file, filename);
3113: }
3114:
3115: }
3116:
3117:
3118: /****************************************************************
3119: *
3120: * proc_long_op(op):
3121: * proc_long_op: process long_op
3122: *
3123: ****************************************************************/
3124:
3125: proc_long_op(op)
3126:
3127: int op;
3128: {
3129: long val;
3130: int i, nesting_level;
3131:
3132:
3133: switch
3134: (op)
3135: {
3136: case (OP_beginBlock):
3137: put_op(op);
3138: ++num_blocks;
3139: ++tnum_blocks;
3140: if (block_indx == 0)
3141: out_end_offset[block_indx] = out_offset - 3;
3142: ++block_indx;
3143: out_beg_offset[block_indx] = out_offset - 2;
3144: blk_num_bytes[block_indx] = 2;
3145: put_opname_to_prop(op);
3146: preamble_expected = FLAG_ON;
3147: break;
3148: case (OP_endBlock):
3149: put_op(op);
3150: put_opname_to_prop(op);
3151: --block_indx;
3152: break;
3153: case (OP_beginBody):
3154: put_opname_to_prop(op);
3155: if (preamble_expected == FLAG_ON)
3156: {
3157: put_op(op);
3158: preamble_expected = FLAG_OFF;
3159: endpreamble_expected = FLAG_ON;
3160: }
3161: else
3162: if (bop_flag == FLAG_ON)
3163: {
3164: put_op(op);
3165: if (bop_iindx[bop_indx] == 0)
3166: bop_preamble_expected[bop_indx] = FLAG_ON;
3167: else
3168: if ((bop_iindx[bop_indx] == 1) &&
3169: (bop_preamble_expected[bop_indx] == FLAG_ON))
3170: bop_preamble_expected[bop_indx] = FLAG_OFF;
3171:
3172: ++bop_iindx[bop_indx];
3173: }
3174: else /* we have a righteous pageBody */
3175: {
3176: ++num_pages;
3177: ++tnum_pages;
3178: frstpg_flag = FLAG_ON;
3179: pg_num_bytes = 2;
3180:
3181: if ((merge_pg[input_indx][merge_indx] == 0) ||
3182: (num_pages < merge_pg[input_indx][merge_indx]))
3183: ipwrite_flag = FLAG_OFF;
3184: else
3185: {
3186: ipwrite_flag = FLAG_ON; /* it should already be on */
3187: put_op(op);
3188: if ((proc_flag[LANDSCAPE] == FLAG_ON) ||
3189: (proc_flag[ROTATE] == FLAG_ON))
3190: {
3191: put_Integer((long)rot_deg);
3192: put_op(OP_rotate);
3193: put_op(OP_concatt);
3194: if ((rxoff_den == 0) || (rxoff_den == 1))
3195: put_Integer(rxoff_num);
3196: else
3197: put_seqRational(rxoff_num, rxoff_den);
3198: if ((ryoff_den == 0) || (ryoff_den == 1))
3199: put_Integer(ryoff_num);
3200: else
3201: put_seqRational(ryoff_num, ryoff_den);
3202: put_op(OP_translate);
3203: put_op(OP_concatt);
3204: }
3205: if (proc_flag[BINDING_OFFSET] == FLAG_ON)
3206: {
3207: if ((proc_flag[DUPLEX] == FLAG_ON) &&
3208: ((num_pages % 2) == 0))
3209: val = -(boff_num);
3210: else
3211: val = boff_num;
3212: if (proc_flag[LANDSCAPE] == FLAG_ON)
3213: {
3214: put_Integer(0L); /* no xShift */
3215: if ((boff_den == 0) || (boff_den == 1))
3216: put_Integer(-(val)); /* -(yShift) */
3217: else
3218: put_seqRational(-(val), boff_den);
3219: }
3220: else
3221: {
3222: if ((boff_den == 0) || (boff_den == 1))
3223: put_Integer(val);
3224: else
3225: put_seqRational(val, boff_den);
3226: put_Integer(0L); /* no yShift */
3227: }
3228: put_op(OP_translate);
3229: put_op(OP_concatt);
3230: }
3231: if ((proc_flag[X_OFFSET] == FLAG_ON) ||
3232: (proc_flag[Y_OFFSET] == FLAG_ON))
3233: {
3234: if ((xoff_den == 0) || (xoff_den == 1))
3235: put_Integer(xoff_num);
3236: else
3237: put_seqRational(xoff_num, xoff_den);
3238:
3239: if ((yoff_den == 0) || (yoff_den == 1))
3240: put_Integer(yoff_num);
3241: else
3242: put_seqRational(yoff_num, yoff_den);
3243: put_op(OP_translate);
3244: put_op(OP_concatt);
3245: }
3246: if (proc_flag[SCALE] == FLAG_ON)
3247: {
3248: if ((scale_den == 0) | (scale_den == 1))
3249: put_Integer(scale_num);
3250: else
3251: put_seqRational(scale_num, scale_den);
3252: put_op(OP_scale);
3253: put_op(OP_concatt);
3254: }
3255:
3256: if ((merge_pg[input_indx][merge_indx] == (-1)) &&
3257: (num_pages ==
3258: merge_pg[input_indx][(merge_indx+1)]))
3259: ++merge_indx;
3260: if ((num_pages ==
3261: merge_pg[input_indx][merge_indx]) &&
3262: (ovly_pg[input_indx][merge_indx] != (-1)))
3263: {
3264: put_op(OP_dosavesimplebody);
3265: put_op(OP_beginBody);
3266: }
3267: }
3268: }
3269: begBody_flag = FLAG_ON;
3270: break;
3271: case (OP_endBody):
3272: put_opname_to_prop(op);
3273: if (bop_flag == FLAG_ON)
3274: {
3275: put_op(op);
3276: --bop_iindx[bop_indx];
3277: if ((bop_iindx[bop_indx] == 0) && (bop_indx > 0))
3278: --bop_indx;
3279: if ((bop_indx == 0) && (bop_iindx[bop_indx] == 0))
3280: bop_flag = FLAG_OFF;
3281: }
3282: else /* bop_flag == FLAG_OFF */
3283: {
3284: if (endpreamble_expected == FLAG_ON)
3285: /* then processing preamble -- can't chapterize */
3286: {
3287: put_op(op);
3288: endpreamble_expected = FLAG_OFF;
3289: /*
3290: * this next code determines the length of each BEGIN/Preamble to copy
3291: * for chapterizing as part of handling nested blocks
3292: */
3293: out_end_offset[block_indx] = out_offset - 1;
3294: }
3295: else /* we have a righteous endBody */
3296: {
3297: if (ipwrite_flag == FLAG_ON)
3298: {
3299: put_op(op);
3300: ++out_numpages;
3301: ovly_flag = FLAG_OFF;
3302: while
3303: (num_pages ==
3304: merge_pg[input_indx][merge_indx])
3305: {
3306: if (ovly_pg[input_indx][merge_indx] != (-1))
3307: {
3308: ovly_flag = FLAG_ON;
3309: proc_overlay();
3310: }
3311: ++merge_indx;
3312: }
3313: if (ovly_flag == FLAG_ON)
3314: {
3315: put_op(OP_endBody);
3316: ovly_flag = FLAG_OFF;
3317: }
3318: proc_chapterize();
3319: }
3320: if (merge_pg[input_indx][merge_indx] == 0)
3321: {
3322: if (proc_flag[CONCAT] == FLAG_ON)
3323: nesting_level = block_indx - 1;
3324: else
3325: nesting_level = block_indx;
3326:
3327: for (i=0; i < nesting_level; i++)
3328: put_op(OP_endBlock);
3329: ipwrite_flag = FLAG_OFF;
3330: }
3331: else
3332: ipwrite_flag = FLAG_ON;
3333: }
3334: }
3335: break;
3336: case (OP_makesimpleco):
3337: case (OP_dosavesimplebody):
3338: case (OP_if):
3339: case (OP_ifelse):
3340: case (OP_ifcopy):
3341: case (OP_correct):
3342: put_op(op);
3343: put_opname_to_prop(op);
3344: if (bop_flag == FLAG_OFF)
3345: {
3346: bop_indx = 0;
3347: bop_flag = FLAG_ON;
3348: }
3349: else
3350: ++bop_indx;
3351: bop_iindx[bop_indx] = 0;
3352: bop_preamble_expected[bop_indx] = FLAG_OFF;
3353: break;
3354: default:
3355: put_op(op);
3356: break;
3357: }
3358: }
3359:
3360:
3361: /****************************************************************
3362: *
3363: * proc_overlay: process the current
3364: * ovly_pg[input_indx][merge_indx]
3365: *
3366: ****************************************************************/
3367:
3368: proc_overlay()
3369: {
3370:
3371: put_op(OP_dosavesimplebody);
3372: put_op(OP_beginBody);
3373: ovly_indx = ovly_pg[input_indx][merge_indx];
3374: if ((ovly_den[0][ovly_indx] != 0) ||
3375: (ovly_den[1][ovly_indx] != 0))
3376: {
3377: if ((ovly_den[0][ovly_indx] == 0) ||
3378: (ovly_den[0][ovly_indx] == 1))
3379: put_Integer(ovly_num[0][ovly_indx]);
3380: else
3381: put_seqRational(ovly_num[0][ovly_indx],
3382: ovly_den[0][ovly_indx]);
3383: if ((ovly_den[1][ovly_indx] == 0) ||
3384: (ovly_den[1][ovly_indx] == 1))
3385: put_Integer(ovly_num[1][ovly_indx]);
3386: else
3387: put_seqRational(ovly_num[1][ovly_indx],
3388: ovly_den[1][ovly_indx]);
3389: put_op(OP_translate);
3390: put_op(OP_concatt);
3391: }
3392: proc_ovly_file(ovly_fname[ovly_indx]);
3393: put_op(OP_endBody);
3394:
3395: }
3396:
3397:
3398: /****************************************************************
3399: *
3400: * prc_ovly_file(fname):
3401: * proc_ovly_file: try to open specified filename;
3402: * if open_err,
3403: * create a SIF reference
3404: * else,
3405: * process as a SIF
3406: *
3407: ****************************************************************/
3408:
3409: proc_ovly_file(fname)
3410:
3411: char *fname;
3412: {
3413: int retcd, pgnum;
3414: char msg[128];
3415:
3416:
3417: ovly_file = fopen(fname, "r");
3418: if (ovly_file == NULL)
3419: {
3420: (void)sprintf(msg,
3421: " --Error opening overlay file: %s\n",
3422: fname);
3423: pip_error(msg);
3424: create_SIF(fname);
3425: }
3426: else
3427: {
3428: retcd = get_ip_hdr(ovly_file, fname);
3429: if (retcd == ERROR)
3430: create_SIF(fname);
3431: else
3432: {
3433: /***
3434: The following assumes we're not already nested in a body_operator
3435: (i.e., that we were at a real endBody when invoked)
3436: ***/
3437: bop_flag = FLAG_ON;
3438: bop_indx = 0;
3439: bop_iindx[0] = 0;
3440: bop_preamble_expected[0] = FLAG_ON;
3441: if (strlen(hdr_workbuf) > IP_HDR_MASTERLEN)
3442: prc_IF_fragment(ovly_file, fname);
3443: else
3444: {
3445: if (ovly_pgnum[ovly_indx] == 0)
3446: pgnum = 1;
3447: else
3448: pgnum = ovly_pgnum[ovly_indx];
3449: prc_IF_master(ovly_file, fname, pgnum);
3450: }
3451: bop_flag = FLAG_OFF;
3452: }
3453: (void)fclose(ovly_file);
3454: }
3455:
3456: }
3457:
3458:
3459: /****************************************************************
3460: *
3461: * proc_sequence(type_byte, length, file, filename):
3462: * proc_sequence: process Interpress tokens of type
3463: * <sequence>
3464: *
3465: ****************************************************************/
3466:
3467: proc_sequence(type_byte, length, file, filename)
3468:
3469: FILE *file;
3470: long length;
3471: int type_byte;
3472: char *filename;
3473: {
3474:
3475: if ((type_byte & 0x1f) == sequenceInsertFile)
3476: proc_SIF_token(type_byte, length, file, filename);
3477: else
3478: {
3479: put_seq_type_len(type_byte, length);
3480: iocopyn(length, file, filename);
3481: }
3482: }
3483:
3484:
3485: /****************************************************************
3486: *
3487: * prc_SIF_file(sfile, sfilename):
3488: * prc_SIF_file: process sequenceInsertFile
3489: *
3490: ****************************************************************/
3491:
3492: prc_SIF_file(sfile, sfilename)
3493:
3494: FILE *sfile;
3495: char *sfilename;
3496: {
3497:
3498: /*
3499: * if the IP_HDR indicates the SIF is a fragment, process as such;
3500: * else, for a regular SIF, just process the first page of a master
3501: */
3502: if (strlen(hdr_workbuf) > IP_HDR_MASTERLEN)
3503: prc_IF_fragment(sfile, sfilename);
3504: else
3505: prc_IF_master(sfile, sfilename, 1);
3506: }
3507:
3508:
3509: /****************************************************************
3510: *
3511: * proc_SIF_token(type, length, file, filename):
3512: * proc_SIF_token: process sequenceInsertFile token
3513: *
3514: ****************************************************************/
3515:
3516: proc_SIF_token(type_byte, length, file, filename)
3517:
3518: FILE *file;
3519: long length;
3520: int type_byte;
3521: char *filename;
3522: {
3523: int i, retcd;
3524: char msg[128], buf[MX_HDR_BUFLEN], open_buf[MX_HDR_BUFLEN];
3525: static char *preserve_msg =
3526: " --(Preserving the SIF reference)\n",
3527: *remove_msg =
3528: " --(Removing the SIF reference)\n";
3529:
3530:
3531: ++num_sifs;
3532: ++tnum_sifs;
3533: test_newline();
3534: put_offset_msg_to_prop((in_offset-1), "--SIF: ");
3535:
3536: if ((length == 0) || (length > MX_HDR_BUFLEN))
3537: {
3538: (void)sprintf(msg,
3539: "--Warning: sequenceInsertFile token encountered with\n");
3540: pip_error(msg);
3541: (void)sprintf(msg, " descriptor length = %d\n",
3542: length);
3543: pip_error(msg);
3544: (void)sprintf(msg, "(ERROR: Descriptor length = %d)\n", length);
3545: pip_prop(msg);
3546: if (proc_flag[REMOVE_SIFS] == FLAG_ON)
3547: {
3548: pip_error(remove_msg);
3549: ioreadn(length, file, filename);
3550: }
3551: else
3552: {
3553: pip_error(preserve_msg);
3554: /*
3555: * preserve the SIF reference
3556: */
3557: copy_preserve_SIF(type_byte, length, file, filename);
3558: }
3559: }
3560: else
3561: {
3562: iogetn(length, file, filename, buf);
3563: (void)strcpy(open_buf, buf);
3564:
3565: (void)sprintf(msg, " --SIF: %s (nesting depth=%d)\n",
3566: buf, sif_indx);
3567: pip_error(msg);
3568: (void)sprintf(msg, "%s\n", buf);
3569: pip_prop(msg);
3570: /*
3571: * Check for alias
3572: */
3573: for (i=0; i < num_aliases; i++)
3574: {
3575: if (strcmp(buf, alias_ref[i]) == 0)
3576: {
3577: (void)strcpy(open_buf, alias_act[i]);
3578: (void)sprintf(msg, " --Alias: %s=%s\n",
3579: buf, open_buf);
3580: pip_error(msg);
3581: indent((off_indent + cur_indent + 8), propfile);
3582: (void)sprintf(msg,"--Alias: %s=%s\n", buf, open_buf);
3583: pip_prop(msg);
3584: break;
3585: }
3586: }
3587:
3588: if (proc_flag[SATISFY_SIFS] == FLAG_OFF)
3589: {
3590: if (proc_flag[REMOVE_SIFS] == FLAG_ON)
3591: pip_error(remove_msg);
3592: else
3593: {
3594: pip_error(
3595: " -s switch (Satisfy SIFS option) not specified\n");
3596: pip_error(preserve_msg);
3597: put_preserve_SIF(type_byte, length, buf);
3598: }
3599: }
3600: else
3601: if (sif_indx >= MX_SIF_DEPTH)
3602: {
3603: (void)sprintf(msg,
3604: "*** warning: maximum SIF nesting depth allowed in IPFE=%d\n",
3605: MX_SIF_DEPTH);
3606: pip_error(msg);
3607: if (proc_flag[REMOVE_SIFS] == FLAG_ON)
3608: pip_error(remove_msg);
3609: else
3610: {
3611: pip_error(preserve_msg);
3612: /*
3613: * preserve the SIF reference
3614: */
3615: put_preserve_SIF(type_byte, length, buf);
3616: }
3617: }
3618: else
3619: {
3620: sif_file[sif_indx] = fopen(open_buf, "r");
3621: if (sif_file[sif_indx] == NULL)
3622: {
3623: pip_error(" ");
3624: (void)sprintf(msg, "--Error opening SIF file: %s\n",
3625: open_buf);
3626: pip_error(msg);
3627: indent((off_indent + cur_indent + 8), propfile);
3628: pip_prop(msg);
3629: if (proc_flag[REMOVE_SIFS] == FLAG_ON)
3630: pip_error(remove_msg);
3631: else
3632: {
3633: pip_error(preserve_msg);
3634: /*
3635: * preserve the SIF reference
3636: */
3637: put_preserve_SIF(type_byte, length, buf);
3638: }
3639: }
3640: else
3641: {
3642: /*
3643: * check the validity of the SIF hdr
3644: */
3645: retcd = get_ip_hdr(sif_file[sif_indx], open_buf);
3646: if (retcd == ERROR)
3647: {
3648: if (proc_flag[REMOVE_SIFS] == FLAG_ON)
3649: pip_error(remove_msg);
3650: else
3651: {
3652: pip_error(preserve_msg);
3653: /*
3654: * preserve the SIF reference
3655: */
3656: put_preserve_SIF(type_byte, length, buf);
3657: }
3658: }
3659: else
3660: {
3661: (void)strcpy(sif_name[sif_indx], open_buf);
3662: sifname = sif_name[sif_indx];
3663: siffile = sif_file[sif_indx];
3664:
3665: pip_error(
3666: " -- Processing SIF content --\n");
3667:
3668: ++sif_indx;
3669: prc_SIF_file(siffile, sifname);
3670: --sif_indx;
3671: }
3672: (void)fclose(sif_file[sif_indx]);
3673: }
3674: }
3675: }
3676:
3677: }
3678:
3679:
3680: /****************************************************************
3681: *
3682: * put_Integer(val):
3683: * put_Integer: if ((val > INTEGER_MAX) ||
3684: * (val < INTEGER_MIN))
3685: * put val out as seqInteger
3686: * else
3687: * put val out as Short Number
3688: * token (biased by 4000 (0xfa0))
3689: *
3690: ****************************************************************/
3691:
3692: put_Integer(val)
3693:
3694: long val;
3695: {
3696: int len;
3697:
3698:
3699: if ((val < INTEGER_MIN) || (val > INTEGER_MAX))
3700: {
3701: len = count_int_bytes(val);
3702: put_seq_type_len(sequenceInteger, (long)len);
3703: put_intn(val, len);
3704: }
3705: else
3706: {
3707: val = val + INTEGER_ZERO; /* add bias */
3708: ip_putc((char)((val >> 8) & 0x7f));
3709: ip_putc((char)val);
3710: }
3711:
3712: }
3713:
3714:
3715: /****************************************************************
3716: *
3717: * put_intn(val, len):
3718: * put_intn: put specified val out as len bytes
3719: *
3720: ****************************************************************/
3721:
3722: put_intn(val, len)
3723:
3724: long val;
3725: int len; /* measured in bytes */
3726: {
3727: int i;
3728:
3729:
3730: if (len > 0)
3731: {
3732: --len;
3733: for (i=len*8; i >= 0; i=i-8)
3734: ip_putc((char)(val >> i));
3735: }
3736:
3737: }
3738:
3739:
3740: /****************************************************************
3741: *
3742: * put_offset_msg_to_prop(off, msg):
3743: * put_offset_msg_to_prop: put specified in_offset (formatted)
3744: * + <: > + <cur_indent> + msg
3745: * to propfile
3746: *
3747: ****************************************************************/
3748:
3749: put_offset_msg_to_prop(off, msg)
3750:
3751: long off;
3752: char *msg;
3753: {
3754:
3755: if (cur_col == 0)
3756: {
3757: if (proc_flag[DEBUG] == FLAG_ON)
3758: put_offp_to_prop(off);
3759: indent(cur_indent, propfile);
3760: }
3761: pip_prop(msg);
3762:
3763: }
3764:
3765:
3766: /****************************************************************
3767: *
3768: * put_off_to_prop(off, format_flag):
3769: * put_off_to_prop: put specified in_offset (formatted)
3770: * to propfile
3771: *
3772: ****************************************************************/
3773:
3774: put_off_to_prop(off, format_flag)
3775:
3776: long off;
3777: int format_flag;
3778: {
3779: int i, procflag;
3780: char digit;
3781:
3782:
3783: if (propfile != NULL)
3784: {
3785: procflag = FLAG_OFF;
3786: for (i=20; i >= 0; i=i-4)
3787: {
3788: digit = (off >> i) & 0x0f;
3789: if ((digit == 0) && (procflag == FLAG_OFF) && (i > 4))
3790: {
3791: if (format_flag == FORMAT)
3792: mputc_prop(SPC);
3793: }
3794: else
3795: {
3796: if (digit > 9)
3797: digit = digit + 7;
3798: mputc_prop(digit + 0x30);
3799: procflag = FLAG_ON;
3800: }
3801: if ((i == 16) &&
3802: ((format_flag == FORMAT) || (procflag == FLAG_ON)))
3803: mputc_prop(SPC);
3804: }
3805: }
3806:
3807: }
3808:
3809:
3810: /****************************************************************
3811: *
3812: * put_offp_to_prop(off):
3813: * put_offp_to_prop: put specified in_offset (formatted
3814: * plus "+ " or ": " to propfile
3815: *
3816: ****************************************************************/
3817:
3818: put_offp_to_prop(off)
3819:
3820: long off;
3821: {
3822: put_off_to_prop(off, FORMAT);
3823: if (off > 0xffffff)
3824: pip_prop("+ ");
3825: else
3826: pip_prop(": ");
3827:
3828: }
3829:
3830:
3831: /****************************************************************
3832: *
3833: * put_op(op):
3834: * put_op: put specified op to output
3835: *
3836: ****************************************************************/
3837:
3838: put_op(op)
3839:
3840: int op;
3841: {
3842: if (op <= SHORT_OP_LIMIT)
3843: ip_putc(op | SHORT_OP);
3844: else
3845: {
3846: ip_putc((op >> 8) | LONG_OP);
3847: ip_putc(op);
3848: }
3849: }
3850:
3851:
3852: /****************************************************************
3853: *
3854: * put_opname_to_prop(op):
3855: * put_opname_to_prop: put specified op_name to propfile
3856: *
3857: ****************************************************************/
3858:
3859: put_opname_to_prop(op)
3860:
3861: int op;
3862: {
3863: char msg[128];
3864:
3865:
3866: if (op != OP_endBody)
3867: test_begBody();
3868: begBody_flag = FLAG_OFF; /* reset because we're ALWAYS putting
3869: SOMETHING to propfile here */
3870:
3871: switch
3872: (op)
3873: {
3874: case (OP_beginBlock):
3875: test_newline();
3876: (void)sprintf(msg, "%s\n", op_name(op));
3877: put_offset_msg_to_prop((in_offset-2), msg);
3878: cur_indent = cur_indent + INDENT_INCR;
3879: break;
3880: case (OP_endBlock):
3881: cur_indent = cur_indent - INDENT_INCR;
3882: test_newline();
3883: put_offset_msg_to_prop((in_offset-2), op_name(op));
3884: if (proc_flag[DEBUG] == FLAG_ON)
3885: {
3886: indent((INDENT_INCR - 1), propfile);
3887: mputc_prop('(');
3888: put_off_to_prop((in_offset-1), DONT_FORMAT);
3889: mputc_prop(')');
3890: }
3891: mputc_prop('\n');
3892: break;
3893: case (OP_beginBody):
3894: put_offset_msg_to_prop((in_offset-2), op_name(op));
3895: indent((INDENT_INCR - 1), propfile);
3896: if ((proc_flag[PROPERTIES] == FLAG_ON) && (prop_level > 0))
3897: {
3898: if ((preamble_expected == FLAG_OFF) &&
3899: (endpreamble_expected == FLAG_OFF) &&
3900: (bop_flag == FLAG_OFF))
3901: { /* we have a righteous pageBody */
3902: (void)sprintf(msg, "Pg%d", (tnum_pages + 1));
3903: pip_prop(msg);
3904: indent((INDENT_INCR - 1), propfile);
3905: }
3906: }
3907: cur_indent = cur_indent + INDENT_INCR;
3908: break;
3909: case (OP_endBody):
3910: cur_indent = cur_indent - INDENT_INCR;
3911: if (cur_col == 0)
3912: indent((cur_indent + off_indent), propfile);
3913: pip_prop(op_name(op));
3914: if ((proc_flag[PROPERTIES] == FLAG_ON) && (prop_level > 0))
3915: {
3916: if ((endpreamble_expected == FLAG_OFF) &&
3917: (bop_flag == FLAG_OFF))
3918: { /* we have a righteous endBody */
3919: indent((INDENT_INCR - 1), propfile);
3920: (void)sprintf(msg, "endPg%d", tnum_pages);
3921: pip_prop(msg);
3922: }
3923: }
3924: if (proc_flag[DEBUG] == FLAG_ON)
3925: {
3926: indent((INDENT_INCR - 1), propfile);
3927: mputc_prop('(');
3928: put_off_to_prop((in_offset-1), DONT_FORMAT);
3929: mputc_prop(')');
3930: }
3931: if (debug_flag == FLAG_ON)
3932: {
3933: indent((INDENT_INCR - 1), propfile);
3934: (void)sprintf(msg,"[%d %d %d %d]",
3935: bop_indx,
3936: bop_iindx[bop_indx],
3937: bop_iindx[0],
3938: endpreamble_expected);
3939: pip_prop(msg);
3940: }
3941: mputc_prop('\n');
3942: break;
3943: case (OP_makesimpleco):
3944: case (OP_dosavesimplebody):
3945: case (OP_if):
3946: case (OP_ifelse):
3947: case (OP_ifcopy):
3948: put_offset_msg_to_prop((in_offset-2), op_name(op));
3949: mputc_prop('\n');
3950: break;
3951: case (OP_correct):
3952: /*
3953: * don't do all those nasty CORRECT's unless the user forces us to
3954: */
3955: if (prop_level > 1)
3956: {
3957: put_offset_msg_to_prop((in_offset-2), op_name(op));
3958: mputc_prop('\n');
3959: }
3960: break;
3961: default:
3962: break;
3963: }
3964: }
3965:
3966:
3967: /****************************************************************
3968: *
3969: * put_seqRational(num, den):
3970: * put_seqRational: put specified numerator & denominator
3971: * out as a sequenceRational
3972: *
3973: ****************************************************************/
3974:
3975: put_seqRational(num, den)
3976:
3977: long num, den;
3978: {
3979: int len, num_len, den_len;
3980:
3981:
3982: num_len = count_int_bytes(num);
3983: den_len = count_int_bytes(den);
3984: if (num_len > den_len)
3985: len = num_len;
3986: else
3987: len = den_len;
3988: put_seq_type_len(sequenceRational, (long)(len * 2));
3989: put_intn(num, len);
3990: put_intn(den, len);
3991:
3992: }
3993:
3994:
3995: /****************************************************************
3996: *
3997: * put_seq_type_len(type_byte, length):
3998: * put_seq_type_len: put specified type_byte & length
3999: * to output
4000: *
4001: ****************************************************************/
4002:
4003: put_seq_type_len(type_byte, length)
4004:
4005: long length;
4006: int type_byte;
4007: {
4008: if (length > SHORT_SEQUENCE_LIMIT)
4009: {
4010: ip_putc((char)(LONG_SEQUENCE | (type_byte & 0x1f)));
4011: ip_putc((char)(length >> 16));
4012: ip_putc((char)(length >> 8));
4013: ip_putc((char)length);
4014: }
4015: else
4016: {
4017: ip_putc((char)(SHORT_SEQUENCE | (type_byte & 0x1f)));
4018: ip_putc((char)length);
4019: }
4020:
4021: }
4022:
4023:
4024: /****************************************************************
4025: *
4026: * test_begBody: if beBody flag is set,
4027: * put a newline to propfile
4028: *
4029: ****************************************************************/
4030:
4031: test_begBody()
4032: {
4033: if (begBody_flag == FLAG_ON)
4034: {
4035: mputc_prop('\n');
4036: begBody_flag = FLAG_OFF;
4037: }
4038: }
4039:
4040:
4041:
4042: /****************************************************************
4043: *
4044: * test_newline: if cur_col != 0,
4045: * put a newline to propfile
4046: *
4047: ****************************************************************/
4048:
4049: test_newline()
4050: {
4051: if (cur_col != 0)
4052: mputc_prop('\n');
4053:
4054: }
4055:
4056:
4057: /****************************************************************
4058: *
4059: * usage: dsply the cmd_line interface
4060: *
4061: ****************************************************************/
4062:
4063: Usage()
4064: {
4065: fprintf(STDERR,
4066: "Usage:\n");
4067: fprintf(STDERR,
4068: " ipfe [ options ] file [pagerange ... [file [pagerange]...]\n");
4069: fprintf(STDERR,
4070: "Options:\n");
4071: fprintf(STDERR,
4072: " [-l logfile] [-dDiLqrRs] [-a alias:actual [-a alias:actual]\n");
4073: fprintf(STDERR,
4074: " ...] [-b offset:unit] [-c count:unit] [-o outfile]\n");
4075: fprintf(STDERR,
4076: " [-p level:propfile] [-S factor] [-X offset:unit]\n");
4077: fprintf(STDERR,
4078: " [-Y offset:unit]\n\n");
4079:
4080: fprintf(STDERR,
4081: " -a alias:actual (alias). If the -s option is specified,\n");
4082: fprintf(STDERR,
4083: " replace any SIF matching the string \"alias\"\n");
4084: fprintf(STDERR,
4085: " with the string \"actual\" before attempting\n");
4086: fprintf(STDERR,
4087: " to satisfy the SIF. If \"actual\" cannot be\n");
4088: fprintf(STDERR,
4089: " opened or there is some error, the SIF\n");
4090: fprintf(STDERR,
4091: " \"alias\" is preserved, unless the -r option\n");
4092: fprintf(STDERR,
4093: " is also specified.\n");
4094: fprintf(STDERR,
4095: " -b offset:unit (binding offset). Shift the image offset units\n");
4096: fprintf(STDERR,
4097: " in the x-direction, where unit may be: none\n");
4098: fprintf(STDERR,
4099: " (default centimeters), c (centimeters), i\n");
4100: fprintf(STDERR,
4101: " (inches), p (points), P (Picas). If the -L\n");
4102: fprintf(STDERR,
4103: " (Landscape) switch is set, the image shift\n");
4104: fprintf(STDERR,
4105: " is in the y-direction.\n");
4106: fprintf(STDERR,
4107: " -c count:unit (chapterize) every count units, where unit\n");
4108: fprintf(STDERR,
4109: " be: p (pages), k (kilobytes), m (megabytes).\n");
4110: fprintf(STDERR,
4111: " -d (duplex). For resolving binding offset.\n");
4112: fprintf(STDERR,
4113: " -D (debug). If the -p option is specified, also\n");
4114: fprintf(STDERR,
4115: " write to the properties file the offsets of\n");
4116: fprintf(STDERR,
4117: " each skeleton-level token encountered.\n");
4118: fprintf(STDERR,
4119: " -i (insert SIF for overlay). Insert (create) a\n");
4120: fprintf(STDERR,
4121: " SIF for any unresolvable overlays.\n");
4122: fprintf(STDERR,
4123: " -l logfile (log). Keep a running log.\n");
4124: fprintf(STDERR,
4125: " -L (Landscape). Rotate every page 90 degrees\n");
4126: fprintf(STDERR,
4127: " counterclockwise and preserve the upper left\n");
4128: fprintf(STDERR,
4129: " corner. Intended for printing text in\n");
4130: fprintf(STDERR,
4131: " landscape orientation.\n");
4132: fprintf(STDERR,
4133: " -o outfile (output). Where the output goes. If there is\n");
4134: fprintf(STDERR,
4135: " no -o and there is a -p, only the properties\n");
4136: fprintf(STDERR,
4137: " are written, else if there is no -o,\n");
4138: fprintf(STDERR,
4139: " \"infile.ip\" is used if it doesn't already\n");
4140: fprintf(STDERR,
4141: " exist, else \"infileN.ip\" is used, where N\n");
4142: fprintf(STDERR,
4143: " is the lowest integer such that \"infileN.ip\"\n");
4144: fprintf(STDERR,
4145: " does not already exist.\n");
4146: fprintf(STDERR,
4147: " -p level:propfile\n");
4148: fprintf(STDERR,
4149: " (properties). Where the properties are\n");
4150: fprintf(STDERR,
4151: " written. Increasing levels provide increasing\n");
4152: fprintf(STDERR,
4153: " information details.\n");
4154: fprintf(STDERR,
4155: " -q (quiet). Don't write info and error msgs (to\n");
4156: fprintf(STDERR,
4157: " STDERR).\n");
4158: fprintf(STDERR,
4159: " -r (remove SIFS). If -s is also specified, it\n");
4160: fprintf(STDERR,
4161: " takes precedence and a SIF reference is\n");
4162: fprintf(STDERR,
4163: " removed only if it is unresolved or there is\n");
4164: fprintf(STDERR,
4165: " some other error.\n");
4166: fprintf(STDERR,
4167: " -R (Rotate). Rotate every page 90 degrees\n");
4168: fprintf(STDERR,
4169: " clockwise and preserve the center point.\n");
4170: fprintf(STDERR,
4171: " Intended for rotating an image created for a\n");
4172: fprintf(STDERR,
4173: " \"landscape printer\" to print in portrait\n");
4174: fprintf(STDERR,
4175: " orientation.\n");
4176: fprintf(STDERR,
4177: " -s (satisfy SIFS). Replace any SIF reference\n");
4178: fprintf(STDERR,
4179: " with the tokens found in the referenced file.\n");
4180: fprintf(STDERR,
4181: " If the referenced file cannot be opened, the\n");
4182: fprintf(STDERR,
4183: " SIF reference is preserved unless -r is also\n");
4184: fprintf(STDERR,
4185: " specified.\n");
4186: fprintf(STDERR,
4187: " -S factor (scale). Scale the image by factor.\n");
4188: fprintf(STDERR,
4189: " -X offset:unit (X-imageShift). Shift the image offset units\n");
4190: fprintf(STDERR,
4191: " in the x-direction, where unit may be: none\n");
4192: fprintf(STDERR,
4193: " (default centimeters), c (centimeters), i\n");
4194: fprintf(STDERR,
4195: " (inches), p (points), P (Picas). The shift\n");
4196: fprintf(STDERR,
4197: " is independent of the -L and -R switches\n");
4198: fprintf(STDERR,
4199: " (i.e., the x-direction is the same as the\n");
4200: fprintf(STDERR,
4201: " unrotated image).\n");
4202: fprintf(STDERR,
4203: " -Y offset:unit (Y-imageShift). Shift the image offset units\n");
4204: fprintf(STDERR,
4205: " in the y-direction, where unit may be: none\n");
4206: fprintf(STDERR,
4207: " (default centimeters), c (centimeters), i\n");
4208: fprintf(STDERR,
4209: " (inches), p (points), P (Picas). The shift\n");
4210: fprintf(STDERR,
4211: " is independent of the -L and -R switches\n");
4212: fprintf(STDERR,
4213: " (i.e., the y-direction is the same as the\n");
4214: fprintf(STDERR,
4215: " unrotated image).\n");
4216: fprintf(STDERR,
4217: " infile [pagerange]\n");
4218: fprintf(STDERR,
4219: " See the manual page for syntax details.\n");
4220: fprintf(STDERR,
4221: " Example:\n");
4222: fprintf(STDERR,
4223: " [1,4-6,9[pic1],10-11,12[pic2:2(2P,4P)][pic3(-4P,-2P)],15-]\n\n");
4224:
4225: exit(1);
4226: }
4227:
4228: /*** end of file = IPFE.C *************************************/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.