]>
Commit | Line | Data |
---|---|---|
09a101d6 | 1 | /* |
2 | * "$Id$" | |
3 | * | |
4 | * CUPS API test program for the Common UNIX Printing System (CUPS). | |
5 | * | |
bc44d920 | 6 | * Copyright 2007 by Apple Inc. |
09a101d6 | 7 | * Copyright 2007 by Easy Software Products. |
8 | * | |
9 | * These coded instructions, statements, and computer programs are the | |
bc44d920 | 10 | * property of Apple Inc. and are protected by Federal copyright |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
09a101d6 | 14 | * |
15 | * This file is subject to the Apple OS-Developed Software exception. | |
16 | * | |
17 | * Contents: | |
18 | * | |
19 | * main() - Main entry. | |
20 | */ | |
21 | ||
22 | /* | |
23 | * Include necessary headers... | |
24 | */ | |
25 | ||
26 | #include <stdio.h> | |
27 | #include <stdlib.h> | |
28 | #include "cups.h" | |
29 | ||
30 | ||
31 | /* | |
32 | * 'main()' - Main entry. | |
33 | */ | |
34 | ||
35 | int /* O - Exit status */ | |
36 | main(int argc, /* I - Number of command-line arguments */ | |
37 | char *argv[]) /* I - Command-line arguments */ | |
38 | { | |
39 | int status = 0, /* Exit status */ | |
40 | num_dests; /* Number of destinations */ | |
41 | cups_dest_t *dests, /* Destinations */ | |
42 | *dest; /* Current destination */ | |
43 | const char *ppdfile; /* PPD file */ | |
44 | ppd_file_t *ppd; /* PPD file data */ | |
45 | int num_jobs; /* Number of jobs for queue */ | |
46 | cups_job_t *jobs; /* Jobs for queue */ | |
47 | ||
48 | ||
49 | /* | |
50 | * cupsGetDests() | |
51 | */ | |
52 | ||
53 | fputs("cupsGetDests: ", stdout); | |
54 | fflush(stdout); | |
55 | ||
56 | num_dests = cupsGetDests(&dests); | |
57 | ||
58 | if (num_dests == 0) | |
59 | { | |
60 | puts("FAIL"); | |
61 | return (1); | |
62 | } | |
63 | else | |
64 | puts("PASS"); | |
65 | ||
66 | /* | |
67 | * cupsGetDest(printer) | |
68 | */ | |
69 | ||
70 | printf("cupsGetDest(\"%s\"): ", dests[num_dests / 2].name); | |
71 | fflush(stdout); | |
72 | ||
73 | if ((dest = cupsGetDest(dests[num_dests / 2].name, NULL, num_dests, | |
74 | dests)) == NULL) | |
75 | { | |
76 | status = 1; | |
77 | puts("FAIL"); | |
78 | } | |
79 | else | |
80 | puts("PASS"); | |
81 | ||
82 | /* | |
83 | * cupsGetDest(NULL) | |
84 | */ | |
85 | ||
86 | fputs("cupsGetDest(NULL): ", stdout); | |
87 | fflush(stdout); | |
88 | ||
89 | if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) == NULL) | |
90 | { | |
91 | status = 1; | |
92 | puts("FAIL"); | |
93 | } | |
94 | else | |
95 | puts("PASS"); | |
96 | ||
97 | /* | |
98 | * cupsPrintFile() | |
99 | */ | |
100 | ||
101 | fputs("cupsPrintFile: ", stdout); | |
102 | fflush(stdout); | |
103 | ||
104 | if (cupsPrintFile(dest->name, "../data/testprint.ps", "Test Page", | |
105 | dest->num_options, dest->options) <= 0) | |
106 | { | |
107 | status = 1; | |
108 | puts("FAIL"); | |
109 | } | |
110 | else | |
111 | puts("PASS"); | |
112 | ||
113 | /* | |
114 | * cupsGetPPD(printer) | |
115 | */ | |
116 | ||
117 | fputs("cupsGetPPD(): ", stdout); | |
118 | fflush(stdout); | |
119 | ||
120 | if ((ppdfile = cupsGetPPD(dest->name)) == NULL) | |
121 | { | |
122 | status = 1; | |
123 | puts("FAIL"); | |
124 | } | |
125 | else | |
126 | { | |
127 | puts("PASS"); | |
128 | ||
129 | /* | |
130 | * ppdOpenFile() | |
131 | */ | |
132 | ||
133 | fputs("ppdOpenFile(): ", stdout); | |
134 | fflush(stdout); | |
135 | ||
136 | if ((ppd = ppdOpenFile(ppdfile)) == NULL) | |
137 | { | |
138 | puts("FAIL"); | |
139 | return (1); | |
140 | } | |
141 | else | |
142 | puts("PASS"); | |
143 | ||
144 | ppdClose(ppd); | |
145 | unlink(ppdfile); | |
146 | } | |
147 | ||
148 | /* | |
149 | * cupsGetJobs() | |
150 | */ | |
151 | ||
152 | fputs("cupsGetJobs: ", stdout); | |
153 | fflush(stdout); | |
154 | ||
155 | num_jobs = cupsGetJobs(&jobs, NULL, 0, -1); | |
156 | ||
157 | if (num_jobs == 0) | |
158 | { | |
159 | puts("FAIL"); | |
160 | return (1); | |
161 | } | |
162 | else | |
163 | puts("PASS"); | |
164 | ||
165 | cupsFreeJobs(num_jobs, jobs); | |
166 | cupsFreeDests(num_dests, dests); | |
167 | ||
168 | return (status); | |
169 | } | |
170 | ||
171 | ||
172 | /* | |
173 | * End of "$Id: testfile.c 6192 2007-01-10 19:26:48Z mike $". | |
174 | */ |