]>
git.ipfire.org Git - thirdparty/cups.git/blob - systemv/cupstestppd.c
8052028220105cc3a05e6a952155aa572ec51817
2 * "$Id: cupstestppd.c,v 1.1.2.1 2002/12/13 21:22:06 mike Exp $"
4 * PPD test program for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2002 by Easy Software Products, all rights reserved.
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
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * PostScript is a trademark of Adobe Systems, Inc.
26 * This file is subject to the Apple OS-Developed Software exception.
30 * main() - Main entry for test program.
34 * Include necessary headers...
37 #include <cups/cups.h>
38 #include <cups/string.h>
48 #define ERROR_FILE_OPEN 2
49 #define ERROR_PPD_FORMAT 3
50 #define ERROR_CONFORMANCE 4
54 * 'main()' - Main entry for test program.
57 int /* O - Exit status */
58 main(int argc
, /* I - Number of command-line arguments */
59 char *argv
[]) /* I - Command-line arguments */
61 int i
, j
, k
, m
; /* Looping vars */
62 int verbose
; /* Want verbose output? */
63 int status
; /* Exit status */
64 int errors
; /* Number of conformance errors */
65 ppd_file_t
*ppd
; /* PPD file record */
66 ppd_size_t
*size
; /* Size record */
67 ppd_group_t
*group
; /* UI group */
68 ppd_option_t
*option
; /* Standard UI option */
69 ppd_choice_t
*choice
; /* Standard UI option choice */
70 static char *uis
[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
71 static char *sections
[] = { "ANY", "DOCUMENT", "EXIT",
72 "JCL", "PAGE", "PROLOG" };
78 * Display PPD files for each file listed on the command-line...
85 for (i
= 1; i
< argc
; i
++)
86 if (strcmp(argv
[i
], "-v") == 0)
88 else if (argv
[i
][0] == '-' && argv
[i
][1])
96 * Open the PPD file...
99 if (argv
[i
][0] == '-')
105 puts("FILE: (stdin)\n");
107 ppd
= ppdOpen(stdin
);
112 * Read from a file...
115 printf("FILE: %s\n\n", argv
[i
]);
117 ppd
= ppdOpenFile(argv
[i
]);
124 status
= ERROR_FILE_OPEN
;
125 printf(" Unable to open PPD file - %s\n\n", strerror(errno
));
129 status
= ERROR_PPD_FORMAT
;
130 puts(" Unable to open PPD file using CUPS functions!\n");
137 * Show the header and then perform basic conformance tests (limited
138 * only by what the CUPS PPD functions actually load...)
141 puts(" CONFORMANCE TESTS:");
145 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
146 for (k
= 0, option
= group
->options
; k
< group
->num_options
; k
++, option
++)
147 if (option
->defchoice
[0])
149 printf(" PASS Default%s\n", option
->keyword
);
154 printf(" **FAIL** REQUIRED Default%s\n", option
->keyword
);
162 puts(" **FAIL** REQUIRED Fonts");
165 if (ppd
->lang_encoding
!= NULL
)
166 puts(" PASS LanguageEncoding");
170 puts(" **FAIL** REQUIRED LanguageEncoding");
173 if (ppd
->lang_version
!= NULL
)
174 puts(" PASS LanguageVersion");
178 puts(" **FAIL** REQUIRED LanguageVersion");
181 if (ppd
->manufacturer
!= NULL
)
182 puts(" PASS Manufacturer");
186 puts(" **FAIL** REQUIRED Manufacturer");
189 if (ppd
->modelname
!= NULL
)
190 puts(" PASS ModelName");
194 puts(" **FAIL** REQUIRED ModelName");
197 if (ppd
->nickname
!= NULL
)
198 puts(" PASS NickName");
202 puts(" **FAIL** REQUIRED NickName");
205 if (ppdFindOption(ppd
, "PageSize") != NULL
)
206 puts(" PASS PageSize");
210 puts(" **FAIL** REQUIRED PageSize");
213 if (ppdFindOption(ppd
, "PageRegion") != NULL
)
214 puts(" PASS PageRegion");
218 puts(" **FAIL** REQUIRED PageRegion");
221 if (ppd
->product
!= NULL
)
222 puts(" PASS Product");
226 puts(" **FAIL** REQUIRED Product");
229 if (ppd
->shortnickname
!= NULL
)
230 puts(" PASS ShortNickName");
234 puts(" **FAIL** REQUIRED ShortNickName");
239 puts("\n **** CONFORMANCE TESTING FAILED ****");
240 status
= ERROR_CONFORMANCE
;
246 * Then list the options, if "-v" was provided...
253 printf(" language_level = %d\n", ppd
->language_level
);
254 printf(" color_device = %s\n", ppd
->color_device
? "TRUE" : "FALSE");
255 printf(" variable_sizes = %s\n", ppd
->variable_sizes
? "TRUE" : "FALSE");
256 printf(" landscape = %d\n", ppd
->landscape
);
258 switch (ppd
->colorspace
)
261 puts(" colorspace = PPD_CS_CMYK");
264 puts(" colorspace = PPD_CS_CMY");
267 puts(" colorspace = PPD_CS_GRAY");
270 puts(" colorspace = PPD_CS_RGB");
273 puts(" colorspace = <unknown>");
277 printf(" num_emulations = %d\n", ppd
->num_emulations
);
278 for (j
= 0; j
< ppd
->num_emulations
; j
++)
279 printf(" emulations[%d] = %s\n", j
, ppd
->emulations
[j
].name
);
281 printf(" lang_encoding = %s\n", ppd
->lang_encoding
);
282 printf(" lang_version = %s\n", ppd
->lang_version
);
283 printf(" modelname = %s\n", ppd
->modelname
);
284 printf(" ttrasterizer = %s\n",
285 ppd
->ttrasterizer
== NULL
? "None" : ppd
->ttrasterizer
);
286 printf(" manufacturer = %s\n", ppd
->manufacturer
);
287 printf(" product = %s\n", ppd
->product
);
288 printf(" nickname = %s\n", ppd
->nickname
);
289 printf(" shortnickname = %s\n", ppd
->shortnickname
);
290 printf(" patches = %d bytes\n",
291 ppd
->patches
== NULL
? 0 : (int)strlen(ppd
->patches
));
293 printf(" num_groups = %d\n", ppd
->num_groups
);
294 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
296 printf(" group[%d] = %s\n", j
, group
->text
);
298 for (k
= 0, option
= group
->options
; k
< group
->num_options
; k
++, option
++)
300 printf(" options[%d] = %s (%s) %s %s %.0f (%d choices)\n", k
,
301 option
->keyword
, option
->text
, uis
[option
->ui
],
302 sections
[option
->section
], option
->order
,
303 option
->num_choices
);
305 if (strcmp(option
->keyword
, "PageSize") == 0 ||
306 strcmp(option
->keyword
, "PageRegion") == 0)
308 for (m
= option
->num_choices
, choice
= option
->choices
;
312 size
= ppdPageSize(ppd
, choice
->choice
);
315 printf(" %s (%s) = ERROR", choice
->choice
, choice
->text
);
317 printf(" %s (%s) = %.2fx%.2fin (%.1f,%.1f,%.1f,%.1f)", choice
->choice
,
318 choice
->text
, size
->width
/ 72.0, size
->length
/ 72.0,
319 size
->left
/ 72.0, size
->bottom
/ 72.0,
320 size
->right
/ 72.0, size
->top
/ 72.0);
322 if (strcmp(option
->defchoice
, choice
->choice
) == 0)
330 for (m
= option
->num_choices
, choice
= option
->choices
;
334 printf(" %s (%s)", choice
->choice
, choice
->text
);
336 if (strcmp(option
->defchoice
, choice
->choice
) == 0)
345 printf(" num_profiles = %d\n", ppd
->num_profiles
);
346 for (j
= 0; j
< ppd
->num_profiles
; j
++)
347 printf(" profiles[%d] = %s/%s %.3f %.3f [ %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f ]\n",
348 j
, ppd
->profiles
[j
].resolution
, ppd
->profiles
[j
].media_type
,
349 ppd
->profiles
[j
].gamma
, ppd
->profiles
[j
].density
,
350 ppd
->profiles
[j
].matrix
[0][0], ppd
->profiles
[j
].matrix
[0][1],
351 ppd
->profiles
[j
].matrix
[0][2], ppd
->profiles
[j
].matrix
[1][0],
352 ppd
->profiles
[j
].matrix
[1][1], ppd
->profiles
[j
].matrix
[1][2],
353 ppd
->profiles
[j
].matrix
[2][0], ppd
->profiles
[j
].matrix
[2][1],
354 ppd
->profiles
[j
].matrix
[2][2]);
356 printf(" num_fonts = %d\n", ppd
->num_fonts
);
357 for (j
= 0; j
< ppd
->num_fonts
; j
++)
358 printf(" fonts[%d] = %s\n", j
, ppd
->fonts
[j
]);
366 puts("Usage: cupstestppd [-v] filename1.ppd [... filenameN.ppd]");
367 puts(" program | cupstestppd [-v] -");
369 return (ERROR_USAGE
);
377 * End of "$Id: cupstestppd.c,v 1.1.2.1 2002/12/13 21:22:06 mike Exp $".