]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
2 * "$Id: testppd.c 5484 2006-05-02 20:38:12Z 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";
66 * 'main()' - Main entry.
69 int /* O - Exit status */
70 main(int argc
, /* I - Number of command-line arguments */
71 char *argv
[]) /* I - Command-line arguments */
73 ppd_file_t
*ppd
; /* PPD file loaded from disk */
74 int status
; /* Status of tests (0 = success, 1 = fail) */
75 int conflicts
; /* Number of conflicts */
83 fputs("ppdOpenFile: ", stdout
);
85 if ((ppd
= ppdOpenFile("test.ppd")) != NULL
)
89 ppd_status_t err
; /* Last error in file */
90 int line
; /* Line number in file */
94 err
= ppdLastError(&line
);
96 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
99 fputs("ppdMarkDefaults: ", stdout
);
100 ppdMarkDefaults(ppd
);
102 if ((conflicts
= ppdConflicts(ppd
)) == 0)
107 printf("FAIL (%d conflicts)\n", conflicts
);
110 fputs("ppdEmitString: ", stdout
);
111 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
112 !strcmp(s
, default_code
))
116 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
117 (int)strlen(default_code
));
130 if ((ppd
= ppdOpenFile(argv
[1])) == NULL
)
132 ppd_status_t err
; /* Last error in file */
133 int line
; /* Line number in file */
137 err
= ppdLastError(&line
);
139 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
143 int i
, j
, k
; /* Looping vars */
144 ppd_group_t
*group
; /* Option group */
145 ppd_option_t
*option
; /* Option */
150 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
154 printf("%s (%s):\n", group
->name
, group
->text
);
156 for (j
= group
->num_options
, option
= group
->options
;
160 printf(" %s (%s):\n", option
->keyword
, option
->text
);
162 for (k
= 0; k
< option
->num_choices
; k
++)
163 printf(" - %s (%s)\n", option
->choices
[k
].choice
,
164 option
->choices
[k
].text
);
175 * End of "$Id: testppd.c 5484 2006-05-02 20:38:12Z mike $".