]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / testppd.c
1 /*
2 * "$Id: testppd.c 5261 2006-03-09 20:47:49Z mike $"
3 *
4 * PPD test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 by Easy Software Products.
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 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * This file is subject to the Apple OS-Developed Software exception.
25 *
26 * Contents:
27 *
28 * main() - Main entry.
29 */
30
31 /*
32 * Include necessary headers...
33 */
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <cups/string.h>
38 #include <errno.h>
39 #include "ppd.h"
40 #ifdef WIN32
41 # include <io.h>
42 #else
43 # include <unistd.h>
44 # include <fcntl.h>
45 #endif /* WIN32 */
46
47
48 /*
49 * Test data...
50 */
51
52 static const char *default_code =
53 "[{\n"
54 "%%BeginFeature: *PageRegion Letter\n"
55 "PageRegion=Letter\n"
56 "%%EndFeature\n"
57 "} stopped cleartomark\n"
58 "[{\n"
59 "%%BeginFeature: *InputSlot Tray\n"
60 "InputSlot=Tray\n"
61 "%%EndFeature\n"
62 "} stopped cleartomark\n";
63
64
65 /*
66 * 'main()' - Main entry.
67 */
68
69 int /* O - Exit status */
70 main(int argc, /* I - Number of command-line arguments */
71 char *argv[]) /* I - Command-line arguments */
72 {
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 */
76 char *s; /* String */
77
78
79 status = 0;
80
81 fputs("ppdOpenFile: ", stdout);
82
83 if ((ppd = ppdOpenFile("test.ppd")) != NULL)
84 puts("PASS");
85 else
86 {
87 ppd_status_t err; /* Last error in file */
88 int line; /* Line number in file */
89
90
91 status ++;
92 err = ppdLastError(&line);
93
94 printf("FAIL (%s on line %d)\n", ppdErrorString(err), line);
95 }
96
97 fputs("ppdMarkDefaults: ", stdout);
98 ppdMarkDefaults(ppd);
99
100 if ((conflicts = ppdConflicts(ppd)) == 0)
101 puts("PASS");
102 else
103 {
104 status ++;
105 printf("FAIL (%d conflicts)\n", conflicts);
106 }
107
108 fputs("ppdEmitString: ", stdout);
109 if ((s = ppdEmitString(ppd, PPD_ORDER_ANY, 0.0)) != NULL &&
110 !strcmp(s, default_code))
111 puts("PASS");
112 else
113 {
114 printf("FAIL (%d bytes instead of %d)\n", s ? (int)strlen(s) : 0,
115 (int)strlen(default_code));
116
117 if (s)
118 puts(s);
119 }
120
121 if (s)
122 free(s);
123
124 ppdClose(ppd);
125
126 return (status);
127 }
128
129
130 /*
131 * End of "$Id: testppd.c 5261 2006-03-09 20:47:49Z mike $".
132 */