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