]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/testcups.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / testcups.c
1 /*
2 * "$Id$"
3 *
4 * CUPS API test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 2007 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.h"
38
39
40 /*
41 * 'main()' - Main entry.
42 */
43
44 int /* O - Exit status */
45 main(int argc, /* I - Number of command-line arguments */
46 char *argv[]) /* I - Command-line arguments */
47 {
48 int status = 0, /* Exit status */
49 num_dests; /* Number of destinations */
50 cups_dest_t *dests, /* Destinations */
51 *dest; /* Current destination */
52 const char *ppdfile; /* PPD file */
53 ppd_file_t *ppd; /* PPD file data */
54 int num_jobs; /* Number of jobs for queue */
55 cups_job_t *jobs; /* Jobs for queue */
56
57
58 /*
59 * cupsGetDests()
60 */
61
62 fputs("cupsGetDests: ", stdout);
63 fflush(stdout);
64
65 num_dests = cupsGetDests(&dests);
66
67 if (num_dests == 0)
68 {
69 puts("FAIL");
70 return (1);
71 }
72 else
73 puts("PASS");
74
75 /*
76 * cupsGetDest(printer)
77 */
78
79 printf("cupsGetDest(\"%s\"): ", dests[num_dests / 2].name);
80 fflush(stdout);
81
82 if ((dest = cupsGetDest(dests[num_dests / 2].name, NULL, num_dests,
83 dests)) == NULL)
84 {
85 status = 1;
86 puts("FAIL");
87 }
88 else
89 puts("PASS");
90
91 /*
92 * cupsGetDest(NULL)
93 */
94
95 fputs("cupsGetDest(NULL): ", stdout);
96 fflush(stdout);
97
98 if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL)
99 {
100 status = 1;
101 puts("FAIL");
102 }
103 else
104 puts("PASS");
105
106 /*
107 * cupsPrintFile()
108 */
109
110 fputs("cupsPrintFile: ", stdout);
111 fflush(stdout);
112
113 if (cupsPrintFile(dest->name, "../data/testprint.ps", "Test Page",
114 dest->num_options, dest->options) <= 0)
115 {
116 status = 1;
117 puts("FAIL");
118 }
119 else
120 puts("PASS");
121
122 /*
123 * cupsGetPPD(printer)
124 */
125
126 fputs("cupsGetPPD(): ", stdout);
127 fflush(stdout);
128
129 if ((ppdfile = cupsGetPPD(dest->name)) == NULL)
130 {
131 status = 1;
132 puts("FAIL");
133 }
134 else
135 {
136 puts("PASS");
137
138 /*
139 * ppdOpenFile()
140 */
141
142 fputs("ppdOpenFile(): ", stdout);
143 fflush(stdout);
144
145 if ((ppd = ppdOpenFile(ppdfile)) == NULL)
146 {
147 puts("FAIL");
148 return (1);
149 }
150 else
151 puts("PASS");
152
153 ppdClose(ppd);
154 unlink(ppdfile);
155 }
156
157 /*
158 * cupsGetJobs()
159 */
160
161 fputs("cupsGetJobs: ", stdout);
162 fflush(stdout);
163
164 num_jobs = cupsGetJobs(&jobs, NULL, 0, -1);
165
166 if (num_jobs == 0)
167 {
168 puts("FAIL");
169 return (1);
170 }
171 else
172 puts("PASS");
173
174 cupsFreeJobs(num_jobs, jobs);
175 cupsFreeDests(num_dests, dests);
176
177 return (status);
178 }
179
180
181 /*
182 * End of "$Id: testfile.c 6192 2007-01-10 19:26:48Z mike $".
183 */