]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/testdriver.c
2 * "$Id: testdriver.c 177 2006-06-21 00:20:03Z jlovell $"
4 * Sample/test driver interface program for the Common UNIX Printing
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.
11 * Copyright 1997-2006 by Easy Software Products.
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
20 * Attn: CUPS Licensing Information
21 * Easy Software Products
22 * 44141 Airport View Drive, Suite 204
23 * Hollywood, Maryland 20636 USA
25 * Voice: (301) 373-9600
26 * EMail: cups-info@cups.org
27 * WWW: http://www.cups.org
31 * main() - Enumerate or display PPD files.
32 * cat_ppd() - Display a PPD file.
33 * list_ppds() - List PPDs.
37 * Include necessary headers...
48 static int cat_ppd(const char *uri
);
49 static int list_ppds(const char *name
);
56 static const char *models
[][2] =
58 { "foojet.ppd", "Foo Printer" },
59 { "barjet.ppd", "Bar Printer" },
60 { "foobar.ppd", "Foo/Bar Multifunction Printer" }
65 * 'main()' - Enumerate or display PPD files.
68 int /* O - Exit status */
69 main(int argc
, /* I - Number of command-line args */
70 char *argv
[]) /* I - Command-line arguments */
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]));
77 fprintf(stderr
, "ERROR: Usage: %s cat URI\n", argv
[0]);
78 fprintf(stderr
, "ERROR: Usage: %s list\n", argv
[0]);
84 * 'cat_ppd()' - Display a PPD file.
87 static int /* O - Exit status */
88 cat_ppd(const char *uri
) /* I - PPD URI */
90 int i
; /* Looping var */
91 const char *name
; /* Pointer to name in URI */
94 if ((name
= strchr(uri
, ':')) == NULL
)
96 fprintf(stderr
, "ERROR: Bad URI \"%s\"!\n", uri
);
102 for (i
= 0 ; i
< (int)(sizeof(models
) / sizeof(models
[0])); i
++)
103 if (!strcmp(name
, models
[i
][0]))
106 * Actually display the PPD file...
108 puts("*PPD-Adobe: \"4.3\"");
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]);
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]);
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");
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");
137 puts("*DefaultImageableArea: Letter");
138 puts("*ImageableArea Letter: \"0 0 612 792\"");
139 puts("*ImageableArea A4: \"0 0 595 842\"");
141 puts("*DefaultPaperDimension: Letter");
142 puts("*PaperDimension Letter: \"612 792\"");
143 puts("*PaperDimension A4: \"595 842\"");
148 fprintf(stderr
, "ERROR: Unknown URI \"%s\"!\n", uri
);
154 * 'list_ppds()' - List PPDs.
157 static int /* O - Exit status */
158 list_ppds(const char *name
) /* I - Program name */
160 int i
; /* Looping var */
161 const char *base
; /* Base name of program */
164 if ((base
= strrchr(name
, '/')) != NULL
)
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]);
178 * End of "$Id: testdriver.c 177 2006-06-21 00:20:03Z jlovell $".