]> git.ipfire.org Git - thirdparty/cups.git/blame - systemv/cupstestppd.c
Get rid of compiler warning.
[thirdparty/cups.git] / systemv / cupstestppd.c
CommitLineData
4b0b2cf9 1/*
f0e7bfbd 2 * "$Id: cupstestppd.c,v 1.20 2003/02/28 21:06:09 mike Exp $"
4b0b2cf9 3 *
4 * PPD test program for the Common UNIX Printing System (CUPS).
5 *
997fbfa7 6 * Copyright 1997-2003 by Easy Software Products, all rights reserved.
4b0b2cf9 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 *
f249be22 30 * main() - Main entry for test program.
31 * usage() - Show program usage...
4b0b2cf9 32 */
33
34/*
35 * Include necessary headers...
36 */
37
38#include <cups/cups.h>
39#include <cups/string.h>
40#include <errno.h>
f249be22 41#include <stdlib.h>
4b0b2cf9 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
f249be22 55/*
56 * Local functions...
57 */
58
59void usage(void);
60
61
4b0b2cf9 62/*
63 * 'main()' - Main entry for test program.
64 */
65
66int /* O - Exit status */
67main(int argc, /* I - Number of command-line arguments */
68 char *argv[]) /* I - Command-line arguments */
69{
5c61431a 70 int i, j, k, m, n; /* Looping vars */
71 int len; /* Length of option name */
f249be22 72 char *opt; /* Option character */
73 const char *ptr; /* Pointer into string */
1391e7cb 74 int files; /* Number of files */
4b0b2cf9 75 int verbose; /* Want verbose output? */
76 int status; /* Exit status */
77 int errors; /* Number of conformance errors */
f9d01894 78 int ppdversion; /* PPD spec version in PPD file */
1391e7cb 79 ppd_status_t error; /* Status of ppdOpen*() */
80 int line; /* Line number for error */
4b0b2cf9 81 ppd_file_t *ppd; /* PPD file record */
f0e7bfbd 82 ppd_attr_t *attr; /* PPD attribute */
4b0b2cf9 83 ppd_size_t *size; /* Size record */
84 ppd_group_t *group; /* UI group */
85 ppd_option_t *option; /* Standard UI option */
5c61431a 86 ppd_group_t *group2; /* UI group */
87 ppd_option_t *option2; /* Standard UI option */
4b0b2cf9 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;
1391e7cb 102 files = 0;
4b0b2cf9 103 status = ERROR_NONE;
104
105 for (i = 1; i < argc; i ++)
f249be22 106 if (argv[i][0] == '-' && argv[i][1])
77f83108 107 {
f249be22 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 }
77f83108 118
f249be22 119 verbose --;
120 break;
77f83108 121
f249be22 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 }
4b0b2cf9 137 }
138 else
139 {
140 /*
141 * Open the PPD file...
142 */
143
e7848a5b 144 if (files && verbose >= 0)
5f7c946a 145 putchar('\n');
146
1391e7cb 147 files ++;
148
4b0b2cf9 149 if (argv[i][0] == '-')
150 {
151 /*
152 * Read from stdin...
153 */
154
77f83108 155 if (verbose >= 0)
f249be22 156 printf("(stdin):");
4b0b2cf9 157
158 ppd = ppdOpen(stdin);
159 }
f249be22 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
ad10470c 174 snprintf(command, sizeof(command), "gunzip -c \"%s\"", argv[i]);
f249be22 175 gunzip = popen(command, "r");
176 ppd = ppdOpen(gunzip);
177
178 if (gunzip != NULL)
179 pclose(gunzip);
180 }
4b0b2cf9 181 else
182 {
183 /*
184 * Read from a file...
185 */
186
77f83108 187 if (verbose >= 0)
f249be22 188 printf("%s:", argv[i]);
4b0b2cf9 189
190 ppd = ppdOpenFile(argv[i]);
191 }
192
193 if (ppd == NULL)
194 {
1391e7cb 195 error = ppdLastError(&line);
196
8b952de6 197 if (verbose >= 0)
198 printf(" FAIL\n **FAIL** Unable to open PPD file - ");
f69d5f26 199
621b77a6 200 if (error <= PPD_ALLOC_ERROR)
4b0b2cf9 201 {
202 status = ERROR_FILE_OPEN;
77f83108 203
5f7c946a 204 if (verbose >= 0)
f69d5f26 205 puts(strerror(errno));
4b0b2cf9 206 }
207 else
208 {
209 status = ERROR_PPD_FORMAT;
77f83108 210
5f7c946a 211 if (verbose >= 0)
212 {
f69d5f26 213 printf("%s on line %d.\n", ppdErrorString(error), line);
5f7c946a 214
215 switch (error)
216 {
217 case PPD_MISSING_PPDADOBE4 :
8e524f97 218 puts(" REF: Page 42, section 5.2.");
5f7c946a 219 break;
220 case PPD_MISSING_VALUE :
8e524f97 221 puts(" REF: Page 20, section 3.4.");
5f7c946a 222 break;
223 case PPD_BAD_OPEN_GROUP :
224 case PPD_NESTED_OPEN_GROUP :
8e524f97 225 puts(" REF: Pages 45-46, section 5.2.");
5f7c946a 226 break;
227 case PPD_BAD_OPEN_UI :
228 case PPD_NESTED_OPEN_UI :
8e524f97 229 puts(" REF: Pages 42-45, section 5.2.");
5f7c946a 230 break;
231 case PPD_BAD_ORDER_DEPENDENCY :
8e524f97 232 puts(" REF: Pages 48-49, section 5.2.");
5f7c946a 233 break;
234 case PPD_BAD_UI_CONSTRAINTS :
8e524f97 235 puts(" REF: Pages 52-54, section 5.2.");
5f7c946a 236 break;
237 case PPD_MISSING_ASTERISK :
8e524f97 238 puts(" REF: Page 15, section 3.2.");
5f7c946a 239 break;
240 case PPD_LINE_TOO_LONG :
8e524f97 241 puts(" REF: Page 15, section 3.1.");
5f7c946a 242 break;
243 case PPD_ILLEGAL_CHARACTER :
8e524f97 244 puts(" REF: Page 15, section 3.1.");
5f7c946a 245 break;
246 case PPD_ILLEGAL_MAIN_KEYWORD :
8e524f97 247 puts(" REF: Pages 16-17, section 3.2.");
5f7c946a 248 break;
249 case PPD_ILLEGAL_OPTION_KEYWORD :
8e524f97 250 puts(" REF: Page 19, section 3.3.");
5f7c946a 251 break;
252 case PPD_ILLEGAL_TRANSLATION :
8e524f97 253 puts(" REF: Page 27, section 3.5.");
5f7c946a 254 break;
255 default :
256 break;
257 }
258 }
4b0b2cf9 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
f9d01894 269 errors = 0;
270 ppdversion = 43;
5f7c946a 271
272 if (verbose > 0)
273 puts("\n DETAILED CONFORMANCE TEST RESULTS");
274
f0e7bfbd 275 if ((attr = ppdFindAttr(ppd, "FormatVersion", NULL)) != NULL &&
276 attr->value)
277 ppdversion = (int)(10 * atof(attr->value) + 0.5);
f9d01894 278
f249be22 279 if (ppdFindAttr(ppd, "DefaultImageableArea", NULL) != NULL)
280 {
281 if (verbose > 0)
282 puts(" PASS DefaultImageableArea");
283 }
284 else
285 {
5f7c946a 286 if (verbose >= 0)
287 {
288 if (!errors && !verbose)
289 puts(" FAIL");
f249be22 290
f249be22 291 puts(" **FAIL** REQUIRED DefaultImageableArea");
5f7c946a 292 puts(" REF: Page 102, section 5.15.");
293 }
294
295 errors ++;
f249be22 296 }
297
298 if (ppdFindAttr(ppd, "DefaultPaperDimension", NULL) != NULL)
299 {
300 if (verbose > 0)
301 puts(" PASS DefaultPaperDimension");
302 }
303 else
304 {
5f7c946a 305 if (verbose >= 0)
306 {
307 if (!errors && !verbose)
308 puts(" FAIL");
f249be22 309
f249be22 310 puts(" **FAIL** REQUIRED DefaultPaperDimension");
5f7c946a 311 puts(" REF: Page 103, section 5.15.");
312 }
313
314 errors ++;
f249be22 315 }
316
4b0b2cf9 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 ++)
5c61431a 319 {
320 /*
321 * Verify that we have a default choice...
322 */
323
4b0b2cf9 324 if (option->defchoice[0])
325 {
f249be22 326 if (verbose > 0)
77f83108 327 printf(" PASS Default%s\n", option->keyword);
4b0b2cf9 328 }
329 else
330 {
5f7c946a 331 if (verbose >= 0)
332 {
333 if (!errors && !verbose)
334 puts(" FAIL");
77f83108 335
77f83108 336 printf(" **FAIL** REQUIRED Default%s\n", option->keyword);
5f7c946a 337 puts(" REF: Page 40, section 4.5.");
338 }
339
340 errors ++;
4b0b2cf9 341 }
5c61431a 342 }
343
f249be22 344 if (ppdFindAttr(ppd, "FileVersion", NULL) != NULL)
77f83108 345 {
f249be22 346 if (verbose > 0)
347 puts(" PASS FileVersion");
77f83108 348 }
4b0b2cf9 349 else
350 {
5f7c946a 351 if (verbose >= 0)
352 {
353 if (!errors && !verbose)
354 puts(" FAIL");
77f83108 355
f249be22 356 puts(" **FAIL** REQUIRED FileVersion");
5f7c946a 357 puts(" REF: Page 56, section 5.3.");
358 }
359
360 errors ++;
f249be22 361 }
362
363 if (ppdFindAttr(ppd, "FormatVersion", NULL) != NULL)
364 {
365 if (verbose > 0)
366 puts(" PASS FormatVersion");
367 }
368 else
369 {
5f7c946a 370 if (verbose >= 0)
371 {
372 if (!errors && !verbose)
373 puts(" FAIL");
f249be22 374
f249be22 375 puts(" **FAIL** REQUIRED FormatVersion");
5f7c946a 376 puts(" REF: Page 56, section 5.3.");
377 }
378
379 errors ++;
4b0b2cf9 380 }
381
382 if (ppd->lang_encoding != NULL)
77f83108 383 {
f249be22 384 if (verbose > 0)
77f83108 385 puts(" PASS LanguageEncoding");
386 }
5f7c946a 387 else if (ppdversion > 40)
4b0b2cf9 388 {
5f7c946a 389 if (verbose >= 0)
390 {
391 if (!errors && !verbose)
392 puts(" FAIL");
77f83108 393
77f83108 394 puts(" **FAIL** REQUIRED LanguageEncoding");
5f7c946a 395 puts(" REF: Pages 56-57, section 5.3.");
396 }
397
398 errors ++;
4b0b2cf9 399 }
400
401 if (ppd->lang_version != NULL)
77f83108 402 {
f249be22 403 if (verbose > 0)
77f83108 404 puts(" PASS LanguageVersion");
405 }
4b0b2cf9 406 else
407 {
5f7c946a 408 if (verbose >= 0)
409 {
410 if (!errors && !verbose)
411 puts(" FAIL");
77f83108 412
77f83108 413 puts(" **FAIL** REQUIRED LanguageVersion");
5f7c946a 414 puts(" REF: Pages 57-58, section 5.3.");
415 }
416
417 errors ++;
4b0b2cf9 418 }
419
420 if (ppd->manufacturer != NULL)
77f83108 421 {
f249be22 422 if (verbose > 0)
77f83108 423 puts(" PASS Manufacturer");
424 }
5f7c946a 425 else if (ppdversion >= 43)
4b0b2cf9 426 {
5f7c946a 427 if (verbose >= 0)
428 {
429 if (!errors && !verbose)
430 puts(" FAIL");
77f83108 431
77f83108 432 puts(" **FAIL** REQUIRED Manufacturer");
5f7c946a 433 puts(" REF: Pages 58-59, section 5.3.");
434 }
435
436 errors ++;
4b0b2cf9 437 }
438
439 if (ppd->modelname != NULL)
77f83108 440 {
f249be22 441 for (ptr = ppd->modelname; *ptr; ptr ++)
442 if (!isalnum(*ptr) && !strchr(" ./-+", *ptr))
443 break;
444
445 if (*ptr)
446 {
5f7c946a 447 if (verbose >= 0)
448 {
449 if (!errors && !verbose)
450 puts(" FAIL");
f249be22 451
5f7c946a 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 ++;
f249be22 458 }
459 else if (verbose > 0)
77f83108 460 puts(" PASS ModelName");
461 }
4b0b2cf9 462 else
463 {
5f7c946a 464 if (verbose >= 0)
465 {
466 if (!errors && !verbose)
467 puts(" FAIL");
77f83108 468
77f83108 469 puts(" **FAIL** REQUIRED ModelName");
5f7c946a 470 puts(" REF: Pages 59-60, section 5.3.");
471 }
472
473 errors ++;
4b0b2cf9 474 }
475
476 if (ppd->nickname != NULL)
77f83108 477 {
f249be22 478 if (verbose > 0)
77f83108 479 puts(" PASS NickName");
480 }
4b0b2cf9 481 else
482 {
5f7c946a 483 if (verbose >= 0)
484 {
485 if (!errors && !verbose)
486 puts(" FAIL");
77f83108 487
77f83108 488 puts(" **FAIL** REQUIRED NickName");
5f7c946a 489 puts(" REF: Page 60, section 5.3.");
490 }
491
492 errors ++;
4b0b2cf9 493 }
494
495 if (ppdFindOption(ppd, "PageSize") != NULL)
77f83108 496 {
f249be22 497 if (verbose > 0)
77f83108 498 puts(" PASS PageSize");
499 }
4b0b2cf9 500 else
501 {
5f7c946a 502 if (verbose >= 0)
503 {
504 if (!errors && !verbose)
505 puts(" FAIL");
77f83108 506
77f83108 507 puts(" **FAIL** REQUIRED PageSize");
5f7c946a 508 puts(" REF: Pages 99-100, section 5.14.");
509 }
510
511 errors ++;
4b0b2cf9 512 }
513
514 if (ppdFindOption(ppd, "PageRegion") != NULL)
77f83108 515 {
f249be22 516 if (verbose > 0)
77f83108 517 puts(" PASS PageRegion");
518 }
4b0b2cf9 519 else
520 {
5f7c946a 521 if (verbose >= 0)
522 {
523 if (!errors && !verbose)
524 puts(" FAIL");
77f83108 525
77f83108 526 puts(" **FAIL** REQUIRED PageRegion");
5f7c946a 527 puts(" REF: Page 100, section 5.14.");
528 }
529
530 errors ++;
4b0b2cf9 531 }
532
23f5e659 533 if (ppd->pcfilename != NULL)
534 {
f249be22 535 if (verbose > 0)
5f7c946a 536 puts(" PASS PCFileName");
23f5e659 537 }
538 else
539 {
5f7c946a 540 if (verbose >= 0)
541 {
542 if (!errors && !verbose)
543 puts(" FAIL");
23f5e659 544
23f5e659 545 puts(" **FAIL** REQUIRED PCFileName");
5f7c946a 546 puts(" REF: Pages 61-62, section 5.3.");
547 }
548
549 errors ++;
23f5e659 550 }
551
4b0b2cf9 552 if (ppd->product != NULL)
77f83108 553 {
f249be22 554 if (ppd->product[0] != '(' ||
555 ppd->product[strlen(ppd->product) - 1] != ')')
556 {
5f7c946a 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 }
f249be22 565
5f7c946a 566 errors ++;
f249be22 567 }
568 else if (verbose > 0)
77f83108 569 puts(" PASS Product");
570 }
4b0b2cf9 571 else
572 {
5f7c946a 573 if (verbose >= 0)
574 {
575 if (!errors && !verbose)
576 puts(" FAIL");
77f83108 577
77f83108 578 puts(" **FAIL** REQUIRED Product");
5f7c946a 579 puts(" REF: Page 62, section 5.3.");
580 }
581
582 errors ++;
4b0b2cf9 583 }
584
f0e7bfbd 585 if ((attr = ppdFindAttr(ppd, "PSVersion", NULL)) != NULL &&
586 attr->value != NULL)
f249be22 587 {
588 char junkstr[255]; /* Temp string */
589 int junkint; /* Temp integer */
590
591
f0e7bfbd 592 if (sscanf(attr->value, "(%[^)])%d", junkstr, &junkint) != 2)
f249be22 593 {
5f7c946a 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 }
f249be22 602
5f7c946a 603 errors ++;
f249be22 604 }
605 else if (verbose > 0)
606 puts(" PASS PSVersion");
607 }
608 else
609 {
5f7c946a 610 if (verbose >= 0)
611 {
612 if (!errors && !verbose)
613 puts(" FAIL");
f249be22 614
f249be22 615 puts(" **FAIL** REQUIRED PSVersion");
5f7c946a 616 puts(" REF: Pages 62-64, section 5.3.");
617 }
618
619 errors ++;
f249be22 620 }
621
4b0b2cf9 622 if (ppd->shortnickname != NULL)
77f83108 623 {
f249be22 624 if (strlen(ppd->shortnickname) > 31)
625 {
5f7c946a 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 }
f249be22 634
5f7c946a 635 errors ++;
f249be22 636 }
637 else if (verbose > 0)
77f83108 638 puts(" PASS ShortNickName");
639 }
5f7c946a 640 else if (ppdversion >= 43)
f9d01894 641 {
5f7c946a 642 if (verbose >= 0)
643 {
644 if (!errors && !verbose)
645 puts(" FAIL");
77f83108 646
77f83108 647 puts(" **FAIL** REQUIRED ShortNickName");
5f7c946a 648 puts(" REF: Page 64-65, section 5.3.");
649 }
650
651 errors ++;
4b0b2cf9 652 }
653
654 if (errors)
5f7c946a 655 status = ERROR_CONFORMANCE;
656 else if (!verbose)
657 puts(" PASS");
658
659 if (verbose >= 0)
4b0b2cf9 660 {
5f7c946a 661 if (ppdversion < 43)
662 {
f0e7bfbd 663 printf(" WARN Obsolete PPD version %.1f!\n",
664 0.1f * ppdversion);
5f7c946a 665 puts(" REF: Page 42, section 5.2.");
666 }
77f83108 667
6fab737b 668 if (!ppd->lang_encoding && ppdversion < 41)
5f7c946a 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 }
b8f94d24 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 }
4b0b2cf9 723 }
724
f249be22 725 if (verbose > 0)
5f7c946a 726 {
727 if (errors)
728 printf(" %d ERROR%s FOUND\n", errors, errors == 1 ? "" : "S");
729 else
730 puts(" NO ERRORS FOUND");
731 }
732
4b0b2cf9 733
734 /*
735 * Then list the options, if "-v" was provided...
736 */
737
f249be22 738 if (verbose > 1)
4b0b2cf9 739 {
740 puts("");
4b0b2cf9 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
f249be22 852 if (!files)
853 usage();
854
855 return (status);
856}
857
858
859/*
860 * 'usage()' - Show program usage...
861 */
862
863void
864usage(void)
865{
866 puts("Usage: cupstestppd [-q] [-v[v]] filename1.ppd[.gz] [... filenameN.ppd[.gz]]");
867 puts(" program | cupstestppd [-q] [-v[v]] -");
4b0b2cf9 868
f249be22 869 exit(ERROR_USAGE);
4b0b2cf9 870}
871
872
873/*
f0e7bfbd 874 * End of "$Id: cupstestppd.c,v 1.20 2003/02/28 21:06:09 mike Exp $".
4b0b2cf9 875 */