]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/extended.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / extended.c
1 /*
2 * "$Id: extended.c 4494 2005-02-18 02:18:11Z mike $"
3 *
4 * Extended option routines for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
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 * PostScript is a trademark of Adobe Systems, Inc.
25 *
26 * This file is subject to the Apple OS-Developed Software exception.
27 *
28 * Contents:
29 *
30 * ppdFindExtOption() - Return a pointer to the extended option.
31 * ppdMarkCurve() - Mark an extended curve option.
32 * ppdMarkGamma() - Mark an extended gamma option.
33 * ppdMarkInteger() - Mark an extended integer option.
34 * ppdMarkIntegerArray() - Mark an extended integer array option.
35 * ppdMarkReal() - Mark an extended real option.
36 * ppdMarkRealArray() - Mark an extended real array option.
37 * ppdMarkText() - Mark an extended text option.
38 */
39
40 /*
41 * Include necessary headers...
42 */
43
44 #include "ppd.h"
45 #include "string.h"
46 #include "debug.h"
47
48
49 /*
50 * Local functions...
51 */
52
53 static void ppd_unmark_choices(ppd_option_t *option);
54
55
56 /*
57 * 'ppdFindExtOption()' - Return a pointer to the extended option.
58 */
59
60 ppd_ext_option_t * /* O - Pointer to option or NULL */
61 ppdFindExtOption(ppd_file_t *ppd, /* I - PPD file data */
62 const char *option) /* I - Option/Keyword name */
63 {
64 int i; /* Looping var */
65 ppd_ext_option_t **o; /* Pointer to option */
66
67
68 if (ppd == NULL || option == NULL)
69 return (NULL);
70
71 for (i = ppd->num_extended, o = ppd->extended; i > 0; i --, o ++)
72 if (strcasecmp(o[0]->keyword, option) == 0)
73 return (*o);
74
75 return (NULL);
76 }
77
78
79 /*
80 * 'ppdFindExtParam()' - Find an extended parameter.
81 */
82
83 ppd_ext_param_t * /* O - Parameter or NULL */
84 ppdFindExtParam(ppd_ext_option_t *opt, /* I - Option */
85 const char *param)/* I - Parameter name */
86 {
87 int i; /* Looping var */
88 ppd_ext_param_t **p; /* Pointer to parameter */
89
90
91 if (opt == NULL || param == NULL)
92 return (NULL);
93
94 for (i = opt->num_params, p = opt->params; i > 0; i --, p ++)
95 if (strcasecmp(p[0]->keyword, param) == 0)
96 return (*p);
97
98 return (NULL);
99 }
100
101
102 /*
103 * 'ppdMarkCurve()' - Mark an extended curve option.
104 */
105
106 int /* O - Number of conflicts */
107 ppdMarkCurve(ppd_file_t *ppd, /* I - PPD file */
108 const char *keyword, /* I - Option name */
109 const char *param, /* I - Parameter name */
110 float low, /* I - Lower (start) value */
111 float high, /* I - Upper (end) value */
112 float gvalue) /* I - Gamma value for range */
113 {
114 ppd_ext_option_t *o; /* Extended option */
115 ppd_ext_param_t *p; /* Extended parameter */
116
117
118 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
119 return (-1);
120
121 if ((p = ppdFindExtParam(o, param)) == NULL)
122 return (-1);
123
124 ppd_unmark_choices(o->option);
125
126 return (ppdConflicts(ppd));
127 }
128
129
130 /*
131 * 'ppdMarkGamma()' - Mark an extended gamma option.
132 */
133
134 int /* O - Number of conflicts */
135 ppdMarkGamma(ppd_file_t *ppd, /* I - PPD file */
136 const char *keyword, /* I - Option name */
137 const char *param, /* I - Parameter name */
138 float gvalue) /* I - Gamma value */
139 {
140 ppd_ext_option_t *o; /* Extended option */
141 ppd_ext_param_t *p; /* Extended parameter */
142
143
144 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
145 return (-1);
146
147 if ((p = ppdFindExtParam(o, param)) == NULL)
148 return (-1);
149
150 ppd_unmark_choices(o->option);
151
152 return (ppdConflicts(ppd));
153 }
154
155
156 /*
157 * 'ppdMarkInteger()' - Mark an extended integer option.
158 */
159
160 int /* O - Number of conflicts */
161 ppdMarkInteger(ppd_file_t *ppd, /* I - PPD file */
162 const char *keyword, /* I - Option name */
163 const char *param, /* I - Parameter name */
164 int value) /* I - Option value */
165 {
166 ppd_ext_option_t *o; /* Extended option */
167 ppd_ext_param_t *p; /* Extended parameter */
168
169
170 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
171 return (-1);
172
173 if ((p = ppdFindExtParam(o, param)) == NULL)
174 return (-1);
175
176 ppd_unmark_choices(o->option);
177
178 return (ppdConflicts(ppd));
179 }
180
181
182 /*
183 * 'ppdMarkIntegerArray()' - Mark an extended integer array option.
184 */
185
186 int /* O - Number of conflicts */
187 ppdMarkIntegerArray(ppd_file_t *ppd, /* I - PPD file */
188 const char *keyword,/* I - Option name */
189 const char *param, /* I - Parameter name */
190 int num_values,
191 /* I - Number of values */
192 const int *values) /* I - Values */
193 {
194 ppd_ext_option_t *o; /* Extended option */
195 ppd_ext_param_t *p; /* Extended parameter */
196
197
198 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
199 return (-1);
200
201 if ((p = ppdFindExtParam(o, param)) == NULL)
202 return (-1);
203
204 ppd_unmark_choices(o->option);
205
206 return (ppdConflicts(ppd));
207 }
208
209
210 /*
211 * 'ppdMarkReal()' - Mark an extended real option.
212 */
213
214 int /* O - Number of conflicts */
215 ppdMarkReal(ppd_file_t *ppd, /* I - PPD file */
216 const char *keyword, /* I - Option name */
217 const char *param, /* I - Parameter name */
218 float value) /* I - Option value */
219 {
220 ppd_ext_option_t *o; /* Extended option */
221 ppd_ext_param_t *p; /* Extended parameter */
222
223
224 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
225 return (-1);
226
227 if ((p = ppdFindExtParam(o, param)) == NULL)
228 return (-1);
229
230 ppd_unmark_choices(o->option);
231
232 return (ppdConflicts(ppd));
233 }
234
235
236 /*
237 * 'ppdMarkRealArray()' - Mark an extended real array option.
238 */
239
240 int /* O - Number of conflicts */
241 ppdMarkRealArray(ppd_file_t *ppd, /* I - PPD file */
242 const char *keyword, /* I - Option name */
243 const char *param, /* I - Parameter name */
244 int num_values,/* I - Number of values */
245 const float *values) /* I - Values */
246 {
247 ppd_ext_option_t *o; /* Extended option */
248 ppd_ext_param_t *p; /* Extended parameter */
249
250
251 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
252 return (-1);
253
254 if ((p = ppdFindExtParam(o, param)) == NULL)
255 return (-1);
256
257 ppd_unmark_choices(o->option);
258
259 return (ppdConflicts(ppd));
260 }
261
262
263 /*
264 * 'ppdMarkText()' - Mark an extended text option.
265 */
266
267 int /* O - Number of conflicts */
268 ppdMarkText(ppd_file_t *ppd, /* I - PPD file */
269 const char *keyword, /* I - Option name */
270 const char *param, /* I - Parameter name */
271 const char *value) /* I - Option value */
272 {
273 ppd_ext_option_t *o; /* Extended option */
274 ppd_ext_param_t *p; /* Extended parameter */
275
276
277 if ((o = ppdFindExtOption(ppd, keyword)) == NULL)
278 return (-1);
279
280 if ((p = ppdFindExtParam(o, param)) == NULL)
281 return (-1);
282
283 ppd_unmark_choices(o->option);
284
285 return (ppdConflicts(ppd));
286 }
287
288
289 /*
290 * 'ppd_unmark_choices()' - Unmark all "canned" choices.
291 */
292
293 static void
294 ppd_unmark_choices(ppd_option_t *option)/* I - Option choice */
295 {
296 int i; /* Looping var */
297 ppd_choice_t *c; /* Current choice */
298
299
300 for (i = option->num_choices, c = option->choices; i > 0; i --, c++)
301 c->marked = 0;
302 }
303
304
305 /*
306 * End of "$Id: extended.c 4494 2005-02-18 02:18:11Z mike $".
307 */