]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * "$Id: cupstestppd.c,v 1.20 2003/02/28 21:06:09 mike Exp $" | |
3 | * | |
4 | * PPD test program for the Common UNIX Printing System (CUPS). | |
5 | * | |
6 | * Copyright 1997-2003 by Easy Software Products, all rights reserved. | |
7 | * | |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Easy Software Products and are protected by Federal | |
10 | * copyright law. Distribution and use rights are outlined in the file | |
11 | * "LICENSE.txt" which should have been included with this file. If this | |
12 | * file is missing or damaged please contact Easy Software Products | |
13 | * at: | |
14 | * | |
15 | * Attn: CUPS Licensing Information | |
16 | * Easy Software Products | |
17 | * 44141 Airport View Drive, Suite 204 | |
18 | * Hollywood, Maryland 20636-3111 USA | |
19 | * | |
20 | * Voice: (301) 373-9603 | |
21 | * EMail: cups-info@cups.org | |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * PostScript is a trademark of Adobe Systems, Inc. | |
25 | * | |
26 | * This file is subject to the Apple OS-Developed Software exception. | |
27 | * | |
28 | * Contents: | |
29 | * | |
30 | * main() - Main entry for test program. | |
31 | * usage() - Show program usage... | |
32 | */ | |
33 | ||
34 | /* | |
35 | * Include necessary headers... | |
36 | */ | |
37 | ||
38 | #include <cups/cups.h> | |
39 | #include <cups/string.h> | |
40 | #include <errno.h> | |
41 | #include <stdlib.h> | |
42 | ||
43 | ||
44 | /* | |
45 | * Error codes... | |
46 | */ | |
47 | ||
48 | #define ERROR_NONE 0 | |
49 | #define ERROR_USAGE 1 | |
50 | #define ERROR_FILE_OPEN 2 | |
51 | #define ERROR_PPD_FORMAT 3 | |
52 | #define ERROR_CONFORMANCE 4 | |
53 | ||
54 | ||
55 | /* | |
56 | * Local functions... | |
57 | */ | |
58 | ||
59 | void usage(void); | |
60 | ||
61 | ||
62 | /* | |
63 | * 'main()' - Main entry for test program. | |
64 | */ | |
65 | ||
66 | int /* O - Exit status */ | |
67 | main(int argc, /* I - Number of command-line arguments */ | |
68 | char *argv[]) /* I - Command-line arguments */ | |
69 | { | |
70 | int i, j, k, m, n; /* Looping vars */ | |
71 | int len; /* Length of option name */ | |
72 | char *opt; /* Option character */ | |
73 | const char *ptr; /* Pointer into string */ | |
74 | int files; /* Number of files */ | |
75 | int verbose; /* Want verbose output? */ | |
76 | int status; /* Exit status */ | |
77 | int errors; /* Number of conformance errors */ | |
78 | int ppdversion; /* PPD spec version in PPD file */ | |
79 | ppd_status_t error; /* Status of ppdOpen*() */ | |
80 | int line; /* Line number for error */ | |
81 | ppd_file_t *ppd; /* PPD file record */ | |
82 | ppd_attr_t *attr; /* PPD attribute */ | |
83 | ppd_size_t *size; /* Size record */ | |
84 | ppd_group_t *group; /* UI group */ | |
85 | ppd_option_t *option; /* Standard UI option */ | |
86 | ppd_group_t *group2; /* UI group */ | |
87 | ppd_option_t *option2; /* Standard UI option */ | |
88 | ppd_choice_t *choice; /* Standard UI option choice */ | |
89 | static char *uis[] = { "BOOLEAN", "PICKONE", "PICKMANY" }; | |
90 | static char *sections[] = { "ANY", "DOCUMENT", "EXIT", | |
91 | "JCL", "PAGE", "PROLOG" }; | |
92 | ||
93 | ||
94 | setbuf(stdout, NULL); | |
95 | ||
96 | /* | |
97 | * Display PPD files for each file listed on the command-line... | |
98 | */ | |
99 | ||
100 | verbose = 0; | |
101 | ppd = NULL; | |
102 | files = 0; | |
103 | status = ERROR_NONE; | |
104 | ||
105 | for (i = 1; i < argc; i ++) | |
106 | if (argv[i][0] == '-' && argv[i][1]) | |
107 | { | |
108 | for (opt = argv[i] + 1; *opt; opt ++) | |
109 | switch (*opt) | |
110 | { | |
111 | case 'q' : | |
112 | if (verbose > 0) | |
113 | { | |
114 | fputs("cupstestppd: The -q option is incompatible with the -v option.\n", | |
115 | stderr); | |
116 | return (1); | |
117 | } | |
118 | ||
119 | verbose --; | |
120 | break; | |
121 | ||
122 | case 'v' : | |
123 | if (verbose < 0) | |
124 | { | |
125 | fputs("cupstestppd: The -v option is incompatible with the -q option.\n", | |
126 | stderr); | |
127 | return (1); | |
128 | } | |
129 | ||
130 | verbose ++; | |
131 | break; | |
132 | ||
133 | default : | |
134 | usage(); | |
135 | break; | |
136 | } | |
137 | } | |
138 | else | |
139 | { | |
140 | /* | |
141 | * Open the PPD file... | |
142 | */ | |
143 | ||
144 | if (files && verbose >= 0) | |
145 | putchar('\n'); | |
146 | ||
147 | files ++; | |
148 | ||
149 | if (argv[i][0] == '-') | |
150 | { | |
151 | /* | |
152 | * Read from stdin... | |
153 | */ | |
154 | ||
155 | if (verbose >= 0) | |
156 | printf("(stdin):"); | |
157 | ||
158 | ppd = ppdOpen(stdin); | |
159 | } | |
160 | else if (strlen(argv[i]) > 3 && | |
161 | !strcmp(argv[i] + strlen(argv[i]) - 3, ".gz")) | |
162 | { | |
163 | /* | |
164 | * Read from a gzipped file... | |
165 | */ | |
166 | ||
167 | char command[1024]; /* Command string */ | |
168 | FILE *gunzip; /* Pipe file */ | |
169 | ||
170 | ||
171 | if (verbose >= 0) | |
172 | printf("%s:", argv[i]); | |
173 | ||
174 | snprintf(command, sizeof(command), "gunzip -c \"%s\"", argv[i]); | |
175 | gunzip = popen(command, "r"); | |
176 | ppd = ppdOpen(gunzip); | |
177 | ||
178 | if (gunzip != NULL) | |
179 | pclose(gunzip); | |
180 | } | |
181 | else | |
182 | { | |
183 | /* | |
184 | * Read from a file... | |
185 | */ | |
186 | ||
187 | if (verbose >= 0) | |
188 | printf("%s:", argv[i]); | |
189 | ||
190 | ppd = ppdOpenFile(argv[i]); | |
191 | } | |
192 | ||
193 | if (ppd == NULL) | |
194 | { | |
195 | error = ppdLastError(&line); | |
196 | ||
197 | if (verbose >= 0) | |
198 | printf(" FAIL\n **FAIL** Unable to open PPD file - "); | |
199 | ||
200 | if (error <= PPD_ALLOC_ERROR) | |
201 | { | |
202 | status = ERROR_FILE_OPEN; | |
203 | ||
204 | if (verbose >= 0) | |
205 | puts(strerror(errno)); | |
206 | } | |
207 | else | |
208 | { | |
209 | status = ERROR_PPD_FORMAT; | |
210 | ||
211 | if (verbose >= 0) | |
212 | { | |
213 | printf("%s on line %d.\n", ppdErrorString(error), line); | |
214 | ||
215 | switch (error) | |
216 | { | |
217 | case PPD_MISSING_PPDADOBE4 : | |
218 | puts(" REF: Page 42, section 5.2."); | |
219 | break; | |
220 | case PPD_MISSING_VALUE : | |
221 | puts(" REF: Page 20, section 3.4."); | |
222 | break; | |
223 | case PPD_BAD_OPEN_GROUP : | |
224 | case PPD_NESTED_OPEN_GROUP : | |
225 | puts(" REF: Pages 45-46, section 5.2."); | |
226 | break; | |
227 | case PPD_BAD_OPEN_UI : | |
228 | case PPD_NESTED_OPEN_UI : | |
229 | puts(" REF: Pages 42-45, section 5.2."); | |
230 | break; | |
231 | case PPD_BAD_ORDER_DEPENDENCY : | |
232 | puts(" REF: Pages 48-49, section 5.2."); | |
233 | break; | |
234 | case PPD_BAD_UI_CONSTRAINTS : | |
235 | puts(" REF: Pages 52-54, section 5.2."); | |
236 | break; | |
237 | case PPD_MISSING_ASTERISK : | |
238 | puts(" REF: Page 15, section 3.2."); | |
239 | break; | |
240 | case PPD_LINE_TOO_LONG : | |
241 | puts(" REF: Page 15, section 3.1."); | |
242 | break; | |
243 | case PPD_ILLEGAL_CHARACTER : | |
244 | puts(" REF: Page 15, section 3.1."); | |
245 | break; | |
246 | case PPD_ILLEGAL_MAIN_KEYWORD : | |
247 | puts(" REF: Pages 16-17, section 3.2."); | |
248 | break; | |
249 | case PPD_ILLEGAL_OPTION_KEYWORD : | |
250 | puts(" REF: Page 19, section 3.3."); | |
251 | break; | |
252 | case PPD_ILLEGAL_TRANSLATION : | |
253 | puts(" REF: Page 27, section 3.5."); | |
254 | break; | |
255 | default : | |
256 | break; | |
257 | } | |
258 | } | |
259 | } | |
260 | ||
261 | continue; | |
262 | } | |
263 | ||
264 | /* | |
265 | * Show the header and then perform basic conformance tests (limited | |
266 | * only by what the CUPS PPD functions actually load...) | |
267 | */ | |
268 | ||
269 | errors = 0; | |
270 | ppdversion = 43; | |
271 | ||
272 | if (verbose > 0) | |
273 | puts("\n DETAILED CONFORMANCE TEST RESULTS"); | |
274 | ||
275 | if ((attr = ppdFindAttr(ppd, "FormatVersion", NULL)) != NULL && | |
276 | attr->value) | |
277 | ppdversion = (int)(10 * atof(attr->value) + 0.5); | |
278 | ||
279 | if (ppdFindAttr(ppd, "DefaultImageableArea", NULL) != NULL) | |
280 | { | |
281 | if (verbose > 0) | |
282 | puts(" PASS DefaultImageableArea"); | |
283 | } | |
284 | else | |
285 | { | |
286 | if (verbose >= 0) | |
287 | { | |
288 | if (!errors && !verbose) | |
289 | puts(" FAIL"); | |
290 | ||
291 | puts(" **FAIL** REQUIRED DefaultImageableArea"); | |
292 | puts(" REF: Page 102, section 5.15."); | |
293 | } | |
294 | ||
295 | errors ++; | |
296 | } | |
297 | ||
298 | if (ppdFindAttr(ppd, "DefaultPaperDimension", NULL) != NULL) | |
299 | { | |
300 | if (verbose > 0) | |
301 | puts(" PASS DefaultPaperDimension"); | |
302 | } | |
303 | else | |
304 | { | |
305 | if (verbose >= 0) | |
306 | { | |
307 | if (!errors && !verbose) | |
308 | puts(" FAIL"); | |
309 | ||
310 | puts(" **FAIL** REQUIRED DefaultPaperDimension"); | |
311 | puts(" REF: Page 103, section 5.15."); | |
312 | } | |
313 | ||
314 | errors ++; | |
315 | } | |
316 | ||
317 | for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++) | |
318 | for (k = 0, option = group->options; k < group->num_options; k ++, option ++) | |
319 | { | |
320 | /* | |
321 | * Verify that we have a default choice... | |
322 | */ | |
323 | ||
324 | if (option->defchoice[0]) | |
325 | { | |
326 | if (verbose > 0) | |
327 | printf(" PASS Default%s\n", option->keyword); | |
328 | } | |
329 | else | |
330 | { | |
331 | if (verbose >= 0) | |
332 | { | |
333 | if (!errors && !verbose) | |
334 | puts(" FAIL"); | |
335 | ||
336 | printf(" **FAIL** REQUIRED Default%s\n", option->keyword); | |
337 | puts(" REF: Page 40, section 4.5."); | |
338 | } | |
339 | ||
340 | errors ++; | |
341 | } | |
342 | } | |
343 | ||
344 | if (ppdFindAttr(ppd, "FileVersion", NULL) != NULL) | |
345 | { | |
346 | if (verbose > 0) | |
347 | puts(" PASS FileVersion"); | |
348 | } | |
349 | else | |
350 | { | |
351 | if (verbose >= 0) | |
352 | { | |
353 | if (!errors && !verbose) | |
354 | puts(" FAIL"); | |
355 | ||
356 | puts(" **FAIL** REQUIRED FileVersion"); | |
357 | puts(" REF: Page 56, section 5.3."); | |
358 | } | |
359 | ||
360 | errors ++; | |
361 | } | |
362 | ||
363 | if (ppdFindAttr(ppd, "FormatVersion", NULL) != NULL) | |
364 | { | |
365 | if (verbose > 0) | |
366 | puts(" PASS FormatVersion"); | |
367 | } | |
368 | else | |
369 | { | |
370 | if (verbose >= 0) | |
371 | { | |
372 | if (!errors && !verbose) | |
373 | puts(" FAIL"); | |
374 | ||
375 | puts(" **FAIL** REQUIRED FormatVersion"); | |
376 | puts(" REF: Page 56, section 5.3."); | |
377 | } | |
378 | ||
379 | errors ++; | |
380 | } | |
381 | ||
382 | if (ppd->lang_encoding != NULL) | |
383 | { | |
384 | if (verbose > 0) | |
385 | puts(" PASS LanguageEncoding"); | |
386 | } | |
387 | else if (ppdversion > 40) | |
388 | { | |
389 | if (verbose >= 0) | |
390 | { | |
391 | if (!errors && !verbose) | |
392 | puts(" FAIL"); | |
393 | ||
394 | puts(" **FAIL** REQUIRED LanguageEncoding"); | |
395 | puts(" REF: Pages 56-57, section 5.3."); | |
396 | } | |
397 | ||
398 | errors ++; | |
399 | } | |
400 | ||
401 | if (ppd->lang_version != NULL) | |
402 | { | |
403 | if (verbose > 0) | |
404 | puts(" PASS LanguageVersion"); | |
405 | } | |
406 | else | |
407 | { | |
408 | if (verbose >= 0) | |
409 | { | |
410 | if (!errors && !verbose) | |
411 | puts(" FAIL"); | |
412 | ||
413 | puts(" **FAIL** REQUIRED LanguageVersion"); | |
414 | puts(" REF: Pages 57-58, section 5.3."); | |
415 | } | |
416 | ||
417 | errors ++; | |
418 | } | |
419 | ||
420 | if (ppd->manufacturer != NULL) | |
421 | { | |
422 | if (verbose > 0) | |
423 | puts(" PASS Manufacturer"); | |
424 | } | |
425 | else if (ppdversion >= 43) | |
426 | { | |
427 | if (verbose >= 0) | |
428 | { | |
429 | if (!errors && !verbose) | |
430 | puts(" FAIL"); | |
431 | ||
432 | puts(" **FAIL** REQUIRED Manufacturer"); | |
433 | puts(" REF: Pages 58-59, section 5.3."); | |
434 | } | |
435 | ||
436 | errors ++; | |
437 | } | |
438 | ||
439 | if (ppd->modelname != NULL) | |
440 | { | |
441 | for (ptr = ppd->modelname; *ptr; ptr ++) | |
442 | if (!isalnum(*ptr) && !strchr(" ./-+", *ptr)) | |
443 | break; | |
444 | ||
445 | if (*ptr) | |
446 | { | |
447 | if (verbose >= 0) | |
448 | { | |
449 | if (!errors && !verbose) | |
450 | puts(" FAIL"); | |
451 | ||
452 | printf(" **FAIL** BAD ModelName - \"%c\" not allowed in string.\n", | |
453 | *ptr); | |
454 | puts(" REF: Pages 59-60, section 5.3."); | |
455 | } | |
456 | ||
457 | errors ++; | |
458 | } | |
459 | else if (verbose > 0) | |
460 | puts(" PASS ModelName"); | |
461 | } | |
462 | else | |
463 | { | |
464 | if (verbose >= 0) | |
465 | { | |
466 | if (!errors && !verbose) | |
467 | puts(" FAIL"); | |
468 | ||
469 | puts(" **FAIL** REQUIRED ModelName"); | |
470 | puts(" REF: Pages 59-60, section 5.3."); | |
471 | } | |
472 | ||
473 | errors ++; | |
474 | } | |
475 | ||
476 | if (ppd->nickname != NULL) | |
477 | { | |
478 | if (verbose > 0) | |
479 | puts(" PASS NickName"); | |
480 | } | |
481 | else | |
482 | { | |
483 | if (verbose >= 0) | |
484 | { | |
485 | if (!errors && !verbose) | |
486 | puts(" FAIL"); | |
487 | ||
488 | puts(" **FAIL** REQUIRED NickName"); | |
489 | puts(" REF: Page 60, section 5.3."); | |
490 | } | |
491 | ||
492 | errors ++; | |
493 | } | |
494 | ||
495 | if (ppdFindOption(ppd, "PageSize") != NULL) | |
496 | { | |
497 | if (verbose > 0) | |
498 | puts(" PASS PageSize"); | |
499 | } | |
500 | else | |
501 | { | |
502 | if (verbose >= 0) | |
503 | { | |
504 | if (!errors && !verbose) | |
505 | puts(" FAIL"); | |
506 | ||
507 | puts(" **FAIL** REQUIRED PageSize"); | |
508 | puts(" REF: Pages 99-100, section 5.14."); | |
509 | } | |
510 | ||
511 | errors ++; | |
512 | } | |
513 | ||
514 | if (ppdFindOption(ppd, "PageRegion") != NULL) | |
515 | { | |
516 | if (verbose > 0) | |
517 | puts(" PASS PageRegion"); | |
518 | } | |
519 | else | |
520 | { | |
521 | if (verbose >= 0) | |
522 | { | |
523 | if (!errors && !verbose) | |
524 | puts(" FAIL"); | |
525 | ||
526 | puts(" **FAIL** REQUIRED PageRegion"); | |
527 | puts(" REF: Page 100, section 5.14."); | |
528 | } | |
529 | ||
530 | errors ++; | |
531 | } | |
532 | ||
533 | if (ppd->pcfilename != NULL) | |
534 | { | |
535 | if (verbose > 0) | |
536 | puts(" PASS PCFileName"); | |
537 | } | |
538 | else | |
539 | { | |
540 | if (verbose >= 0) | |
541 | { | |
542 | if (!errors && !verbose) | |
543 | puts(" FAIL"); | |
544 | ||
545 | puts(" **FAIL** REQUIRED PCFileName"); | |
546 | puts(" REF: Pages 61-62, section 5.3."); | |
547 | } | |
548 | ||
549 | errors ++; | |
550 | } | |
551 | ||
552 | if (ppd->product != NULL) | |
553 | { | |
554 | if (ppd->product[0] != '(' || | |
555 | ppd->product[strlen(ppd->product) - 1] != ')') | |
556 | { | |
557 | if (verbose >= 0) | |
558 | { | |
559 | if (!errors && !verbose) | |
560 | puts(" FAIL"); | |
561 | ||
562 | puts(" **FAIL** BAD Product - not \"(string)\"."); | |
563 | puts(" REF: Page 62, section 5.3."); | |
564 | } | |
565 | ||
566 | errors ++; | |
567 | } | |
568 | else if (verbose > 0) | |
569 | puts(" PASS Product"); | |
570 | } | |
571 | else | |
572 | { | |
573 | if (verbose >= 0) | |
574 | { | |
575 | if (!errors && !verbose) | |
576 | puts(" FAIL"); | |
577 | ||
578 | puts(" **FAIL** REQUIRED Product"); | |
579 | puts(" REF: Page 62, section 5.3."); | |
580 | } | |
581 | ||
582 | errors ++; | |
583 | } | |
584 | ||
585 | if ((attr = ppdFindAttr(ppd, "PSVersion", NULL)) != NULL && | |
586 | attr->value != NULL) | |
587 | { | |
588 | char junkstr[255]; /* Temp string */ | |
589 | int junkint; /* Temp integer */ | |
590 | ||
591 | ||
592 | if (sscanf(attr->value, "(%[^)])%d", junkstr, &junkint) != 2) | |
593 | { | |
594 | if (verbose >= 0) | |
595 | { | |
596 | if (!errors && !verbose) | |
597 | puts(" FAIL"); | |
598 | ||
599 | puts(" **FAIL** BAD PSVersion - not \"(string) int\"."); | |
600 | puts(" REF: Pages 62-64, section 5.3."); | |
601 | } | |
602 | ||
603 | errors ++; | |
604 | } | |
605 | else if (verbose > 0) | |
606 | puts(" PASS PSVersion"); | |
607 | } | |
608 | else | |
609 | { | |
610 | if (verbose >= 0) | |
611 | { | |
612 | if (!errors && !verbose) | |
613 | puts(" FAIL"); | |
614 | ||
615 | puts(" **FAIL** REQUIRED PSVersion"); | |
616 | puts(" REF: Pages 62-64, section 5.3."); | |
617 | } | |
618 | ||
619 | errors ++; | |
620 | } | |
621 | ||
622 | if (ppd->shortnickname != NULL) | |
623 | { | |
624 | if (strlen(ppd->shortnickname) > 31) | |
625 | { | |
626 | if (verbose >= 0) | |
627 | { | |
628 | if (!errors && !verbose) | |
629 | puts(" FAIL"); | |
630 | ||
631 | puts(" **FAIL** BAD ShortNickName - longer than 31 chars."); | |
632 | puts(" REF: Pages 64-65, section 5.3."); | |
633 | } | |
634 | ||
635 | errors ++; | |
636 | } | |
637 | else if (verbose > 0) | |
638 | puts(" PASS ShortNickName"); | |
639 | } | |
640 | else if (ppdversion >= 43) | |
641 | { | |
642 | if (verbose >= 0) | |
643 | { | |
644 | if (!errors && !verbose) | |
645 | puts(" FAIL"); | |
646 | ||
647 | puts(" **FAIL** REQUIRED ShortNickName"); | |
648 | puts(" REF: Page 64-65, section 5.3."); | |
649 | } | |
650 | ||
651 | errors ++; | |
652 | } | |
653 | ||
654 | if (errors) | |
655 | status = ERROR_CONFORMANCE; | |
656 | else if (!verbose) | |
657 | puts(" PASS"); | |
658 | ||
659 | if (verbose >= 0) | |
660 | { | |
661 | if (ppdversion < 43) | |
662 | { | |
663 | printf(" WARN Obsolete PPD version %.1f!\n", | |
664 | 0.1f * ppdversion); | |
665 | puts(" REF: Page 42, section 5.2."); | |
666 | } | |
667 | ||
668 | if (!ppd->lang_encoding && ppdversion < 41) | |
669 | { | |
670 | puts(" WARN LanguageEncoding required by PPD 4.3 spec."); | |
671 | puts(" REF: Pages 56-57, section 5.3."); | |
672 | } | |
673 | ||
674 | if (!ppd->manufacturer && ppdversion < 43) | |
675 | { | |
676 | puts(" WARN Manufacturer required by PPD 4.3 spec."); | |
677 | puts(" REF: Pages 58-59, section 5.3."); | |
678 | } | |
679 | ||
680 | /* | |
681 | * Treat a PCFileName attribute longer than 12 characters as | |
682 | * a warning and not a hard error... | |
683 | */ | |
684 | ||
685 | if (ppd->pcfilename && strlen(ppd->pcfilename) > 12) | |
686 | { | |
687 | puts(" WARN PCFileName longer than 8.3 in violation of PPD spec."); | |
688 | puts(" REF: Pages 61-62, section 5.3."); | |
689 | } | |
690 | ||
691 | if (!ppd->shortnickname && ppdversion < 43) | |
692 | { | |
693 | puts(" WARN ShortNickName required by PPD 4.3 spec."); | |
694 | puts(" REF: Pages 64-65, section 5.3."); | |
695 | } | |
696 | ||
697 | /* | |
698 | * Check for options with a common prefix, e.g. Duplex and Duplexer, | |
699 | * which are errors according to the spec but won't cause problems | |
700 | * with CUPS specifically... | |
701 | */ | |
702 | ||
703 | for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++) | |
704 | for (k = 0, option = group->options; k < group->num_options; k ++, option ++) | |
705 | { | |
706 | len = strlen(option->keyword); | |
707 | ||
708 | for (m = 0, group2 = ppd->groups; | |
709 | m < ppd->num_groups; | |
710 | m ++, group2 ++) | |
711 | for (n = 0, option2 = group2->options; | |
712 | n < group2->num_options; | |
713 | n ++, option2 ++) | |
714 | if (option != option2 && | |
715 | len < strlen(option2->keyword) && | |
716 | !strncmp(option->keyword, option2->keyword, len)) | |
717 | { | |
718 | printf(" WARN %s shares a common prefix with %s\n", | |
719 | option->keyword, option2->keyword); | |
720 | puts(" REF: Page 15, section 3.2."); | |
721 | } | |
722 | } | |
723 | } | |
724 | ||
725 | if (verbose > 0) | |
726 | { | |
727 | if (errors) | |
728 | printf(" %d ERROR%s FOUND\n", errors, errors == 1 ? "" : "S"); | |
729 | else | |
730 | puts(" NO ERRORS FOUND"); | |
731 | } | |
732 | ||
733 | ||
734 | /* | |
735 | * Then list the options, if "-v" was provided... | |
736 | */ | |
737 | ||
738 | if (verbose > 1) | |
739 | { | |
740 | puts(""); | |
741 | printf(" language_level = %d\n", ppd->language_level); | |
742 | printf(" color_device = %s\n", ppd->color_device ? "TRUE" : "FALSE"); | |
743 | printf(" variable_sizes = %s\n", ppd->variable_sizes ? "TRUE" : "FALSE"); | |
744 | printf(" landscape = %d\n", ppd->landscape); | |
745 | ||
746 | switch (ppd->colorspace) | |
747 | { | |
748 | case PPD_CS_CMYK : | |
749 | puts(" colorspace = PPD_CS_CMYK"); | |
750 | break; | |
751 | case PPD_CS_CMY : | |
752 | puts(" colorspace = PPD_CS_CMY"); | |
753 | break; | |
754 | case PPD_CS_GRAY : | |
755 | puts(" colorspace = PPD_CS_GRAY"); | |
756 | break; | |
757 | case PPD_CS_RGB : | |
758 | puts(" colorspace = PPD_CS_RGB"); | |
759 | break; | |
760 | default : | |
761 | puts(" colorspace = <unknown>"); | |
762 | break; | |
763 | } | |
764 | ||
765 | printf(" num_emulations = %d\n", ppd->num_emulations); | |
766 | for (j = 0; j < ppd->num_emulations; j ++) | |
767 | printf(" emulations[%d] = %s\n", j, ppd->emulations[j].name); | |
768 | ||
769 | printf(" lang_encoding = %s\n", ppd->lang_encoding); | |
770 | printf(" lang_version = %s\n", ppd->lang_version); | |
771 | printf(" modelname = %s\n", ppd->modelname); | |
772 | printf(" ttrasterizer = %s\n", | |
773 | ppd->ttrasterizer == NULL ? "None" : ppd->ttrasterizer); | |
774 | printf(" manufacturer = %s\n", ppd->manufacturer); | |
775 | printf(" product = %s\n", ppd->product); | |
776 | printf(" nickname = %s\n", ppd->nickname); | |
777 | printf(" shortnickname = %s\n", ppd->shortnickname); | |
778 | printf(" patches = %d bytes\n", | |
779 | ppd->patches == NULL ? 0 : (int)strlen(ppd->patches)); | |
780 | ||
781 | printf(" num_groups = %d\n", ppd->num_groups); | |
782 | for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++) | |
783 | { | |
784 | printf(" group[%d] = %s\n", j, group->text); | |
785 | ||
786 | for (k = 0, option = group->options; k < group->num_options; k ++, option ++) | |
787 | { | |
788 | printf(" options[%d] = %s (%s) %s %s %.0f (%d choices)\n", k, | |
789 | option->keyword, option->text, uis[option->ui], | |
790 | sections[option->section], option->order, | |
791 | option->num_choices); | |
792 | ||
793 | if (strcmp(option->keyword, "PageSize") == 0 || | |
794 | strcmp(option->keyword, "PageRegion") == 0) | |
795 | { | |
796 | for (m = option->num_choices, choice = option->choices; | |
797 | m > 0; | |
798 | m --, choice ++) | |
799 | { | |
800 | size = ppdPageSize(ppd, choice->choice); | |
801 | ||
802 | if (size == NULL) | |
803 | printf(" %s (%s) = ERROR", choice->choice, choice->text); | |
804 | else | |
805 | printf(" %s (%s) = %.2fx%.2fin (%.1f,%.1f,%.1f,%.1f)", choice->choice, | |
806 | choice->text, size->width / 72.0, size->length / 72.0, | |
807 | size->left / 72.0, size->bottom / 72.0, | |
808 | size->right / 72.0, size->top / 72.0); | |
809 | ||
810 | if (strcmp(option->defchoice, choice->choice) == 0) | |
811 | puts(" *"); | |
812 | else | |
813 | putchar('\n'); | |
814 | } | |
815 | } | |
816 | else | |
817 | { | |
818 | for (m = option->num_choices, choice = option->choices; | |
819 | m > 0; | |
820 | m --, choice ++) | |
821 | { | |
822 | printf(" %s (%s)", choice->choice, choice->text); | |
823 | ||
824 | if (strcmp(option->defchoice, choice->choice) == 0) | |
825 | puts(" *"); | |
826 | else | |
827 | putchar('\n'); | |
828 | } | |
829 | } | |
830 | } | |
831 | } | |
832 | ||
833 | printf(" num_profiles = %d\n", ppd->num_profiles); | |
834 | for (j = 0; j < ppd->num_profiles; j ++) | |
835 | printf(" profiles[%d] = %s/%s %.3f %.3f [ %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f ]\n", | |
836 | j, ppd->profiles[j].resolution, ppd->profiles[j].media_type, | |
837 | ppd->profiles[j].gamma, ppd->profiles[j].density, | |
838 | ppd->profiles[j].matrix[0][0], ppd->profiles[j].matrix[0][1], | |
839 | ppd->profiles[j].matrix[0][2], ppd->profiles[j].matrix[1][0], | |
840 | ppd->profiles[j].matrix[1][1], ppd->profiles[j].matrix[1][2], | |
841 | ppd->profiles[j].matrix[2][0], ppd->profiles[j].matrix[2][1], | |
842 | ppd->profiles[j].matrix[2][2]); | |
843 | ||
844 | printf(" num_fonts = %d\n", ppd->num_fonts); | |
845 | for (j = 0; j < ppd->num_fonts; j ++) | |
846 | printf(" fonts[%d] = %s\n", j, ppd->fonts[j]); | |
847 | } | |
848 | ||
849 | ppdClose(ppd); | |
850 | } | |
851 | ||
852 | if (!files) | |
853 | usage(); | |
854 | ||
855 | return (status); | |
856 | } | |
857 | ||
858 | ||
859 | /* | |
860 | * 'usage()' - Show program usage... | |
861 | */ | |
862 | ||
863 | void | |
864 | usage(void) | |
865 | { | |
866 | puts("Usage: cupstestppd [-q] [-v[v]] filename1.ppd[.gz] [... filenameN.ppd[.gz]]"); | |
867 | puts(" program | cupstestppd [-q] [-v[v]] -"); | |
868 | ||
869 | exit(ERROR_USAGE); | |
870 | } | |
871 | ||
872 | ||
873 | /* | |
874 | * End of "$Id: cupstestppd.c,v 1.20 2003/02/28 21:06:09 mike Exp $". | |
875 | */ |