]> git.ipfire.org Git - thirdparty/cups.git/blob - systemv/cupstestppd.c
Load cups into easysw/current.
[thirdparty/cups.git] / systemv / cupstestppd.c
1 /*
2 * "$Id: cupstestppd.c 5422 2006-04-18 15:16:00Z mike $"
3 *
4 * PPD test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 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 USA
19 *
20 * Voice: (301) 373-9600
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 * show_conflicts() - Show option conflicts in a PPD file.
32 * usage() - Show program usage...
33 */
34
35 /*
36 * Include necessary headers...
37 */
38
39 #include <cups/string.h>
40 #include <cups/cups.h>
41 #include <cups/i18n.h>
42 #include <errno.h>
43 #include <stdlib.h>
44
45
46 /*
47 * Error codes...
48 */
49
50 enum
51 {
52 ERROR_NONE = 0,
53 ERROR_USAGE,
54 ERROR_FILE_OPEN,
55 ERROR_PPD_FORMAT,
56 ERROR_CONFORMANCE
57 };
58
59
60 /*
61 * Line endings...
62 */
63
64 enum
65 {
66 EOL_NONE = 0,
67 EOL_CR,
68 EOL_LF,
69 EOL_CRLF
70 };
71
72
73 /*
74 * Local functions...
75 */
76
77 void check_basics(const char *filename);
78 void show_conflicts(ppd_file_t *ppd);
79 void usage(void);
80
81
82 /*
83 * 'main()' - Main entry for test program.
84 */
85
86 int /* O - Exit status */
87 main(int argc, /* I - Number of command-line arguments */
88 char *argv[]) /* I - Command-line arguments */
89 {
90 int i, j, k, m, n; /* Looping vars */
91 int len; /* Length of option name */
92 char *opt; /* Option character */
93 const char *ptr; /* Pointer into string */
94 int files; /* Number of files */
95 int verbose; /* Want verbose output? */
96 int status; /* Exit status */
97 int errors; /* Number of conformance errors */
98 int ppdversion; /* PPD spec version in PPD file */
99 ppd_status_t error; /* Status of ppdOpen*() */
100 int line; /* Line number for error */
101 int xdpi, /* X resolution */
102 ydpi; /* Y resolution */
103 ppd_file_t *ppd; /* PPD file record */
104 ppd_attr_t *attr; /* PPD attribute */
105 ppd_size_t *size; /* Size record */
106 ppd_group_t *group; /* UI group */
107 ppd_option_t *option; /* Standard UI option */
108 ppd_group_t *group2; /* UI group */
109 ppd_option_t *option2; /* Standard UI option */
110 ppd_choice_t *choice; /* Standard UI option choice */
111 static char *uis[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
112 static char *sections[] = { "ANY", "DOCUMENT", "EXIT",
113 "JCL", "PAGE", "PROLOG" };
114
115
116 /*
117 * Display PPD files for each file listed on the command-line...
118 */
119
120 ppdSetConformance(PPD_CONFORM_STRICT);
121
122 verbose = 0;
123 ppd = NULL;
124 files = 0;
125 status = ERROR_NONE;
126
127 for (i = 1; i < argc; i ++)
128 if (argv[i][0] == '-' && argv[i][1])
129 {
130 for (opt = argv[i] + 1; *opt; opt ++)
131 switch (*opt)
132 {
133 case 'q' : /* Quiet mode */
134 if (verbose > 0)
135 {
136 _cupsLangPuts(stderr,
137 _("cupstestppd: The -q option is incompatible "
138 "with the -v option.\n"));
139 return (1);
140 }
141
142 verbose --;
143 break;
144
145 case 'r' : /* Relaxed mode */
146 ppdSetConformance(PPD_CONFORM_RELAXED);
147 break;
148
149 case 'v' : /* Verbose mode */
150 if (verbose < 0)
151 {
152 _cupsLangPuts(stderr,
153 _("cupstestppd: The -v option is incompatible "
154 "with the -q option.\n"));
155 return (1);
156 }
157
158 verbose ++;
159 break;
160
161 default :
162 usage();
163 break;
164 }
165 }
166 else
167 {
168 /*
169 * Open the PPD file...
170 */
171
172 if (files && verbose >= 0)
173 _cupsLangPuts(stdout, "\n");
174
175 files ++;
176
177 if (argv[i][0] == '-')
178 {
179 /*
180 * Read from stdin...
181 */
182
183 if (verbose >= 0)
184 printf("(stdin):");
185
186 ppd = ppdOpen(stdin);
187 }
188 else
189 {
190 /*
191 * Read from a file...
192 */
193
194 if (verbose >= 0)
195 printf("%s:", argv[i]);
196
197 ppd = ppdOpenFile(argv[i]);
198 }
199
200 if (ppd == NULL)
201 {
202 error = ppdLastError(&line);
203
204 if (error <= PPD_ALLOC_ERROR)
205 {
206 status = ERROR_FILE_OPEN;
207
208 if (verbose >= 0)
209 _cupsLangPrintf(stdout,
210 _(" FAIL\n"
211 " **FAIL** Unable to open PPD file - %s\n"),
212 strerror(errno));
213 }
214 else
215 {
216 status = ERROR_PPD_FORMAT;
217
218 if (verbose >= 0)
219 {
220 _cupsLangPrintf(stdout,
221 _(" FAIL\n"
222 " **FAIL** Unable to open PPD file - "
223 "%s on line %d.\n"),
224 ppdErrorString(error), line);
225
226 switch (error)
227 {
228 case PPD_MISSING_PPDADOBE4 :
229 _cupsLangPuts(stdout,
230 _(" REF: Page 42, section 5.2.\n"));
231 break;
232 case PPD_MISSING_VALUE :
233 _cupsLangPuts(stdout,
234 _(" REF: Page 20, section 3.4.\n"));
235 break;
236 case PPD_BAD_OPEN_GROUP :
237 case PPD_NESTED_OPEN_GROUP :
238 _cupsLangPuts(stdout,
239 _(" REF: Pages 45-46, section 5.2.\n"));
240 break;
241 case PPD_BAD_OPEN_UI :
242 case PPD_NESTED_OPEN_UI :
243 _cupsLangPuts(stdout,
244 _(" REF: Pages 42-45, section 5.2.\n"));
245 break;
246 case PPD_BAD_ORDER_DEPENDENCY :
247 _cupsLangPuts(stdout,
248 _(" REF: Pages 48-49, section 5.2.\n"));
249 break;
250 case PPD_BAD_UI_CONSTRAINTS :
251 _cupsLangPuts(stdout,
252 _(" REF: Pages 52-54, section 5.2.\n"));
253 break;
254 case PPD_MISSING_ASTERISK :
255 _cupsLangPuts(stdout,
256 _(" REF: Page 15, section 3.2.\n"));
257 break;
258 case PPD_LINE_TOO_LONG :
259 _cupsLangPuts(stdout,
260 _(" REF: Page 15, section 3.1.\n"));
261 break;
262 case PPD_ILLEGAL_CHARACTER :
263 _cupsLangPuts(stdout,
264 _(" REF: Page 15, section 3.1.\n"));
265 break;
266 case PPD_ILLEGAL_MAIN_KEYWORD :
267 _cupsLangPuts(stdout,
268 _(" REF: Pages 16-17, section 3.2.\n"));
269 break;
270 case PPD_ILLEGAL_OPTION_KEYWORD :
271 _cupsLangPuts(stdout,
272 _(" REF: Page 19, section 3.3.\n"));
273 break;
274 case PPD_ILLEGAL_TRANSLATION :
275 _cupsLangPuts(stdout,
276 _(" REF: Page 27, section 3.5.\n"));
277 break;
278 default :
279 break;
280 }
281
282 check_basics(argv[i]);
283 }
284 }
285
286 continue;
287 }
288
289 /*
290 * Show the header and then perform basic conformance tests (limited
291 * only by what the CUPS PPD functions actually load...)
292 */
293
294 errors = 0;
295 ppdversion = 43;
296
297 if (verbose > 0)
298 _cupsLangPuts(stdout,
299 _("\n DETAILED CONFORMANCE TEST RESULTS\n"));
300
301 if ((attr = ppdFindAttr(ppd, "FormatVersion", NULL)) != NULL &&
302 attr->value)
303 ppdversion = (int)(10 * atof(attr->value) + 0.5);
304
305 /*
306 * Look for default keywords with no matching option...
307 */
308
309 for (i = 0; i < ppd->num_attrs; i ++)
310 {
311 attr = ppd->attrs[i];
312
313 if (!strcmp(attr->name, "DefaultColorSpace") ||
314 !strcmp(attr->name, "DefaultFont") ||
315 !strcmp(attr->name, "DefaultImageableArea") ||
316 !strcmp(attr->name, "DefaultOutputOrder") ||
317 !strcmp(attr->name, "DefaultPaperDimension") ||
318 !strcmp(attr->name, "DefaultTransfer"))
319 continue;
320
321 if (!strncmp(attr->name, "Default", 7))
322 {
323 if ((option = ppdFindOption(ppd, attr->name + 7)) != NULL &&
324 strcmp(attr->value, "Unknown"))
325 {
326 /*
327 * Check that the default option value matches a choice...
328 */
329
330 for (j = 0; j < option->num_choices; j ++)
331 if (!strcmp(option->choices[j].choice, attr->value))
332 break;
333
334 if (j >= option->num_choices)
335 {
336 if (verbose >= 0)
337 {
338 if (!errors && !verbose)
339 _cupsLangPuts(stdout, _(" FAIL\n"));
340
341 _cupsLangPrintf(stdout,
342 _(" **FAIL** %s %s does not exist!\n"),
343 attr->name, attr->value);
344 }
345
346 errors ++;
347 }
348 }
349 }
350 }
351
352 if ((attr = ppdFindAttr(ppd, "DefaultImageableArea", NULL)) == NULL)
353 {
354 if (verbose >= 0)
355 {
356 if (!errors && !verbose)
357 _cupsLangPuts(stdout, _(" FAIL\n"));
358
359 _cupsLangPuts(stdout,
360 _(" **FAIL** REQUIRED DefaultImageableArea\n"
361 " REF: Page 102, section 5.15.\n"));
362 }
363
364 errors ++;
365 }
366 else if (ppdPageSize(ppd, attr->value) == NULL &&
367 strcmp(attr->value, "Unknown"))
368 {
369 if (verbose >= 0)
370 {
371 if (!errors && !verbose)
372 _cupsLangPuts(stdout, _(" FAIL\n"));
373
374 _cupsLangPrintf(stdout,
375 _(" **FAIL** BAD DefaultImageableArea %s!\n"
376 " REF: Page 102, section 5.15.\n"),
377 attr->value);
378 }
379
380 errors ++;
381 }
382 else
383 {
384 if (verbose > 0)
385 _cupsLangPuts(stdout, _(" PASS DefaultImageableArea\n"));
386 }
387
388 if ((attr = ppdFindAttr(ppd, "DefaultPaperDimension", NULL)) == NULL)
389 {
390 if (verbose >= 0)
391 {
392 if (!errors && !verbose)
393 _cupsLangPuts(stdout, _(" FAIL\n"));
394
395 _cupsLangPuts(stdout,
396 _(" **FAIL** REQUIRED DefaultPaperDimension\n"
397 " REF: Page 103, section 5.15.\n"));
398 }
399
400 errors ++;
401 }
402 else if (ppdPageSize(ppd, attr->value) == NULL &&
403 strcmp(attr->value, "Unknown"))
404 {
405 if (verbose >= 0)
406 {
407 if (!errors && !verbose)
408 _cupsLangPuts(stdout, _(" FAIL\n"));
409
410 _cupsLangPrintf(stdout,
411 _(" **FAIL** BAD DefaultPaperDimension %s!\n"
412 " REF: Page 103, section 5.15.\n"),
413 attr->value);
414 }
415
416 errors ++;
417 }
418 else if (verbose > 0)
419 _cupsLangPuts(stdout, _(" PASS DefaultPaperDimension\n"));
420
421 for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++)
422 for (k = 0, option = group->options; k < group->num_options; k ++, option ++)
423 {
424 /*
425 * Verify that we have a default choice...
426 */
427
428 if (option->defchoice[0])
429 {
430 if (ppdFindChoice(option, option->defchoice) == NULL &&
431 strcmp(option->defchoice, "Unknown"))
432 {
433 if (verbose >= 0)
434 {
435 if (!errors && !verbose)
436 _cupsLangPuts(stdout, _(" FAIL\n"));
437
438 _cupsLangPrintf(stdout,
439 _(" **FAIL** BAD Default%s %s\n"
440 " REF: Page 40, section 4.5.\n"),
441 option->keyword, option->defchoice);
442 }
443
444 errors ++;
445 }
446 else if (verbose > 0)
447 _cupsLangPrintf(stdout,
448 _(" PASS Default%s\n"),
449 option->keyword);
450 }
451 else
452 {
453 if (verbose >= 0)
454 {
455 if (!errors && !verbose)
456 _cupsLangPuts(stdout, _(" FAIL\n"));
457
458 _cupsLangPrintf(stdout,
459 _(" **FAIL** REQUIRED Default%s\n"
460 " REF: Page 40, section 4.5.\n"),
461 option->keyword);
462 }
463
464 errors ++;
465 }
466 }
467
468 if (ppdFindAttr(ppd, "FileVersion", NULL) != NULL)
469 {
470 if (verbose > 0)
471 _cupsLangPuts(stdout, _(" PASS FileVersion\n"));
472 }
473 else
474 {
475 if (verbose >= 0)
476 {
477 if (!errors && !verbose)
478 _cupsLangPuts(stdout, _(" FAIL\n"));
479
480 _cupsLangPuts(stdout,
481 _(" **FAIL** REQUIRED FileVersion\n"
482 " REF: Page 56, section 5.3.\n"));
483 }
484
485 errors ++;
486 }
487
488 if (ppdFindAttr(ppd, "FormatVersion", NULL) != NULL)
489 {
490 if (verbose > 0)
491 _cupsLangPuts(stdout, _(" PASS FormatVersion\n"));
492 }
493 else
494 {
495 if (verbose >= 0)
496 {
497 if (!errors && !verbose)
498 _cupsLangPuts(stdout, _(" FAIL\n"));
499
500 _cupsLangPuts(stdout,
501 _(" **FAIL** REQUIRED FormatVersion\n"
502 " REF: Page 56, section 5.3.\n"));
503 }
504
505 errors ++;
506 }
507
508 if (ppd->lang_encoding != NULL)
509 {
510 if (verbose > 0)
511 _cupsLangPuts(stdout, _(" PASS LanguageEncoding\n"));
512 }
513 else if (ppdversion > 40)
514 {
515 if (verbose >= 0)
516 {
517 if (!errors && !verbose)
518 _cupsLangPuts(stdout, _(" FAIL\n"));
519
520 _cupsLangPuts(stdout,
521 _(" **FAIL** REQUIRED LanguageEncoding\n"
522 " REF: Pages 56-57, section 5.3.\n"));
523 }
524
525 errors ++;
526 }
527
528 if (ppd->lang_version != NULL)
529 {
530 if (verbose > 0)
531 _cupsLangPuts(stdout, _(" PASS LanguageVersion\n"));
532 }
533 else
534 {
535 if (verbose >= 0)
536 {
537 if (!errors && !verbose)
538 _cupsLangPuts(stdout, _(" FAIL\n"));
539
540 _cupsLangPuts(stdout,
541 _(" **FAIL** REQUIRED LanguageVersion\n"
542 " REF: Pages 57-58, section 5.3.\n"));
543 }
544
545 errors ++;
546 }
547
548 if (ppd->manufacturer != NULL)
549 {
550 if (!strncasecmp(ppd->manufacturer, "Hewlett-Packard", 15) ||
551 !strncasecmp(ppd->manufacturer, "Hewlett Packard", 15))
552 {
553 if (verbose >= 0)
554 {
555 if (!errors && !verbose)
556 _cupsLangPuts(stdout, _(" FAIL\n"));
557
558 _cupsLangPuts(stdout,
559 _(" **FAIL** BAD Manufacturer (should be "
560 "\"HP\")\n"
561 " REF: Page 211, table D.1.\n"));
562 }
563
564 errors ++;
565 }
566 else if (verbose > 0)
567 _cupsLangPuts(stdout, _(" PASS Manufacturer\n"));
568 }
569 else if (ppdversion >= 43)
570 {
571 if (verbose >= 0)
572 {
573 if (!errors && !verbose)
574 _cupsLangPuts(stdout, _(" FAIL\n"));
575
576 _cupsLangPuts(stdout,
577 _(" **FAIL** REQUIRED Manufacturer\n"
578 " REF: Pages 58-59, section 5.3.\n"));
579 }
580
581 errors ++;
582 }
583
584 if (ppd->modelname != NULL)
585 {
586 for (ptr = ppd->modelname; *ptr; ptr ++)
587 if (!isalnum(*ptr & 255) && !strchr(" ./-+", *ptr))
588 break;
589
590 if (*ptr)
591 {
592 if (verbose >= 0)
593 {
594 if (!errors && !verbose)
595 _cupsLangPuts(stdout, _(" FAIL\n"));
596
597 _cupsLangPrintf(stdout,
598 _(" **FAIL** BAD ModelName - \"%c\" not "
599 "allowed in string.\n"
600 " REF: Pages 59-60, section 5.3.\n"),
601 *ptr);
602 }
603
604 errors ++;
605 }
606 else if (verbose > 0)
607 _cupsLangPuts(stdout, _(" PASS ModelName\n"));
608 }
609 else
610 {
611 if (verbose >= 0)
612 {
613 if (!errors && !verbose)
614 _cupsLangPuts(stdout, _(" FAIL\n"));
615
616 _cupsLangPuts(stdout,
617 _(" **FAIL** REQUIRED ModelName\n"
618 " REF: Pages 59-60, section 5.3.\n"));
619 }
620
621 errors ++;
622 }
623
624 if (ppd->nickname != NULL)
625 {
626 if (verbose > 0)
627 _cupsLangPuts(stdout, _(" PASS NickName\n"));
628 }
629 else
630 {
631 if (verbose >= 0)
632 {
633 if (!errors && !verbose)
634 _cupsLangPuts(stdout, _(" FAIL\n"));
635
636 _cupsLangPuts(stdout,
637 _(" **FAIL** REQUIRED NickName\n"
638 " REF: Page 60, section 5.3.\n"));
639 }
640
641 errors ++;
642 }
643
644 if (ppdFindOption(ppd, "PageSize") != NULL)
645 {
646 if (verbose > 0)
647 _cupsLangPuts(stdout, _(" PASS PageSize\n"));
648 }
649 else
650 {
651 if (verbose >= 0)
652 {
653 if (!errors && !verbose)
654 _cupsLangPuts(stdout, _(" FAIL\n"));
655
656 _cupsLangPuts(stdout,
657 _(" **FAIL** REQUIRED PageSize\n"
658 " REF: Pages 99-100, section 5.14.\n"));
659 }
660
661 errors ++;
662 }
663
664 if (ppdFindOption(ppd, "PageRegion") != NULL)
665 {
666 if (verbose > 0)
667 _cupsLangPuts(stdout, _(" PASS PageRegion\n"));
668 }
669 else
670 {
671 if (verbose >= 0)
672 {
673 if (!errors && !verbose)
674 _cupsLangPuts(stdout, _(" FAIL\n"));
675
676 _cupsLangPuts(stdout,
677 _(" **FAIL** REQUIRED PageRegion\n"
678 " REF: Page 100, section 5.14.\n"));
679 }
680
681 errors ++;
682 }
683
684 if (ppd->pcfilename != NULL)
685 {
686 if (verbose > 0)
687 _cupsLangPuts(stdout, _(" PASS PCFileName\n"));
688 }
689 else
690 {
691 if (verbose >= 0)
692 {
693 if (!errors && !verbose)
694 _cupsLangPuts(stdout, _(" FAIL\n"));
695
696 _cupsLangPuts(stdout,
697 _(" **FAIL** REQUIRED PCFileName\n"
698 " REF: Pages 61-62, section 5.3.\n"));
699 }
700
701 errors ++;
702 }
703
704 if (ppd->product != NULL)
705 {
706 if (ppd->product[0] != '(' ||
707 ppd->product[strlen(ppd->product) - 1] != ')')
708 {
709 if (verbose >= 0)
710 {
711 if (!errors && !verbose)
712 _cupsLangPuts(stdout, _(" FAIL\n"));
713
714 _cupsLangPuts(stdout,
715 _(" **FAIL** BAD Product - not \"(string)\".\n"
716 " REF: Page 62, section 5.3.\n"));
717 }
718
719 errors ++;
720 }
721 else if (verbose > 0)
722 _cupsLangPuts(stdout, _(" PASS Product\n"));
723 }
724 else
725 {
726 if (verbose >= 0)
727 {
728 if (!errors && !verbose)
729 _cupsLangPuts(stdout, _(" FAIL\n"));
730
731 _cupsLangPuts(stdout,
732 _(" **FAIL** REQUIRED Product\n"
733 " REF: Page 62, section 5.3.\n"));
734 }
735
736 errors ++;
737 }
738
739 if ((attr = ppdFindAttr(ppd, "PSVersion", NULL)) != NULL &&
740 attr->value != NULL)
741 {
742 char junkstr[255]; /* Temp string */
743 int junkint; /* Temp integer */
744
745
746 if (sscanf(attr->value, "(%[^)])%d", junkstr, &junkint) != 2)
747 {
748 if (verbose >= 0)
749 {
750 if (!errors && !verbose)
751 _cupsLangPuts(stdout, _(" FAIL\n"));
752
753 _cupsLangPuts(stdout,
754 _(" **FAIL** BAD PSVersion - not \"(string) "
755 "int\".\n"
756 " REF: Pages 62-64, section 5.3.\n"));
757 }
758
759 errors ++;
760 }
761 else if (verbose > 0)
762 _cupsLangPuts(stdout, _(" PASS PSVersion\n"));
763 }
764 else
765 {
766 if (verbose >= 0)
767 {
768 if (!errors && !verbose)
769 _cupsLangPuts(stdout, _(" FAIL\n"));
770
771 _cupsLangPuts(stdout,
772 _(" **FAIL** REQUIRED PSVersion\n"
773 " REF: Pages 62-64, section 5.3.\n"));
774 }
775
776 errors ++;
777 }
778
779 if (ppd->shortnickname != NULL)
780 {
781 if (strlen(ppd->shortnickname) > 31)
782 {
783 if (verbose >= 0)
784 {
785 if (!errors && !verbose)
786 _cupsLangPuts(stdout, _(" FAIL\n"));
787
788 _cupsLangPuts(stdout,
789 _(" **FAIL** BAD ShortNickName - longer "
790 "than 31 chars.\n"
791 " REF: Pages 64-65, section 5.3.\n"));
792 }
793
794 errors ++;
795 }
796 else if (verbose > 0)
797 _cupsLangPuts(stdout, _(" PASS ShortNickName\n"));
798 }
799 else if (ppdversion >= 43)
800 {
801 if (verbose >= 0)
802 {
803 if (!errors && !verbose)
804 _cupsLangPuts(stdout, _(" FAIL\n"));
805
806 _cupsLangPuts(stdout,
807 _(" **FAIL** REQUIRED ShortNickName\n"
808 " REF: Page 64-65, section 5.3.\n"));
809 }
810
811 errors ++;
812 }
813
814 if (ppd->patches != NULL && strchr(ppd->patches, '\"') &&
815 strstr(ppd->patches, "*End"))
816 {
817 if (verbose >= 0)
818 {
819 if (!errors && !verbose)
820 _cupsLangPuts(stdout, _(" FAIL\n"));
821
822 _cupsLangPuts(stdout,
823 _(" **FAIL** BAD JobPatchFile attribute in file\n"
824 " REF: Page 24, section 3.4.\n"));
825 }
826
827 errors ++;
828 }
829
830 /*
831 * Check for page sizes without the corresponding ImageableArea or
832 * PaperDimension values...
833 */
834
835 if (ppd->num_sizes == 0)
836 {
837 if (verbose >= 0)
838 {
839 if (!errors && !verbose)
840 _cupsLangPuts(stdout, _(" FAIL\n"));
841
842 _cupsLangPuts(stdout,
843 _(" **FAIL** REQUIRED PageSize\n"
844 " REF: Page 41, section 5.\n"
845 " REF: Page 99, section 5.14.\n"));
846 }
847
848 errors ++;
849 }
850 else
851 {
852 for (j = 0, size = ppd->sizes; j < ppd->num_sizes; j ++, size ++)
853 {
854 /*
855 * Don't check custom size...
856 */
857
858 if (!strcmp(size->name, "Custom"))
859 continue;
860
861 /*
862 * Check for ImageableArea...
863 */
864
865 if (size->left == 0.0 && size->bottom == 0.0 &&
866 size->right == 0.0 && size->top == 0.0)
867 {
868 if (verbose >= 0)
869 {
870 if (!errors && !verbose)
871 _cupsLangPuts(stdout, _(" FAIL\n"));
872
873 _cupsLangPrintf(stdout,
874 _(" **FAIL** REQUIRED ImageableArea for "
875 "PageSize %s\n"
876 " REF: Page 41, section 5.\n"
877 " REF: Page 102, section 5.15.\n"),
878 size->name);
879 }
880
881 errors ++;
882 }
883
884 /*
885 * Check for PaperDimension...
886 */
887
888 if (size->width == 0.0 && size->length == 0.0)
889 {
890 if (verbose >= 0)
891 {
892 if (!errors && !verbose)
893 _cupsLangPuts(stdout, _(" FAIL\n"));
894
895 _cupsLangPrintf(stdout,
896 _(" **FAIL** REQUIRED PaperDimension "
897 "for PageSize %s\n"
898 " REF: Page 41, section 5.\n"
899 " REF: Page 103, section 5.15.\n"),
900 size->name);
901 }
902
903 errors ++;
904 }
905 }
906 }
907
908 /*
909 * Check for valid Resolution, JCLResolution, or SetResolution values...
910 */
911
912 if ((option = ppdFindOption(ppd, "Resolution")) == NULL)
913 if ((option = ppdFindOption(ppd, "JCLResolution")) == NULL)
914 option = ppdFindOption(ppd, "SetResolution");
915
916 if (option != NULL)
917 {
918 for (j = option->num_choices, choice = option->choices; j > 0; j --, choice ++)
919 {
920 /*
921 * Verify that all resolution options are of the form NNNdpi
922 * or NNNxNNNdpi...
923 */
924
925 xdpi = strtol(choice->choice, (char **)&ptr, 10);
926 if (ptr > choice->choice && xdpi > 0)
927 {
928 if (*ptr == 'x')
929 ydpi = strtol(ptr + 1, (char **)&ptr, 10);
930 else
931 ydpi = xdpi;
932 }
933 else
934 ydpi = xdpi;
935
936 if (xdpi <= 0 || ydpi <= 0 || strcmp(ptr, "dpi"))
937 {
938 if (verbose >= 0)
939 {
940 if (!errors && !verbose)
941 _cupsLangPuts(stdout, _(" FAIL\n"));
942
943 _cupsLangPrintf(stdout,
944 _(" **FAIL** Bad %s choice %s!\n"
945 " REF: Page 84, section 5.9\n"),
946 option->keyword, choice->choice);
947 }
948
949 errors ++;
950 }
951 }
952 }
953
954 /*
955 * Check for a duplex option, and for standard values...
956 */
957
958 if ((option = ppdFindOption(ppd, "Duplex")) == NULL)
959 if ((option = ppdFindOption(ppd, "JCLDuplex")) == NULL)
960 if ((option = ppdFindOption(ppd, "EFDuplex")) == NULL)
961 option = ppdFindOption(ppd, "KD03Duplex");
962
963 if (option != NULL)
964 {
965 if (ppdFindChoice(option, "None") == NULL)
966 {
967 if (verbose >= 0)
968 {
969 if (!errors && !verbose)
970 _cupsLangPuts(stdout, _(" FAIL\n"));
971
972 _cupsLangPrintf(stdout,
973 _(" **FAIL** REQUIRED %s does not define "
974 "choice None!\n"
975 " REF: Page 122, section 5.17\n"),
976 option->keyword);
977 }
978
979 errors ++;
980 }
981
982 for (j = option->num_choices, choice = option->choices; j > 0; j --, choice ++)
983 if (strcmp(choice->choice, "None") &&
984 strcmp(choice->choice, "DuplexNoTumble") &&
985 strcmp(choice->choice, "DuplexTumble") &&
986 strcmp(choice->choice, "SimplexTumble"))
987 {
988 if (verbose >= 0)
989 {
990 if (!errors && !verbose)
991 _cupsLangPuts(stdout, _(" FAIL\n"));
992
993 _cupsLangPrintf(stdout,
994 _(" **FAIL** Bad %s choice %s!\n"
995 " REF: Page 122, section 5.17\n"),
996 option->keyword, choice->choice);
997 }
998
999 errors ++;
1000 }
1001 }
1002
1003 if ((attr = ppdFindAttr(ppd, "cupsLanguages", NULL)) != NULL &&
1004 attr->value)
1005 {
1006 /*
1007 * This file contains localizations, check them...
1008 */
1009
1010 char *languages, /* Copy of attribute value */
1011 *langstart, /* Start of current language */
1012 *langptr, /* Pointer into languages */
1013 keyword[PPD_MAX_NAME]; /* Localization keyword */
1014
1015
1016 languages = strdup(attr->value);
1017 for (langptr = languages; *langptr;)
1018 {
1019 /*
1020 * Skip leading whitespace...
1021 */
1022
1023 while (isspace(*langptr & 255))
1024 langptr ++;
1025
1026 if (!*langptr)
1027 break;
1028
1029 /*
1030 * Find the end of this language name...
1031 */
1032
1033 for (langstart = langptr;
1034 *langptr && !isspace(*langptr & 255);
1035 langptr ++);
1036
1037 if (*langptr)
1038 *langptr++ = '\0';
1039
1040 j = strlen(langstart);
1041 if (j != 2 && j != 5)
1042 {
1043 if (verbose >= 0)
1044 {
1045 if (!errors && !verbose)
1046 _cupsLangPuts(stdout, _(" FAIL\n"));
1047
1048 _cupsLangPrintf(stdout,
1049 _(" **FAIL** Bad language \"%s\"!\n"),
1050 langstart);
1051 }
1052
1053 errors ++;
1054 continue;
1055 }
1056
1057 /*
1058 * Loop through all options and choices...
1059 */
1060
1061 for (option = ppdFirstOption(ppd);
1062 option;
1063 option = ppdNextOption(ppd))
1064 {
1065 snprintf(keyword, sizeof(keyword), "%s.Translation", langstart);
1066 if (!ppdFindAttr(ppd, keyword, option->keyword))
1067 {
1068 if (verbose >= 0)
1069 {
1070 if (!errors && !verbose)
1071 _cupsLangPuts(stdout, _(" FAIL\n"));
1072
1073 _cupsLangPrintf(stdout,
1074 _(" **FAIL** Missing \"%s\" translation "
1075 "string for option %s!\n"),
1076 langstart, option->keyword);
1077 }
1078
1079 errors ++;
1080 }
1081
1082 for (ptr = option->text; *ptr; ptr ++)
1083 if (*ptr & 128)
1084 break;
1085
1086 if (*ptr)
1087 {
1088 if (verbose >= 0)
1089 {
1090 if (!errors && !verbose)
1091 _cupsLangPuts(stdout, _(" FAIL\n"));
1092
1093 _cupsLangPrintf(stdout,
1094 _(" **FAIL** Default translation "
1095 "string for option %s contains 8-bit "
1096 "characters!\n"),
1097 option->keyword);
1098 }
1099
1100 errors ++;
1101 }
1102
1103 snprintf(keyword, sizeof(keyword), "%s.%s", langstart,
1104 option->keyword);
1105 for (j = 0; j < option->num_choices; j ++)
1106 {
1107 if (!ppdFindAttr(ppd, keyword, option->choices[j].choice))
1108 {
1109 if (verbose >= 0)
1110 {
1111 if (!errors && !verbose)
1112 _cupsLangPuts(stdout, _(" FAIL\n"));
1113
1114 _cupsLangPrintf(stdout,
1115 _(" **FAIL** Missing \"%s\" "
1116 "translation string for option %s, "
1117 "choice %s!\n"),
1118 langstart, option->keyword,
1119 option->choices[j].choice);
1120 }
1121
1122 errors ++;
1123 }
1124
1125 for (ptr = option->choices[j].text; *ptr; ptr ++)
1126 if (*ptr & 128)
1127 break;
1128
1129 if (*ptr)
1130 {
1131 if (verbose >= 0)
1132 {
1133 if (!errors && !verbose)
1134 _cupsLangPuts(stdout, _(" FAIL\n"));
1135
1136 _cupsLangPrintf(stdout,
1137 _(" **FAIL** Default translation "
1138 "string for option %s choice %s contains "
1139 "8-bit characters!\n"),
1140 option->keyword,
1141 option->choices[j].choice);
1142 }
1143
1144 errors ++;
1145 }
1146 }
1147 }
1148 }
1149 }
1150
1151 for (attr = ppdFindAttr(ppd, "cupsFilter", NULL);
1152 attr;
1153 attr = ppdFindNextAttr(ppd, "cupsFilter", NULL))
1154 {
1155 char super[16], /* Filter super type */
1156 type[256], /* Filter type */
1157 program[256]; /* Filter program */
1158 int cost; /* Filter cost */
1159
1160
1161 if (!attr->value ||
1162 sscanf(attr->value, "%15[^/]/%255s%d%255s", super, type, &cost,
1163 program) != 4)
1164 {
1165 if (verbose >= 0)
1166 {
1167 if (!errors && !verbose)
1168 _cupsLangPuts(stdout, _(" FAIL\n"));
1169
1170 _cupsLangPrintf(stdout,
1171 _(" **FAIL** Bad cupsFilter value \"%s\"!\n"),
1172 attr->value ? attr->value : "");
1173 }
1174
1175 errors ++;
1176 }
1177 }
1178
1179 if (ppdFindAttr(ppd, "1284DeviceId", NULL))
1180 {
1181 if (verbose >= 0)
1182 {
1183 if (!errors && !verbose)
1184 _cupsLangPuts(stdout, _(" FAIL\n"));
1185
1186 _cupsLangPuts(stdout,
1187 _(" **FAIL** 1284DeviceId must be 1284DeviceID!\n"
1188 " REF: Page 72, section 5.5\n"));
1189 }
1190
1191 errors ++;
1192 }
1193
1194 if (errors)
1195 status = ERROR_CONFORMANCE;
1196 else if (!verbose)
1197 _cupsLangPuts(stdout, _(" PASS\n"));
1198
1199 if (verbose >= 0)
1200 {
1201 check_basics(argv[i]);
1202
1203 /*
1204 * Look for default keywords with no corresponding option...
1205 */
1206
1207 for (i = 0; i < ppd->num_attrs; i ++)
1208 {
1209 attr = ppd->attrs[i];
1210
1211 if (!strcmp(attr->name, "DefaultColorSpace") ||
1212 !strcmp(attr->name, "DefaultColorSep") ||
1213 !strcmp(attr->name, "DefaultFont") ||
1214 !strcmp(attr->name, "DefaultImageableArea") ||
1215 !strcmp(attr->name, "DefaultOutputOrder") ||
1216 !strcmp(attr->name, "DefaultPaperDimension") ||
1217 !strcmp(attr->name, "DefaultScreenProc") ||
1218 !strcmp(attr->name, "DefaultTransfer"))
1219 continue;
1220
1221 if (!strncmp(attr->name, "Default", 7) &&
1222 !ppdFindOption(ppd, attr->name + 7))
1223 _cupsLangPrintf(stdout,
1224 _(" WARN %s has no corresponding "
1225 "options!\n"),
1226 attr->name);
1227 }
1228
1229 /*
1230 * Check for old Duplex option names...
1231 */
1232
1233 if ((option = ppdFindOption(ppd, "EFDuplex")) == NULL)
1234 option = ppdFindOption(ppd, "KD03Duplex");
1235
1236 if (option)
1237 {
1238 _cupsLangPrintf(stdout,
1239 _(" WARN Duplex option keyword %s "
1240 "should be named Duplex or JCLDuplex!\n"
1241 " REF: Page 122, section 5.17\n"),
1242 option->keyword);
1243 }
1244
1245 ppdMarkDefaults(ppd);
1246 if (ppdConflicts(ppd))
1247 {
1248 _cupsLangPuts(stdout,
1249 _(" WARN Default choices conflicting!\n"));
1250
1251 show_conflicts(ppd);
1252 }
1253
1254 if (ppdversion < 43)
1255 {
1256 _cupsLangPrintf(stdout,
1257 _(" WARN Obsolete PPD version %.1f!\n"
1258 " REF: Page 42, section 5.2.\n"),
1259 0.1f * ppdversion);
1260 }
1261
1262 if (!ppd->lang_encoding && ppdversion < 41)
1263 {
1264 _cupsLangPuts(stdout,
1265 _(" WARN LanguageEncoding required by PPD "
1266 "4.3 spec.\n"
1267 " REF: Pages 56-57, section 5.3.\n"));
1268 }
1269
1270 if (!ppd->manufacturer && ppdversion < 43)
1271 {
1272 _cupsLangPuts(stdout,
1273 _(" WARN Manufacturer required by PPD "
1274 "4.3 spec.\n"
1275 " REF: Pages 58-59, section 5.3.\n"));
1276 }
1277
1278 /*
1279 * Treat a PCFileName attribute longer than 12 characters as
1280 * a warning and not a hard error...
1281 */
1282
1283 if (ppd->pcfilename && strlen(ppd->pcfilename) > 12)
1284 {
1285 _cupsLangPuts(stdout,
1286 _(" WARN PCFileName longer than 8.3 in "
1287 "violation of PPD spec.\n"
1288 " REF: Pages 61-62, section 5.3.\n"));
1289 }
1290
1291 if (!ppd->shortnickname && ppdversion < 43)
1292 {
1293 _cupsLangPuts(stdout,
1294 _(" WARN ShortNickName required by PPD "
1295 "4.3 spec.\n"
1296 " REF: Pages 64-65, section 5.3.\n"));
1297 }
1298
1299 /*
1300 * Check the Protocols line and flag PJL + BCP since TBCP is
1301 * usually used with PJL...
1302 */
1303
1304 if (ppd->protocols)
1305 {
1306 if (strstr(ppd->protocols, "PJL") &&
1307 strstr(ppd->protocols, "BCP") &&
1308 !strstr(ppd->protocols, "TBCP"))
1309 {
1310 _cupsLangPuts(stdout,
1311 _(" WARN Protocols contains both PJL "
1312 "and BCP; expected TBCP.\n"
1313 " REF: Pages 78-79, section 5.7.\n"));
1314 }
1315
1316 if (strstr(ppd->protocols, "PJL") &&
1317 (!ppd->jcl_begin || !ppd->jcl_end || !ppd->jcl_ps))
1318 {
1319 _cupsLangPuts(stdout,
1320 _(" WARN Protocols contains PJL but JCL "
1321 "attributes are not set.\n"
1322 " REF: Pages 78-79, section 5.7.\n"));
1323 }
1324 }
1325
1326 /*
1327 * Check for options with a common prefix, e.g. Duplex and Duplexer,
1328 * which are errors according to the spec but won't cause problems
1329 * with CUPS specifically...
1330 */
1331
1332 for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++)
1333 for (k = 0, option = group->options; k < group->num_options; k ++, option ++)
1334 {
1335 len = strlen(option->keyword);
1336
1337 for (m = 0, group2 = ppd->groups;
1338 m < ppd->num_groups;
1339 m ++, group2 ++)
1340 for (n = 0, option2 = group2->options;
1341 n < group2->num_options;
1342 n ++, option2 ++)
1343 if (option != option2 &&
1344 len < strlen(option2->keyword) &&
1345 !strncmp(option->keyword, option2->keyword, len))
1346 {
1347 _cupsLangPrintf(stdout,
1348 _(" WARN %s shares a common "
1349 "prefix with %s\n"
1350 " REF: Page 15, section "
1351 "3.2.\n"),
1352 option->keyword, option2->keyword);
1353 }
1354 }
1355 }
1356
1357 if (verbose > 0)
1358 {
1359 if (errors)
1360 _cupsLangPrintf(stdout, _(" %d ERROR%s FOUND\n"),
1361 errors, errors == 1 ? "" : "S");
1362 else
1363 _cupsLangPuts(stdout, _(" NO ERRORS FOUND\n"));
1364 }
1365
1366 /*
1367 * Then list the options, if "-v" was provided...
1368 */
1369
1370 if (verbose > 1)
1371 {
1372 _cupsLangPrintf(stdout,
1373 "\n"
1374 " language_level = %d\n"
1375 " color_device = %s\n"
1376 " variable_sizes = %s\n"
1377 " landscape = %d\n",
1378 ppd->language_level,
1379 ppd->color_device ? "TRUE" : "FALSE",
1380 ppd->variable_sizes ? "TRUE" : "FALSE",
1381 ppd->landscape);
1382
1383 switch (ppd->colorspace)
1384 {
1385 case PPD_CS_CMYK :
1386 _cupsLangPuts(stdout, " colorspace = PPD_CS_CMYK\n");
1387 break;
1388 case PPD_CS_CMY :
1389 _cupsLangPuts(stdout, " colorspace = PPD_CS_CMY\n");
1390 break;
1391 case PPD_CS_GRAY :
1392 _cupsLangPuts(stdout, " colorspace = PPD_CS_GRAY\n");
1393 break;
1394 case PPD_CS_RGB :
1395 _cupsLangPuts(stdout, " colorspace = PPD_CS_RGB\n");
1396 break;
1397 default :
1398 _cupsLangPuts(stdout, " colorspace = <unknown>\n");
1399 break;
1400 }
1401
1402 _cupsLangPrintf(stdout, " num_emulations = %d\n",
1403 ppd->num_emulations);
1404 for (j = 0; j < ppd->num_emulations; j ++)
1405 _cupsLangPrintf(stdout, " emulations[%d] = %s\n",
1406 j, ppd->emulations[j].name);
1407
1408 _cupsLangPrintf(stdout, " lang_encoding = %s\n",
1409 ppd->lang_encoding);
1410 _cupsLangPrintf(stdout, " lang_version = %s\n",
1411 ppd->lang_version);
1412 _cupsLangPrintf(stdout, " modelname = %s\n", ppd->modelname);
1413 _cupsLangPrintf(stdout, " ttrasterizer = %s\n",
1414 ppd->ttrasterizer == NULL ? "None" : ppd->ttrasterizer);
1415 _cupsLangPrintf(stdout, " manufacturer = %s\n",
1416 ppd->manufacturer);
1417 _cupsLangPrintf(stdout, " product = %s\n", ppd->product);
1418 _cupsLangPrintf(stdout, " nickname = %s\n", ppd->nickname);
1419 _cupsLangPrintf(stdout, " shortnickname = %s\n",
1420 ppd->shortnickname);
1421 _cupsLangPrintf(stdout, " patches = %d bytes\n",
1422 ppd->patches == NULL ? 0 : (int)strlen(ppd->patches));
1423
1424 _cupsLangPrintf(stdout, " num_groups = %d\n", ppd->num_groups);
1425 for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++)
1426 {
1427 _cupsLangPrintf(stdout, " group[%d] = %s\n",
1428 j, group->text);
1429
1430 for (k = 0, option = group->options; k < group->num_options; k ++, option ++)
1431 {
1432 _cupsLangPrintf(stdout,
1433 " options[%d] = %s (%s) %s %s %.0f "
1434 "(%d choices)\n",
1435 k, option->keyword, option->text, uis[option->ui],
1436 sections[option->section], option->order,
1437 option->num_choices);
1438
1439 if (!strcmp(option->keyword, "PageSize") ||
1440 !strcmp(option->keyword, "PageRegion"))
1441 {
1442 for (m = option->num_choices, choice = option->choices;
1443 m > 0;
1444 m --, choice ++)
1445 {
1446 size = ppdPageSize(ppd, choice->choice);
1447
1448 if (size == NULL)
1449 _cupsLangPrintf(stdout,
1450 " %s (%s) = ERROR",
1451 choice->choice, choice->text);
1452 else
1453 _cupsLangPrintf(stdout,
1454 " %s (%s) = %.2fx%.2fin "
1455 "(%.1f,%.1f,%.1f,%.1f)",
1456 choice->choice, choice->text,
1457 size->width / 72.0, size->length / 72.0,
1458 size->left / 72.0, size->bottom / 72.0,
1459 size->right / 72.0, size->top / 72.0);
1460
1461 if (!strcmp(option->defchoice, choice->choice))
1462 _cupsLangPuts(stdout, " *\n");
1463 else
1464 _cupsLangPuts(stdout, "\n");
1465 }
1466 }
1467 else
1468 {
1469 for (m = option->num_choices, choice = option->choices;
1470 m > 0;
1471 m --, choice ++)
1472 {
1473 _cupsLangPrintf(stdout, " %s (%s)",
1474 choice->choice, choice->text);
1475
1476 if (!strcmp(option->defchoice, choice->choice))
1477 _cupsLangPuts(stdout, " *\n");
1478 else
1479 _cupsLangPuts(stdout, "\n");
1480 }
1481 }
1482 }
1483 }
1484
1485 _cupsLangPrintf(stdout, " num_profiles = %d\n",
1486 ppd->num_profiles);
1487 for (j = 0; j < ppd->num_profiles; j ++)
1488 _cupsLangPrintf(stdout,
1489 " profiles[%d] = %s/%s %.3f %.3f "
1490 "[ %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f ]\n",
1491 j, ppd->profiles[j].resolution,
1492 ppd->profiles[j].media_type,
1493 ppd->profiles[j].gamma, ppd->profiles[j].density,
1494 ppd->profiles[j].matrix[0][0],
1495 ppd->profiles[j].matrix[0][1],
1496 ppd->profiles[j].matrix[0][2],
1497 ppd->profiles[j].matrix[1][0],
1498 ppd->profiles[j].matrix[1][1],
1499 ppd->profiles[j].matrix[1][2],
1500 ppd->profiles[j].matrix[2][0],
1501 ppd->profiles[j].matrix[2][1],
1502 ppd->profiles[j].matrix[2][2]);
1503
1504 _cupsLangPrintf(stdout, " num_fonts = %d\n", ppd->num_fonts);
1505 for (j = 0; j < ppd->num_fonts; j ++)
1506 _cupsLangPrintf(stdout, " fonts[%d] = %s\n",
1507 j, ppd->fonts[j]);
1508
1509 _cupsLangPrintf(stdout, " num_attrs = %d\n", ppd->num_attrs);
1510 for (j = 0; j < ppd->num_attrs; j ++)
1511 _cupsLangPrintf(stdout,
1512 " attrs[%d] = %s %s%s%s: \"%s\"\n", j,
1513 ppd->attrs[j]->name, ppd->attrs[j]->spec,
1514 ppd->attrs[j]->text[0] ? "/" : "",
1515 ppd->attrs[j]->text,
1516 ppd->attrs[j]->value ?
1517 ppd->attrs[j]->value : "(null)");
1518 }
1519
1520 ppdClose(ppd);
1521 }
1522
1523 if (!files)
1524 usage();
1525
1526 return (status);
1527 }
1528
1529
1530 /*
1531 * 'check_basics()' - Check for CR LF, mixed line endings, and blank lines.
1532 */
1533
1534 void
1535 check_basics(const char *filename) /* I - PPD file to check */
1536 {
1537 cups_file_t *fp; /* File pointer */
1538 int ch; /* Current character */
1539 int col, /* Current column */
1540 whitespace; /* Only seen whitespace? */
1541 int eol; /* Line endings */
1542 int linenum; /* Line number */
1543 int mixed; /* Mixed line endings? */
1544
1545
1546 if ((fp = cupsFileOpen(filename, "r")) == NULL)
1547 return;
1548
1549 linenum = 1;
1550 col = 0;
1551 eol = EOL_NONE;
1552 mixed = 0;
1553 whitespace = 1;
1554
1555 while ((ch = cupsFileGetChar(fp)) != EOF)
1556 {
1557 if (ch == '\r' || ch == '\n')
1558 {
1559 if (ch == '\n')
1560 {
1561 if (eol == EOL_NONE)
1562 eol = EOL_LF;
1563 else if (eol != EOL_LF)
1564 mixed = 1;
1565 }
1566 else if (ch == '\r')
1567 {
1568 if (cupsFilePeekChar(fp) == '\n')
1569 {
1570 cupsFileGetChar(fp);
1571
1572 if (eol == EOL_NONE)
1573 eol = EOL_CRLF;
1574 else
1575 mixed = 1;
1576 }
1577 else if (eol == EOL_NONE)
1578 eol = EOL_CR;
1579 else
1580 mixed = 1;
1581 }
1582
1583 if (col > 0 && whitespace)
1584 _cupsLangPrintf(stdout,
1585 _(" WARN Line %d only contains whitespace!\n"),
1586 linenum);
1587
1588 linenum ++;
1589 col = 0;
1590 whitespace = 1;
1591 }
1592 else
1593 {
1594 if (ch != ' ' && ch != '\t')
1595 whitespace = 0;
1596
1597 col ++;
1598 }
1599 }
1600
1601 if (mixed)
1602 _cupsLangPuts(stdout,
1603 _(" WARN File contains a mix of CR, LF, and "
1604 "CR LF line endings!\n"));
1605
1606 if (eol == EOL_CRLF)
1607 _cupsLangPuts(stdout,
1608 _(" WARN Non-Windows PPD files should use lines "
1609 "ending with only LF, not CR LF!\n"));
1610
1611 cupsFileClose(fp);
1612 }
1613
1614
1615 /*
1616 * 'show_conflicts()' - Show option conflicts in a PPD file.
1617 */
1618
1619 void
1620 show_conflicts(ppd_file_t *ppd) /* I - PPD to check */
1621 {
1622 int i, j; /* Looping variables */
1623 ppd_const_t *c; /* Current constraint */
1624 ppd_option_t *o1, *o2; /* Options */
1625 ppd_choice_t *c1, *c2; /* Choices */
1626
1627
1628 /*
1629 * Loop through all of the UI constraints and report any options
1630 * that conflict...
1631 */
1632
1633 for (i = ppd->num_consts, c = ppd->consts; i > 0; i --, c ++)
1634 {
1635 /*
1636 * Grab pointers to the first option...
1637 */
1638
1639 o1 = ppdFindOption(ppd, c->option1);
1640
1641 if (o1 == NULL)
1642 continue;
1643 else if (c->choice1[0] != '\0')
1644 {
1645 /*
1646 * This constraint maps to a specific choice.
1647 */
1648
1649 c1 = ppdFindChoice(o1, c->choice1);
1650 }
1651 else
1652 {
1653 /*
1654 * This constraint applies to any choice for this option.
1655 */
1656
1657 for (j = o1->num_choices, c1 = o1->choices; j > 0; j --, c1 ++)
1658 if (c1->marked)
1659 break;
1660
1661 if (j == 0 ||
1662 !strcasecmp(c1->choice, "None") ||
1663 !strcasecmp(c1->choice, "Off") ||
1664 !strcasecmp(c1->choice, "False"))
1665 c1 = NULL;
1666 }
1667
1668 /*
1669 * Grab pointers to the second option...
1670 */
1671
1672 o2 = ppdFindOption(ppd, c->option2);
1673
1674 if (o2 == NULL)
1675 continue;
1676 else if (c->choice2[0] != '\0')
1677 {
1678 /*
1679 * This constraint maps to a specific choice.
1680 */
1681
1682 c2 = ppdFindChoice(o2, c->choice2);
1683 }
1684 else
1685 {
1686 /*
1687 * This constraint applies to any choice for this option.
1688 */
1689
1690 for (j = o2->num_choices, c2 = o2->choices; j > 0; j --, c2 ++)
1691 if (c2->marked)
1692 break;
1693
1694 if (j == 0 ||
1695 !strcasecmp(c2->choice, "None") ||
1696 !strcasecmp(c2->choice, "Off") ||
1697 !strcasecmp(c2->choice, "False"))
1698 c2 = NULL;
1699 }
1700
1701 /*
1702 * If both options are marked then there is a conflict...
1703 */
1704
1705 if (c1 != NULL && c1->marked && c2 != NULL && c2->marked)
1706 _cupsLangPrintf(stdout,
1707 _(" WARN \"%s %s\" conflicts with \"%s %s\"\n"
1708 " (constraint=\"%s %s %s %s\")\n"),
1709 o1->keyword, c1->choice, o2->keyword, c2->choice,
1710 c->option1, c->choice1, c->option2, c->choice2);
1711 }
1712 }
1713
1714
1715 /*
1716 * 'usage()' - Show program usage...
1717 */
1718
1719 void
1720 usage(void)
1721 {
1722 _cupsLangPuts(stdout,
1723 _("Usage: cupstestppd [-q] [-r] [-v[v]] filename1.ppd[.gz] "
1724 "[... filenameN.ppd[.gz]]\n"
1725 " program | cupstestppd [-q] [-r] [-v[v]] -\n"));
1726
1727 exit(ERROR_USAGE);
1728 }
1729
1730
1731 /*
1732 * End of "$Id: cupstestppd.c 5422 2006-04-18 15:16:00Z mike $".
1733 */