]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
Fixed all constant arrays to use "const" modifier.
[thirdparty/cups.git] / cups / testppd.c
1 /*
2 * "$Id: testppd.c,v 1.13 1999/07/12 16:09:41 mike Exp $"
3 *
4 * PPD test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-1999 by Easy Software Products, all rights reserved.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
19 *
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * PostScript is a trademark of Adobe Systems, Inc.
25 *
26 * Contents:
27 *
28 * main() - Main entry for test program.
29 */
30
31 /*
32 * Include necessary headers...
33 */
34
35 #include "cups.h"
36 #include "string.h"
37
38
39 /*
40 * 'main()' - Main entry for test program.
41 */
42
43 int /* O - Exit status */
44 main(int argc, /* I - Number of command-line arguments */
45 char *argv[]) /* I - Command-line arguments */
46 {
47 int i, j, k, m, n; /* Looping vars */
48 const char *filename; /* File to load */
49 ppd_file_t *ppd; /* PPD file record */
50 ppd_size_t *size; /* Size record */
51 ppd_group_t *group; /* UI group */
52 ppd_option_t *option; /* Standard UI option */
53 ppd_choice_t *choice; /* Standard UI option choice */
54 static char *uis[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
55 static char *sections[] = { "ANY", "DOCUMENT", "EXIT",
56 "JCL", "PAGE", "PROLOG" };
57
58
59 /*
60 * Display PPD files for each file listed on the command-line...
61 */
62
63 if (argc == 1)
64 {
65 fputs("Usage: ppdtest filename1.ppd [... filenameN.ppd]\n", stderr);
66 return (1);
67 }
68
69 for (i = 1; i < argc; i ++)
70 {
71 if (strstr(argv[i], ".ppd"))
72 filename = argv[i];
73 else
74 filename = cupsGetPPD(argv[i]);
75
76 if ((ppd = ppdOpenFile(filename)) == NULL)
77 {
78 fprintf(stderr, "Unable to open \'%s\' as a PPD file!\n", filename);
79 continue;
80 }
81
82 printf("FILE: %s\n", filename);
83 printf(" language_level = %d\n", ppd->language_level);
84 printf(" color_device = %s\n", ppd->color_device ? "TRUE" : "FALSE");
85 printf(" variable_sizes = %s\n", ppd->variable_sizes ? "TRUE" : "FALSE");
86 printf(" landscape = %d\n", ppd->landscape);
87
88 switch (ppd->colorspace)
89 {
90 case PPD_CS_CMYK :
91 puts(" colorspace = PPD_CS_CMYK");
92 break;
93 case PPD_CS_CMY :
94 puts(" colorspace = PPD_CS_CMY");
95 break;
96 case PPD_CS_GRAY :
97 puts(" colorspace = PPD_CS_GRAY");
98 break;
99 case PPD_CS_RGB :
100 puts(" colorspace = PPD_CS_RGB");
101 break;
102 default :
103 puts(" colorspace = <unknown>");
104 break;
105 }
106
107 printf(" num_emulations = %d\n", ppd->num_emulations);
108 for (j = 0; j < ppd->num_emulations; j ++)
109 printf(" emulations[%d] = %s\n", j, ppd->emulations[j].name);
110
111 printf(" lang_encoding = %s\n", ppd->lang_encoding);
112 printf(" lang_version = %s\n", ppd->lang_version);
113 printf(" modelname = %s\n", ppd->modelname);
114 printf(" ttrasterizer = %s\n",
115 ppd->ttrasterizer == NULL ? "None" : ppd->ttrasterizer);
116 printf(" manufacturer = %s\n", ppd->manufacturer);
117 printf(" product = %s\n", ppd->product);
118 printf(" nickname = %s\n", ppd->nickname);
119 printf(" shortnickname = %s\n", ppd->shortnickname);
120 printf(" patches = %d bytes\n",
121 ppd->patches == NULL ? 0 : strlen(ppd->patches));
122
123 printf(" num_groups = %d\n", ppd->num_groups);
124 for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++)
125 {
126 printf(" group[%d] = %s\n", j, group->text);
127
128 for (k = 0, option = group->options; k < group->num_options; k ++, option ++)
129 {
130 printf(" options[%d] = %s (%s) %s %s %.0f\n", k,
131 option->keyword, option->text, uis[option->ui],
132 sections[option->section], option->order);
133
134 if (strcmp(option->keyword, "PageSize") == 0 ||
135 strcmp(option->keyword, "PageRegion") == 0)
136 {
137 for (m = option->num_choices, choice = option->choices;
138 m > 0;
139 m --, choice ++)
140 {
141 size = ppdPageSize(ppd, choice->choice);
142
143 if (size == NULL)
144 printf(" %s (%s) = ERROR", choice->choice, choice->text);
145 else
146 printf(" %s (%s) = %.2fx%.2fin (%.1f,%.1f,%.1f,%.1f)", choice->choice,
147 choice->text, size->width / 72.0, size->length / 72.0,
148 size->left / 72.0, size->bottom / 72.0,
149 size->right / 72.0, size->top / 72.0);
150
151 if (strcmp(option->defchoice, choice->choice) == 0)
152 puts(" *");
153 else
154 putchar('\n');
155 }
156 }
157 else
158 {
159 for (m = option->num_choices, choice = option->choices;
160 m > 0;
161 m --, choice ++)
162 {
163 printf(" %s (%s)", choice->choice, choice->text);
164
165 if (strcmp(option->defchoice, choice->choice) == 0)
166 puts(" *");
167 else
168 putchar('\n');
169 }
170 }
171 }
172 }
173
174 ppdClose(ppd);
175 }
176
177 return (0);
178 }
179
180
181 /*
182 * End of "$Id: testppd.c,v 1.13 1999/07/12 16:09:41 mike Exp $".
183 */