]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
4d1ee2da062458fdf3bb589a35427bebb2f11021
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_group_t
*group
; /* Option group */
196 ppd_option_t
*option
; /* Option */
201 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
205 printf("%s (%s):\n", group
->name
, group
->text
);
207 for (j
= group
->num_options
, option
= group
->options
;
211 printf(" %s (%s):\n", option
->keyword
, option
->text
);
213 for (k
= 0; k
< option
->num_choices
; k
++)
214 printf(" - %s (%s)\n", option
->choices
[k
].choice
,
215 option
->choices
[k
].text
);