]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
2 * "$Id: testppd.c 5826 2006-08-15 19:04:11Z mike $"
4 * PPD test program for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2006 by Easy Software Products.
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 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * This file is subject to the Apple OS-Developed Software exception.
28 * main() - Main entry.
32 * Include necessary headers...
37 #include <cups/string.h>
52 static const char *default_code
=
54 "%%BeginFeature: *PageRegion Letter\n"
57 "} stopped cleartomark\n"
59 "%%BeginFeature: *InputSlot Tray\n"
62 "} stopped cleartomark\n"
64 "%%BeginFeature: *IntOption None\n"
66 "} stopped cleartomark\n"
68 "%%BeginFeature: *StringOption None\n"
70 "} stopped cleartomark\n";
72 static const char *custom_code
=
74 "%%BeginFeature: *CustomPageSize True\n"
82 "} stopped cleartomark\n"
84 "%%BeginFeature: *InputSlot Tray\n"
87 "} stopped cleartomark\n"
89 "%%BeginFeature: *IntOption None\n"
91 "} stopped cleartomark\n"
93 "%%BeginFeature: *StringOption None\n"
95 "} stopped cleartomark\n";
99 * 'main()' - Main entry.
102 int /* O - Exit status */
103 main(int argc
, /* I - Number of command-line arguments */
104 char *argv
[]) /* I - Command-line arguments */
106 ppd_file_t
*ppd
; /* PPD file loaded from disk */
107 int status
; /* Status of tests (0 = success, 1 = fail) */
108 int conflicts
; /* Number of conflicts */
109 char *s
; /* String */
116 fputs("ppdOpenFile: ", stdout
);
118 if ((ppd
= ppdOpenFile("test.ppd")) != NULL
)
122 ppd_status_t err
; /* Last error in file */
123 int line
; /* Line number in file */
127 err
= ppdLastError(&line
);
129 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
132 fputs("ppdMarkDefaults: ", stdout
);
133 ppdMarkDefaults(ppd
);
135 if ((conflicts
= ppdConflicts(ppd
)) == 0)
140 printf("FAIL (%d conflicts)\n", conflicts
);
143 fputs("ppdEmitString (defaults): ", stdout
);
144 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
145 !strcmp(s
, default_code
))
149 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
150 (int)strlen(default_code
));
159 fputs("ppdEmitString (custom size): ", stdout
);
160 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
162 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
163 !strcmp(s
, custom_code
))
167 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
168 (int)strlen(custom_code
));
181 if ((ppd
= ppdOpenFile(argv
[1])) == NULL
)
183 ppd_status_t err
; /* Last error in file */
184 int line
; /* Line number in file */
188 err
= ppdLastError(&line
);
190 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
194 int i
, j
, k
; /* Looping vars */
195 ppd_attr_t
*attr
; /* Current attribute */
196 ppd_group_t
*group
; /* Option group */
197 ppd_option_t
*option
; /* Option */
198 char lang
[255]; /* LANG environment variable */
203 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
209 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
213 printf("%s (%s):\n", group
->name
, group
->text
);
215 for (j
= group
->num_options
, option
= group
->options
;
219 printf(" %s (%s):\n", option
->keyword
, option
->text
);
221 for (k
= 0; k
< option
->num_choices
; k
++)
222 printf(" - %s (%s)\n", option
->choices
[k
].choice
,
223 option
->choices
[k
].text
);
229 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
231 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
232 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
233 attr
->text
, attr
->value
? attr
->value
: "");
242 * End of "$Id: testppd.c 5826 2006-08-15 19:04:11Z mike $".