]> git.ipfire.org Git - thirdparty/cups.git/blob - driver/testdriver.c
Load cups into easysw/current.
[thirdparty/cups.git] / driver / testdriver.c
1 /*
2 * "$Id: testdriver.c 5390 2006-04-10 19:29:44Z mike $"
3 *
4 * Sample/test driver interface program for the Common UNIX Printing
5 * System (CUPS).
6 *
7 * This program handles listing and installing both static PPD files
8 * in CUPS_DATADIR/model and dynamically generated PPD files using
9 * the driver helper programs in CUPS_SERVERBIN/driver.
10 *
11 * Copyright 1997-2006 by Easy Software Products.
12 *
13 * These coded instructions, statements, and computer programs are the
14 * property of Easy Software Products and are protected by Federal
15 * copyright law. Distribution and use rights are outlined in the file
16 * "LICENSE.txt" which should have been included with this file. If this
17 * file is missing or damaged please contact Easy Software Products
18 * at:
19 *
20 * Attn: CUPS Licensing Information
21 * Easy Software Products
22 * 44141 Airport View Drive, Suite 204
23 * Hollywood, Maryland 20636 USA
24 *
25 * Voice: (301) 373-9600
26 * EMail: cups-info@cups.org
27 * WWW: http://www.cups.org
28 *
29 * Contents:
30 *
31 * main() - Enumerate or display PPD files.
32 * cat_ppd() - Display a PPD file.
33 * list_ppds() - List PPDs.
34 */
35
36 /*
37 * Include necessary headers...
38 */
39
40 #include <stdio.h>
41 #include <string.h>
42
43
44 /*
45 * Local functions...
46 */
47
48 static int cat_ppd(const char *uri);
49 static int list_ppds(const char *name);
50
51
52 /*
53 * Sample data...
54 */
55
56 static const char *models[][2] =
57 {
58 { "foojet.ppd", "Foo Printer" },
59 { "barjet.ppd", "Bar Printer" },
60 { "foobar.ppd", "Foo/Bar Multifunction Printer" }
61 };
62
63
64 /*
65 * 'main()' - Enumerate or display PPD files.
66 */
67
68 int /* O - Exit status */
69 main(int argc, /* I - Number of command-line args */
70 char *argv[]) /* I - Command-line arguments */
71 {
72 if (argc == 2 && !strcmp(argv[1], "list"))
73 return (list_ppds(argv[0]));
74 else if (argc == 3 && !strcmp(argv[1], "cat"))
75 return (cat_ppd(argv[2]));
76
77 fprintf(stderr, "ERROR: Usage: %s cat URI\n", argv[0]);
78 fprintf(stderr, "ERROR: Usage: %s list\n", argv[0]);
79 return (1);
80 }
81
82
83 /*
84 * 'cat_ppd()' - Display a PPD file.
85 */
86
87 static int /* O - Exit status */
88 cat_ppd(const char *uri) /* I - PPD URI */
89 {
90 int i; /* Looping var */
91 const char *name; /* Pointer to name in URI */
92
93
94 if ((name = strchr(uri, ':')) == NULL)
95 {
96 fprintf(stderr, "ERROR: Bad URI \"%s\"!\n", uri);
97 return (1);
98 }
99
100 name ++;
101
102 for (i = 0 ; i < (int)(sizeof(models) / sizeof(models[0])); i ++)
103 if (!strcmp(name, models[i][0]))
104 {
105 /*
106 * Actually display the PPD file...
107 */
108 puts("*PPD-Adobe: \"4.3\"");
109
110 puts("*LanguageEncoding: ISOLatin1");
111 puts("*LanguageVersion: English");
112 puts("*Manufacturer: \"Test\"");
113 puts("*FileVersion: \"1.0\"");
114 puts("*FormatVersion: \"4.3\"");
115 puts("*PSVersion: \"(3010) 1\"");
116 printf("*PCFileName: \"%s\"\n", models[i][0]);
117
118 printf("*Product: \"(%s)\"\n", models[i][1]);
119 printf("*ModelName: \"Test %s\"\n", models[i][1]);
120 printf("*NickName: \"Test %s\"\n", models[i][1]);
121 printf("*ShortNickName: \"Test %s\"\n", models[i][1]);
122
123 puts("*OpenUI PageSize: PickOne");
124 puts("*OrderDependency: 10 AnySetup *PageSetup");
125 puts("*DefaultPageSize: Letter");
126 puts("*PageSize Letter: \"<</PageSize[612 792]>>setpagedevice\"");
127 puts("*PageSize A4: \"<</PageSize[585 842]>>setpagedevice\"");
128 puts("*CloseUI: *PageSize");
129
130 puts("*OpenUI PageRegion: PickOne");
131 puts("*OrderDependency: 10 AnySetup *PageRegion");
132 puts("*DefaultPageRegion: Letter");
133 puts("*PageRegion Letter: \"<</PageRegion[612 792]>>setpagedevice\"");
134 puts("*PageRegion A4: \"<</PageRegion[585 842]>>setpagedevice\"");
135 puts("*CloseUI: *PageRegion");
136
137 puts("*DefaultImageableArea: Letter");
138 puts("*ImageableArea Letter: \"0 0 612 792\"");
139 puts("*ImageableArea A4: \"0 0 595 842\"");
140
141 puts("*DefaultPaperDimension: Letter");
142 puts("*PaperDimension Letter: \"612 792\"");
143 puts("*PaperDimension A4: \"595 842\"");
144
145 return (0);
146 }
147
148 fprintf(stderr, "ERROR: Unknown URI \"%s\"!\n", uri);
149 return (1);
150 }
151
152
153 /*
154 * 'list_ppds()' - List PPDs.
155 */
156
157 static int /* O - Exit status */
158 list_ppds(const char *name) /* I - Program name */
159 {
160 int i; /* Looping var */
161 const char *base; /* Base name of program */
162
163
164 if ((base = strrchr(name, '/')) != NULL)
165 base ++;
166 else
167 base = name;
168
169 for (i = 0; i < (int)(sizeof(models) / sizeof(models[0])); i ++)
170 printf("\"%s:%s\" en \"Test\" \"Test %s\" \"1284 device id\"\n",
171 base, models[i][0], models[i][1]);
172
173 return (0);
174 }
175
176
177 /*
178 * End of "$Id: testdriver.c 5390 2006-04-10 19:29:44Z mike $".
179 */