]>
Commit | Line | Data |
---|---|---|
a129ddbd | 1 | /* |
b2e10895 | 2 | * "$Id$" |
a129ddbd | 3 | * |
cbbfcc63 | 4 | * Printer routines for the Common UNIX Printing System (CUPS). |
a129ddbd | 5 | * |
24c1b5ce | 6 | * Copyright 1997-2006 by Easy Software Products, all rights reserved. |
a129ddbd | 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 | |
8784b6a6 | 17 | * 44141 Airport View Drive, Suite 204 |
8650fcf2 | 18 | * Hollywood, Maryland 20636 USA |
a129ddbd | 19 | * |
edfd3c3d | 20 | * Voice: (301) 373-9600 |
a129ddbd | 21 | * EMail: cups-info@cups.org |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * Contents: | |
25 | * | |
589eb420 | 26 | * cupsdAddPrinter() - Add a printer to the system. |
589eb420 | 27 | * cupsdAddPrinterHistory() - Add the current printer state to the history. |
28 | * cupsdAddPrinterUser() - Add a user to the ACL. | |
29 | * cupsdDeleteAllPrinters() - Delete all printers from the system. | |
30 | * cupsdDeletePrinter() - Delete a printer from the system. | |
31 | * cupsdDeletePrinterFilters() - Delete all MIME filters for a printer. | |
32 | * cupsdFindPrinter() - Find a printer in the list. | |
33 | * cupsdFreePrinterUsers() - Free allow/deny users. | |
34 | * cupsdLoadAllPrinters() - Load printers from the printers.conf file. | |
04907de7 | 35 | * cupsdSaveAllPrinters() - Save all printer definitions to the |
36 | * printers.conf file. | |
37 | * cupsdSetPrinterAttrs() - Set printer attributes based upon the PPD | |
38 | * file. | |
589eb420 | 39 | * cupsdSetPrinterReasons() - Set/update the reasons strings. |
40 | * cupsdSetPrinterState() - Update the current state of a printer. | |
589eb420 | 41 | * cupsdStopPrinter() - Stop a printer from printing any jobs... |
87650f55 | 42 | * cupsdUpdatePrinters() - Update printers after a partial reload. |
589eb420 | 43 | * cupsdValidateDest() - Validate a printer/class destination. |
44 | * cupsdWritePrintcap() - Write a pseudo-printcap file for older | |
f3e786fc | 45 | * applications that need it... |
46 | * cupsdSanitizeURI() - Sanitize a device URI... | |
d318937f | 47 | * add_printer_filter() - Add a MIME filter for a printer. |
48 | * add_printer_formats() - Add document-format-supported values for | |
49 | * a printer. | |
f3e786fc | 50 | * compare_printers() - Compare two printers. |
cf0959e5 | 51 | * transcode_nickname() - Convert the PPD NickName to UTF-8... |
f3e786fc | 52 | * write_irix_config() - Update the config files used by the IRIX |
53 | * desktop tools. | |
04907de7 | 54 | * write_irix_state() - Update the status files used by IRIX |
55 | * printing desktop tools. | |
a129ddbd | 56 | */ |
57 | ||
58 | /* | |
59 | * Include necessary headers... | |
60 | */ | |
61 | ||
fd8b1cf8 | 62 | #include "cupsd.h" |
cf0959e5 | 63 | #include <cups/transcode.h> |
a129ddbd | 64 | |
65 | ||
9cd605da | 66 | /* |
67 | * Local functions... | |
68 | */ | |
69 | ||
d318937f | 70 | static void add_printer_filter(cupsd_printer_t *p, const char *filter); |
71 | static void add_printer_formats(cupsd_printer_t *p); | |
90231631 | 72 | static int compare_printers(void *first, void *second, void *data); |
cf0959e5 | 73 | static void transcode_nickname(cupsd_printer_t *p, ppd_file_t *ppd); |
9ae34eb7 | 74 | #ifdef __sgi |
589eb420 | 75 | static void write_irix_config(cupsd_printer_t *p); |
76 | static void write_irix_state(cupsd_printer_t *p); | |
9ae34eb7 | 77 | #endif /* __sgi */ |
9cd605da | 78 | |
79 | ||
a129ddbd | 80 | /* |
589eb420 | 81 | * 'cupsdAddPrinter()' - Add a printer to the system. |
a9de544f | 82 | */ |
83 | ||
589eb420 | 84 | cupsd_printer_t * /* O - New printer */ |
85 | cupsdAddPrinter(const char *name) /* I - Name of printer */ | |
a9de544f | 86 | { |
589eb420 | 87 | cupsd_printer_t *p; /* New printer */ |
a9de544f | 88 | |
89 | ||
90 | /* | |
91 | * Range check input... | |
92 | */ | |
93 | ||
f3e786fc | 94 | cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddPrinter(\"%s\")", name); |
a9de544f | 95 | |
96 | /* | |
97 | * Create a new printer entity... | |
98 | */ | |
99 | ||
589eb420 | 100 | if ((p = calloc(1, sizeof(cupsd_printer_t))) == NULL) |
36564e2c | 101 | { |
f3e786fc | 102 | cupsdLogMessage(CUPSD_LOG_CRIT, "Unable to allocate memory for printer - %s", |
103 | strerror(errno)); | |
a9de544f | 104 | return (NULL); |
36564e2c | 105 | } |
a9de544f | 106 | |
589eb420 | 107 | cupsdSetString(&p->name, name); |
108 | cupsdSetString(&p->info, name); | |
109 | cupsdSetString(&p->hostname, ServerName); | |
99de6da0 | 110 | |
589eb420 | 111 | cupsdSetStringf(&p->uri, "ipp://%s:%d/printers/%s", ServerName, LocalPort, name); |
112 | cupsdSetStringf(&p->device_uri, "file:/dev/null"); | |
d588a92e | 113 | |
ffd99efd | 114 | p->state = IPP_PRINTER_STOPPED; |
115 | p->state_time = time(NULL); | |
116 | p->accepting = 0; | |
04907de7 | 117 | p->shared = DefaultShared; |
ffd99efd | 118 | p->filetype = mimeAddType(MimeDatabase, "printer", name); |
c7fa9d06 | 119 | |
f3e786fc | 120 | cupsdSetString(&p->job_sheets[0], "none"); |
121 | cupsdSetString(&p->job_sheets[1], "none"); | |
e175d98d | 122 | |
589eb420 | 123 | cupsdSetString(&p->error_policy, "stop-printer"); |
124 | cupsdSetString(&p->op_policy, DefaultPolicy); | |
21d970f2 | 125 | |
126 | p->op_policy_ptr = DefaultPolicyPtr; | |
127 | ||
62bcac22 | 128 | if (MaxPrinterHistory) |
129 | p->history = calloc(MaxPrinterHistory, sizeof(ipp_t *)); | |
a3e17a89 | 130 | |
a9de544f | 131 | /* |
132 | * Insert the printer in the printer list alphabetically... | |
133 | */ | |
134 | ||
90231631 | 135 | if (!Printers) |
136 | Printers = cupsArrayNew(compare_printers, NULL); | |
a9de544f | 137 | |
90231631 | 138 | cupsArrayAdd(Printers, p); |
a9de544f | 139 | |
e5dc1f76 | 140 | if (!ImplicitPrinters) |
141 | ImplicitPrinters = cupsArrayNew(compare_printers, NULL); | |
142 | ||
ba886a95 | 143 | /* |
90231631 | 144 | * Return the new printer... |
ba886a95 | 145 | */ |
146 | ||
a9de544f | 147 | return (p); |
148 | } | |
149 | ||
150 | ||
62bcac22 | 151 | /* |
589eb420 | 152 | * 'cupsdAddPrinterHistory()' - Add the current printer state to the history. |
62bcac22 | 153 | */ |
154 | ||
155 | void | |
f3e786fc | 156 | cupsdAddPrinterHistory( |
157 | cupsd_printer_t *p) /* I - Printer */ | |
62bcac22 | 158 | { |
159 | ipp_t *history; /* History collection */ | |
160 | ||
161 | ||
162 | /* | |
163 | * Stop early if we aren't keeping history data... | |
164 | */ | |
165 | ||
166 | if (MaxPrinterHistory <= 0) | |
167 | return; | |
168 | ||
169 | /* | |
170 | * Retire old history data as needed... | |
171 | */ | |
172 | ||
c8a55d2c | 173 | p->sequence_number ++; |
174 | ||
62bcac22 | 175 | if (p->num_history >= MaxPrinterHistory) |
176 | { | |
177 | p->num_history --; | |
178 | ippDelete(p->history[0]); | |
179 | memmove(p->history, p->history + 1, p->num_history * sizeof(ipp_t *)); | |
180 | } | |
181 | ||
182 | /* | |
183 | * Create a collection containing the current printer-state, printer-up-time, | |
184 | * printer-state-message, and printer-state-reasons attributes. | |
185 | */ | |
186 | ||
187 | history = ippNew(); | |
188 | ippAddInteger(history, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", | |
189 | p->state); | |
c8a55d2c | 190 | ippAddBoolean(history, IPP_TAG_PRINTER, "printer-is-accepting-jobs", |
191 | p->accepting); | |
04907de7 | 192 | ippAddBoolean(history, IPP_TAG_PRINTER, "printer-is-shared", p->shared); |
62bcac22 | 193 | ippAddString(history, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-state-message", |
194 | NULL, p->state_message); | |
7c9b0290 | 195 | #ifdef __APPLE__ |
196 | if (p->recoverable) | |
197 | ippAddString(history, IPP_TAG_PRINTER, IPP_TAG_TEXT, | |
198 | "com.apple.print.recoverable-message", NULL, p->recoverable); | |
199 | #endif /* __APPLE__ */ | |
62bcac22 | 200 | if (p->num_reasons == 0) |
201 | ippAddString(history, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
202 | "printer-state-reasons", NULL, | |
203 | p->state == IPP_PRINTER_STOPPED ? "paused" : "none"); | |
204 | else | |
205 | ippAddStrings(history, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
206 | "printer-state-reasons", p->num_reasons, NULL, | |
207 | (const char * const *)p->reasons); | |
c8a55d2c | 208 | ippAddInteger(history, IPP_TAG_PRINTER, IPP_TAG_INTEGER, |
ffd99efd | 209 | "printer-state-change-time", p->state_time); |
c8a55d2c | 210 | ippAddInteger(history, IPP_TAG_PRINTER, IPP_TAG_INTEGER, |
211 | "printer-state-sequence-number", p->sequence_number); | |
62bcac22 | 212 | |
213 | p->history[p->num_history] = history; | |
214 | p->num_history ++; | |
215 | } | |
216 | ||
217 | ||
d7845573 | 218 | /* |
589eb420 | 219 | * 'cupsdAddPrinterUser()' - Add a user to the ACL. |
d7845573 | 220 | */ |
221 | ||
222 | void | |
f3e786fc | 223 | cupsdAddPrinterUser( |
224 | cupsd_printer_t *p, /* I - Printer */ | |
225 | const char *username) /* I - User */ | |
d7845573 | 226 | { |
227 | const char **temp; /* Temporary array pointer */ | |
228 | ||
229 | ||
230 | if (!p || !username) | |
231 | return; | |
232 | ||
233 | if (p->num_users == 0) | |
234 | temp = malloc(sizeof(char **)); | |
235 | else | |
236 | temp = realloc(p->users, sizeof(char **) * (p->num_users + 1)); | |
237 | ||
238 | if (!temp) | |
239 | return; | |
240 | ||
241 | p->users = temp; | |
242 | temp += p->num_users; | |
243 | ||
244 | if ((*temp = strdup(username)) != NULL) | |
245 | p->num_users ++; | |
246 | } | |
247 | ||
248 | ||
67c158fa | 249 | /* |
589eb420 | 250 | * 'cupsdCreateCommonData()' - Create the common printer data. |
67c158fa | 251 | */ |
252 | ||
253 | void | |
589eb420 | 254 | cupsdCreateCommonData(void) |
67c158fa | 255 | { |
f3e786fc | 256 | int i; /* Looping var */ |
257 | ipp_attribute_t *attr; /* Attribute data */ | |
67c158fa | 258 | static const int nups[] = /* number-up-supported values */ |
259 | { 1, 2, 4, 6, 9, 16 }; | |
260 | static const ipp_orient_t orients[4] =/* orientation-requested-supported values */ | |
261 | { | |
262 | IPP_PORTRAIT, | |
263 | IPP_LANDSCAPE, | |
264 | IPP_REVERSE_LANDSCAPE, | |
265 | IPP_REVERSE_PORTRAIT | |
266 | }; | |
267 | static const char * const holds[] = /* job-hold-until-supported values */ | |
268 | { | |
269 | "no-hold", | |
270 | "indefinite", | |
271 | "day-time", | |
272 | "evening", | |
273 | "night", | |
274 | "second-shift", | |
275 | "third-shift", | |
276 | "weekend" | |
277 | }; | |
278 | static const char * const versions[] =/* ipp-versions-supported values */ | |
279 | { | |
280 | "1.0", | |
281 | "1.1" | |
282 | }; | |
283 | static const ipp_op_t ops[] = /* operations-supported values */ | |
284 | { | |
285 | IPP_PRINT_JOB, | |
286 | IPP_VALIDATE_JOB, | |
287 | IPP_CREATE_JOB, | |
288 | IPP_SEND_DOCUMENT, | |
289 | IPP_CANCEL_JOB, | |
290 | IPP_GET_JOB_ATTRIBUTES, | |
291 | IPP_GET_JOBS, | |
292 | IPP_GET_PRINTER_ATTRIBUTES, | |
293 | IPP_HOLD_JOB, | |
294 | IPP_RELEASE_JOB, | |
295 | IPP_PAUSE_PRINTER, | |
296 | IPP_RESUME_PRINTER, | |
297 | IPP_PURGE_JOBS, | |
298 | IPP_SET_JOB_ATTRIBUTES, | |
a4b3db80 | 299 | IPP_CREATE_PRINTER_SUBSCRIPTION, |
300 | IPP_CREATE_JOB_SUBSCRIPTION, | |
301 | IPP_GET_SUBSCRIPTION_ATTRIBUTES, | |
302 | IPP_GET_SUBSCRIPTIONS, | |
303 | IPP_RENEW_SUBSCRIPTION, | |
304 | IPP_CANCEL_SUBSCRIPTION, | |
305 | IPP_GET_NOTIFICATIONS, | |
67c158fa | 306 | IPP_ENABLE_PRINTER, |
307 | IPP_DISABLE_PRINTER, | |
308 | CUPS_GET_DEFAULT, | |
309 | CUPS_GET_PRINTERS, | |
310 | CUPS_ADD_PRINTER, | |
311 | CUPS_DELETE_PRINTER, | |
312 | CUPS_GET_CLASSES, | |
313 | CUPS_ADD_CLASS, | |
314 | CUPS_DELETE_CLASS, | |
315 | CUPS_ACCEPT_JOBS, | |
316 | CUPS_REJECT_JOBS, | |
48e211f3 | 317 | CUPS_SET_DEFAULT, |
67c158fa | 318 | CUPS_GET_DEVICES, |
319 | CUPS_GET_PPDS, | |
48e211f3 | 320 | CUPS_MOVE_JOB, |
321 | CUPS_AUTHENTICATE_JOB, | |
67c158fa | 322 | IPP_RESTART_JOB |
323 | }; | |
324 | static const char * const charsets[] =/* charset-supported values */ | |
325 | { | |
326 | "us-ascii", | |
a4b3db80 | 327 | "utf-8" |
67c158fa | 328 | }; |
329 | static const char * const compressions[] = | |
330 | { /* document-compression-supported values */ | |
331 | "none" | |
332 | #ifdef HAVE_LIBZ | |
333 | ,"gzip" | |
334 | #endif /* HAVE_LIBZ */ | |
335 | }; | |
336 | static const char * const multiple_document_handling[] = | |
337 | { /* multiple-document-handling-supported values */ | |
338 | "separate-documents-uncollated-copies", | |
339 | "separate-documents-collated-copies" | |
340 | }; | |
0f9c1053 | 341 | static const char * const errors[] = /* printer-error-policy-supported values */ |
342 | { | |
343 | "abort-job", | |
344 | "retry-job", | |
345 | "stop-printer" | |
346 | }; | |
64ecb863 | 347 | static const char * const notify_attrs[] = |
348 | { /* notify-attributes-supported values */ | |
349 | "printer-state-change-time", | |
350 | "notify-lease-expiration-time", | |
351 | "notify-subscriber-user-name" | |
352 | }; | |
353 | static const char * const notify_events[] = | |
354 | { /* notify-events-supported values */ | |
355 | "job-completed", | |
356 | "job-config-changed", | |
357 | "job-created", | |
358 | "job-progress", | |
359 | "job-state-changed", | |
360 | "job-stopped", | |
361 | "printer-added", | |
362 | "printer-changed", | |
363 | "printer-config-changed", | |
364 | "printer-deleted", | |
365 | "printer-finishings-changed", | |
366 | "printer-media-changed", | |
367 | "printer-modified", | |
368 | "printer-restarted", | |
369 | "printer-shutdown", | |
370 | "printer-state-changed", | |
371 | "printer-stopped", | |
372 | "server-audit", | |
373 | "server-restarted", | |
374 | "server-started", | |
375 | "server-stopped" | |
376 | }; | |
67c158fa | 377 | |
378 | ||
379 | if (CommonData) | |
380 | ippDelete(CommonData); | |
381 | ||
382 | CommonData = ippNew(); | |
383 | ||
64ecb863 | 384 | /* |
385 | * This list of attributes is sorted to improve performance when the | |
386 | * client provides a requested-attributes attribute... | |
387 | */ | |
388 | ||
389 | /* charset-configured */ | |
67c158fa | 390 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_CHARSET, |
391 | "charset-configured", NULL, DefaultCharset); | |
64ecb863 | 392 | |
393 | /* charset-supported */ | |
67c158fa | 394 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_CHARSET, |
395 | "charset-supported", sizeof(charsets) / sizeof(charsets[0]), | |
396 | NULL, charsets); | |
64ecb863 | 397 | |
398 | /* compression-supported */ | |
67c158fa | 399 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, |
400 | "compression-supported", | |
401 | sizeof(compressions) / sizeof(compressions[0]), | |
402 | NULL, compressions); | |
64ecb863 | 403 | |
404 | /* TODO: move to printer-specific section! */ | |
405 | /* copies-default */ | |
67c158fa | 406 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, |
407 | "copies-default", 1); | |
64ecb863 | 408 | |
409 | /* copies-supported */ | |
410 | ippAddRange(CommonData, IPP_TAG_PRINTER, "copies-supported", 1, MaxCopies); | |
411 | ||
412 | /* TODO: move to printer-specific section! */ | |
413 | /* document-format-default */ | |
414 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, | |
415 | "document-format-default", NULL, "application/octet-stream"); | |
416 | ||
64ecb863 | 417 | /* generated-natural-language-supported */ |
418 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE, | |
419 | "generated-natural-language-supported", NULL, DefaultLanguage); | |
420 | ||
421 | /* ipp-versions-supported */ | |
67c158fa | 422 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, |
64ecb863 | 423 | "ipp-versions-supported", sizeof(versions) / sizeof(versions[0]), |
424 | NULL, versions); | |
425 | ||
426 | /* TODO: move to printer-specific section! */ | |
427 | /* job-hold-until-default */ | |
67c158fa | 428 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, |
429 | "job-hold-until-default", NULL, "no-hold"); | |
430 | ||
64ecb863 | 431 | /* job-hold-until-supported */ |
432 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
433 | "job-hold-until-supported", sizeof(holds) / sizeof(holds[0]), | |
434 | NULL, holds); | |
435 | ||
436 | /* TODO: move to printer-specific section! */ | |
437 | /* job-priority-default */ | |
438 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
439 | "job-priority-default", 50); | |
440 | ||
441 | /* job-priority-supported */ | |
442 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
443 | "job-priority-supported", 100); | |
444 | ||
445 | /* job-sheets-supported */ | |
92ed2c7c | 446 | if (cupsArrayCount(Banners) > 0) |
67c158fa | 447 | { |
448 | /* | |
64ecb863 | 449 | * Setup the job-sheets-supported attribute... |
67c158fa | 450 | */ |
451 | ||
452 | if (Classification && !ClassifyOverride) | |
453 | attr = ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
454 | "job-sheets-supported", NULL, Classification); | |
455 | else | |
456 | attr = ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
92ed2c7c | 457 | "job-sheets-supported", cupsArrayCount(Banners) + 1, |
458 | NULL, NULL); | |
67c158fa | 459 | |
460 | if (attr == NULL) | |
f3e786fc | 461 | cupsdLogMessage(CUPSD_LOG_EMERG, |
d318937f | 462 | "Unable to allocate memory for " |
f3e786fc | 463 | "job-sheets-supported attribute: %s!", strerror(errno)); |
67c158fa | 464 | else if (!Classification || ClassifyOverride) |
465 | { | |
92ed2c7c | 466 | cupsd_banner_t *banner; /* Current banner */ |
467 | ||
468 | ||
fc957d47 | 469 | attr->values[0].string.text = _cups_sp_alloc("none"); |
67c158fa | 470 | |
92ed2c7c | 471 | for (i = 1, banner = (cupsd_banner_t *)cupsArrayFirst(Banners); |
472 | banner; | |
473 | i ++, banner = (cupsd_banner_t *)cupsArrayNext(Banners)) | |
fc957d47 | 474 | attr->values[i].string.text = _cups_sp_alloc(banner->name); |
67c158fa | 475 | } |
476 | } | |
64ecb863 | 477 | else |
478 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
479 | "job-sheets-supported", NULL, "none"); | |
e175d98d | 480 | |
64ecb863 | 481 | /* multiple-document-handling-supported */ |
482 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
483 | "multiple-document-handling-supported", | |
484 | sizeof(multiple_document_handling) / | |
485 | sizeof(multiple_document_handling[0]), NULL, | |
486 | multiple_document_handling); | |
e175d98d | 487 | |
64ecb863 | 488 | /* multiple-document-jobs-supported */ |
489 | ippAddBoolean(CommonData, IPP_TAG_PRINTER, | |
490 | "multiple-document-jobs-supported", 1); | |
491 | ||
492 | /* multiple-operation-time-out */ | |
493 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
494 | "multiple-operation-time-out", 60); | |
495 | ||
496 | /* natural-language-configured */ | |
497 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE, | |
498 | "natural-language-configured", NULL, DefaultLanguage); | |
499 | ||
500 | /* notify-attributes-supported */ | |
501 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
502 | "notify-attributes-supported", | |
503 | (int)(sizeof(notify_attrs) / sizeof(notify_attrs[0])), | |
504 | NULL, notify_attrs); | |
505 | ||
506 | /* TODO: move to printer-specific section! */ | |
507 | /* notify-lease-duration-default */ | |
508 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
509 | "notify-lease-duration-default", DefaultLeaseDuration); | |
510 | ||
511 | /* notify-lease-duration-supported */ | |
512 | ippAddRange(CommonData, IPP_TAG_PRINTER, | |
513 | "notify-lease-duration-supported", 0, | |
514 | MaxLeaseDuration ? MaxLeaseDuration : 2147483647); | |
515 | ||
516 | /* notify-max-events-supported */ | |
517 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
518 | "notify-max-events-supported", MaxEvents); | |
519 | ||
520 | /* notify-notify-events-default */ | |
521 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
522 | "notify-events-default", NULL, "job-completed"); | |
523 | ||
524 | /* notify-notify-events-supported */ | |
525 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
526 | "notify-events-supported", | |
527 | (int)(sizeof(notify_events) / sizeof(notify_events[0])), | |
528 | NULL, notify_events); | |
529 | ||
530 | /* notify-pull-method-supported */ | |
531 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
532 | "notify-pull-method-supported", NULL, "ippget"); | |
533 | ||
534 | /* TODO: scan notifier directory */ | |
535 | /* notify-schemes-supported */ | |
536 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
537 | "notify-schemes-supported", NULL, "mailto"); | |
538 | ||
539 | /* TODO: move to printer-specific section! */ | |
540 | /* number-up-default */ | |
541 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
542 | "number-up-default", 1); | |
543 | ||
544 | /* number-up-supported */ | |
545 | ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
546 | "number-up-supported", sizeof(nups) / sizeof(nups[0]), nups); | |
547 | ||
548 | /* operations-supported */ | |
549 | ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM, | |
550 | "operations-supported", | |
551 | sizeof(ops) / sizeof(ops[0]) + JobFiles - 1, (int *)ops); | |
552 | ||
553 | /* TODO: move to printer-specific section! */ | |
554 | /* orientation-requested-default */ | |
555 | ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM, | |
556 | "orientation-requested-default", IPP_PORTRAIT); | |
557 | ||
558 | /* orientation-requested-supported */ | |
559 | ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM, | |
560 | "orientation-requested-supported", 4, (int *)orients); | |
561 | ||
562 | /* page-ranges-supported */ | |
563 | ippAddBoolean(CommonData, IPP_TAG_PRINTER, "page-ranges-supported", 1); | |
564 | ||
565 | /* pdf-override-supported */ | |
566 | ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
567 | "pdl-override-supported", NULL, "not-attempted"); | |
568 | ||
569 | /* printer-error-policy-supported */ | |
570 | ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
571 | "printer-error-policy-supported", | |
572 | sizeof(errors) / sizeof(errors[0]), NULL, errors); | |
573 | ||
574 | /* printer-op-policy-supported */ | |
575 | attr = ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
576 | "printer-op-policy-supported", NumPolicies, NULL, NULL); | |
577 | for (i = 0; i < NumPolicies; i ++) | |
fc957d47 | 578 | attr->values[i].string.text = _cups_sp_alloc(Policies[i]->name); |
67c158fa | 579 | } |
580 | ||
581 | ||
a9de544f | 582 | /* |
589eb420 | 583 | * 'cupsdDeleteAllPrinters()' - Delete all printers from the system. |
a9de544f | 584 | */ |
585 | ||
586 | void | |
589eb420 | 587 | cupsdDeleteAllPrinters(void) |
a9de544f | 588 | { |
f3e786fc | 589 | cupsd_printer_t *p; /* Pointer to current printer/class */ |
cbbfcc63 | 590 | |
591 | ||
589eb420 | 592 | for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); |
90231631 | 593 | p; |
589eb420 | 594 | p = (cupsd_printer_t *)cupsArrayNext(Printers)) |
cbbfcc63 | 595 | if (!(p->type & CUPS_PRINTER_CLASS)) |
589eb420 | 596 | cupsdDeletePrinter(p, 0); |
a9de544f | 597 | } |
598 | ||
599 | ||
600 | /* | |
589eb420 | 601 | * 'cupsdDeletePrinter()' - Delete a printer from the system. |
a9de544f | 602 | */ |
603 | ||
604 | void | |
f3e786fc | 605 | cupsdDeletePrinter( |
606 | cupsd_printer_t *p, /* I - Printer to delete */ | |
607 | int update) /* I - Update printers.conf? */ | |
a9de544f | 608 | { |
ba886a95 | 609 | int i; /* Looping var */ |
9cd605da | 610 | #ifdef __sgi |
ba886a95 | 611 | char filename[1024]; /* Interface script filename */ |
9cd605da | 612 | #endif /* __sgi */ |
a9de544f | 613 | |
614 | ||
0ccebdfa | 615 | cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdDeletePrinter(p=%p(%s), update=%d)", |
616 | p, p->name, update); | |
e63d9801 | 617 | |
81b79f9a | 618 | /* |
619 | * Save the current position in the Printers array... | |
620 | */ | |
621 | ||
622 | cupsArraySave(Printers); | |
623 | ||
1b7c45db | 624 | /* |
625 | * Stop printing on this printer... | |
626 | */ | |
627 | ||
628 | cupsdStopPrinter(p, update); | |
629 | ||
a9de544f | 630 | /* |
90231631 | 631 | * If this printer is the next for browsing, point to the next one... |
a9de544f | 632 | */ |
633 | ||
90231631 | 634 | if (p == BrowseNext) |
a9de544f | 635 | { |
90231631 | 636 | cupsArrayFind(Printers, p); |
589eb420 | 637 | BrowseNext = (cupsd_printer_t *)cupsArrayNext(Printers); |
a9de544f | 638 | } |
639 | ||
ba886a95 | 640 | /* |
641 | * Remove the printer from the list... | |
642 | */ | |
643 | ||
90231631 | 644 | cupsArrayRemove(Printers, p); |
ba886a95 | 645 | |
a6988fb1 | 646 | /* |
647 | * Remove the dummy interface/icon/option files under IRIX... | |
648 | */ | |
9cd605da | 649 | |
650 | #ifdef __sgi | |
a6988fb1 | 651 | snprintf(filename, sizeof(filename), "/var/spool/lp/interface/%s", p->name); |
9cd605da | 652 | unlink(filename); |
653 | ||
a6988fb1 | 654 | snprintf(filename, sizeof(filename), "/var/spool/lp/gui_interface/ELF/%s.gui", |
655 | p->name); | |
9cd605da | 656 | unlink(filename); |
30f1fa61 | 657 | |
a6988fb1 | 658 | snprintf(filename, sizeof(filename), "/var/spool/lp/activeicons/%s", p->name); |
30f1fa61 | 659 | unlink(filename); |
9ae34eb7 | 660 | |
661 | snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.config", p->name); | |
662 | unlink(filename); | |
663 | ||
664 | snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.status", p->name); | |
665 | unlink(filename); | |
cb9d2abc | 666 | |
667 | snprintf(filename, sizeof(filename), "/var/spool/lp/member/%s", p->name); | |
668 | unlink(filename); | |
9cd605da | 669 | #endif /* __sgi */ |
3d299a9d | 670 | |
8d853fdf | 671 | /* |
5bd8a9fa | 672 | * If p is the default printer, assign a different one... |
8d853fdf | 673 | */ |
674 | ||
675 | if (p == DefaultPrinter) | |
5bd8a9fa | 676 | { |
677 | DefaultPrinter = NULL; | |
678 | ||
679 | if (UseNetworkDefault) | |
680 | { | |
681 | /* | |
682 | * Find the first network default printer and use it... | |
683 | */ | |
684 | ||
685 | cupsd_printer_t *dp; /* New default printer */ | |
686 | ||
687 | ||
688 | for (dp = (cupsd_printer_t *)cupsArrayFirst(Printers); | |
689 | dp; | |
690 | dp = (cupsd_printer_t *)cupsArrayNext(Printers)) | |
691 | if (dp != p && (dp->type & CUPS_PRINTER_DEFAULT)) | |
692 | { | |
693 | DefaultPrinter = p; | |
694 | break; | |
695 | } | |
696 | } | |
697 | } | |
8d853fdf | 698 | |
699 | /* | |
903511b4 | 700 | * Remove this printer from any classes and send a browse delete message... |
8d853fdf | 701 | */ |
702 | ||
238f6a6e | 703 | if (!(p->type & CUPS_PRINTER_IMPLICIT)) |
903511b4 | 704 | { |
589eb420 | 705 | cupsdDeletePrinterFromClasses(p); |
706 | cupsdSendBrowseDelete(p); | |
903511b4 | 707 | } |
8d853fdf | 708 | |
3d299a9d | 709 | /* |
a6988fb1 | 710 | * Free all memory used by the printer... |
3d299a9d | 711 | */ |
712 | ||
713 | if (p->printers != NULL) | |
714 | free(p->printers); | |
715 | ||
62bcac22 | 716 | if (MaxPrinterHistory) |
717 | { | |
718 | for (i = 0; i < p->num_history; i ++) | |
719 | ippDelete(p->history[i]); | |
720 | ||
721 | free(p->history); | |
722 | } | |
723 | ||
724 | for (i = 0; i < p->num_reasons; i ++) | |
725 | free(p->reasons[i]); | |
726 | ||
3d299a9d | 727 | ippDelete(p->attrs); |
728 | ||
589eb420 | 729 | cupsdDeletePrinterFilters(p); |
3d299a9d | 730 | |
0557217b | 731 | mimeDeleteType(MimeDatabase, p->filetype); |
732 | ||
589eb420 | 733 | cupsdFreePrinterUsers(p); |
734 | cupsdFreeQuotas(p); | |
d7845573 | 735 | |
589eb420 | 736 | cupsdClearString(&p->uri); |
737 | cupsdClearString(&p->hostname); | |
738 | cupsdClearString(&p->name); | |
739 | cupsdClearString(&p->location); | |
740 | cupsdClearString(&p->make_model); | |
741 | cupsdClearString(&p->info); | |
f3e786fc | 742 | cupsdClearString(&p->job_sheets[0]); |
743 | cupsdClearString(&p->job_sheets[1]); | |
589eb420 | 744 | cupsdClearString(&p->device_uri); |
745 | cupsdClearString(&p->port_monitor); | |
746 | cupsdClearString(&p->op_policy); | |
747 | cupsdClearString(&p->error_policy); | |
36992080 | 748 | |
7c9b0290 | 749 | #ifdef __APPLE__ |
750 | cupsdClearString(&p->recoverable); | |
751 | #endif /* __APPLE__ */ | |
752 | ||
3d299a9d | 753 | free(p); |
81b79f9a | 754 | |
755 | /* | |
756 | * Restore the previous position in the Printers array... | |
757 | */ | |
758 | ||
759 | cupsArrayRestore(Printers); | |
a9de544f | 760 | } |
761 | ||
762 | ||
c7fa9d06 | 763 | /* |
589eb420 | 764 | * 'cupsdDeletePrinterFilters()' - Delete all MIME filters for a printer. |
c7fa9d06 | 765 | */ |
766 | ||
767 | void | |
f3e786fc | 768 | cupsdDeletePrinterFilters( |
769 | cupsd_printer_t *p) /* I - Printer to remove from */ | |
c7fa9d06 | 770 | { |
c7fa9d06 | 771 | mime_filter_t *filter; /* MIME filter looping var */ |
772 | ||
773 | ||
774 | /* | |
775 | * Range check input... | |
776 | */ | |
777 | ||
778 | if (p == NULL) | |
779 | return; | |
780 | ||
781 | /* | |
782 | * Remove all filters from the MIME database that have a destination | |
783 | * type == printer... | |
784 | */ | |
785 | ||
0557217b | 786 | for (filter = mimeFirstFilter(MimeDatabase); |
787 | filter; | |
788 | filter = mimeNextFilter(MimeDatabase)) | |
c7fa9d06 | 789 | if (filter->dst == p->filetype) |
790 | { | |
791 | /* | |
792 | * Delete the current filter... | |
793 | */ | |
794 | ||
0557217b | 795 | mimeDeleteFilter(MimeDatabase, filter); |
c7fa9d06 | 796 | } |
797 | } | |
798 | ||
799 | ||
8bd0441f | 800 | /* |
589eb420 | 801 | * 'cupsdFindDest()' - Find a destination in the list. |
8bd0441f | 802 | */ |
803 | ||
589eb420 | 804 | cupsd_printer_t * /* O - Destination in list */ |
f3e786fc | 805 | cupsdFindDest(const char *name) /* I - Name of printer or class to find */ |
8bd0441f | 806 | { |
589eb420 | 807 | cupsd_printer_t key; /* Search key */ |
8bd0441f | 808 | |
809 | ||
90231631 | 810 | key.name = (char *)name; |
589eb420 | 811 | return ((cupsd_printer_t *)cupsArrayFind(Printers, &key)); |
8bd0441f | 812 | } |
813 | ||
814 | ||
a9de544f | 815 | /* |
589eb420 | 816 | * 'cupsdFindPrinter()' - Find a printer in the list. |
a9de544f | 817 | */ |
818 | ||
589eb420 | 819 | cupsd_printer_t * /* O - Printer in list */ |
820 | cupsdFindPrinter(const char *name) /* I - Name of printer to find */ | |
a9de544f | 821 | { |
589eb420 | 822 | cupsd_printer_t *p; /* Printer in list */ |
a9de544f | 823 | |
824 | ||
589eb420 | 825 | if ((p = cupsdFindDest(name)) != NULL && (p->type & CUPS_PRINTER_CLASS)) |
90231631 | 826 | return (NULL); |
827 | else | |
828 | return (p); | |
a9de544f | 829 | } |
830 | ||
831 | ||
d7845573 | 832 | /* |
589eb420 | 833 | * 'cupsdFreePrinterUsers()' - Free allow/deny users. |
d7845573 | 834 | */ |
835 | ||
836 | void | |
f3e786fc | 837 | cupsdFreePrinterUsers( |
838 | cupsd_printer_t *p) /* I - Printer */ | |
d7845573 | 839 | { |
f3e786fc | 840 | int i; /* Looping var */ |
d7845573 | 841 | |
842 | ||
843 | if (!p || !p->num_users) | |
844 | return; | |
845 | ||
846 | for (i = 0; i < p->num_users; i ++) | |
847 | free((void *)p->users[i]); | |
848 | ||
849 | free(p->users); | |
850 | ||
851 | p->num_users = 0; | |
852 | p->users = NULL; | |
853 | } | |
854 | ||
855 | ||
a9de544f | 856 | /* |
589eb420 | 857 | * 'cupsdLoadAllPrinters()' - Load printers from the printers.conf file. |
a9de544f | 858 | */ |
859 | ||
860 | void | |
589eb420 | 861 | cupsdLoadAllPrinters(void) |
a9de544f | 862 | { |
f3e786fc | 863 | cups_file_t *fp; /* printers.conf file */ |
864 | int linenum; /* Current line number */ | |
865 | char line[1024], /* Line from file */ | |
866 | *value, /* Pointer to value */ | |
867 | *valueptr; /* Pointer into value */ | |
868 | cupsd_printer_t *p; /* Current printer */ | |
a9de544f | 869 | |
870 | ||
871 | /* | |
7db52463 | 872 | * Open the printers.conf file... |
a9de544f | 873 | */ |
874 | ||
a6988fb1 | 875 | snprintf(line, sizeof(line), "%s/printers.conf", ServerRoot); |
7b0fde61 | 876 | if ((fp = cupsFileOpen(line, "r")) == NULL) |
d47f8ebe | 877 | { |
b246a60a | 878 | if (errno != ENOENT) |
d318937f | 879 | cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open %s - %s", line, |
b246a60a | 880 | strerror(errno)); |
a9de544f | 881 | return; |
d47f8ebe | 882 | } |
a9de544f | 883 | |
884 | /* | |
885 | * Read printer configurations until we hit EOF... | |
886 | */ | |
887 | ||
888 | linenum = 0; | |
889 | p = NULL; | |
890 | ||
4a1c4581 | 891 | while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) |
a9de544f | 892 | { |
a9de544f | 893 | /* |
894 | * Decode the directive... | |
895 | */ | |
896 | ||
90d20520 | 897 | if (!strcasecmp(line, "<Printer") || |
898 | !strcasecmp(line, "<DefaultPrinter")) | |
a9de544f | 899 | { |
900 | /* | |
1d2c70a6 | 901 | * <Printer name> or <DefaultPrinter name> |
a9de544f | 902 | */ |
903 | ||
4a1c4581 | 904 | if (p == NULL && value) |
a9de544f | 905 | { |
cbbfcc63 | 906 | /* |
907 | * Add the printer and a base file type... | |
908 | */ | |
909 | ||
d318937f | 910 | cupsdLogMessage(CUPSD_LOG_DEBUG, "Loading printer %s...", value); |
d47f8ebe | 911 | |
589eb420 | 912 | p = cupsdAddPrinter(value); |
4139b718 | 913 | p->accepting = 1; |
914 | p->state = IPP_PRINTER_IDLE; | |
cbbfcc63 | 915 | |
916 | /* | |
917 | * Set the default printer as needed... | |
918 | */ | |
919 | ||
90d20520 | 920 | if (!strcasecmp(line, "<DefaultPrinter")) |
cbbfcc63 | 921 | DefaultPrinter = p; |
a9de544f | 922 | } |
923 | else | |
924 | { | |
f3e786fc | 925 | cupsdLogMessage(CUPSD_LOG_ERROR, |
926 | "Syntax error on line %d of printers.conf.", linenum); | |
a9de544f | 927 | return; |
928 | } | |
929 | } | |
90d20520 | 930 | else if (!strcasecmp(line, "</Printer>")) |
a9de544f | 931 | { |
932 | if (p != NULL) | |
e5cf24b2 | 933 | { |
52215316 | 934 | /* |
935 | * Close out the current printer... | |
936 | */ | |
937 | ||
589eb420 | 938 | cupsdSetPrinterAttrs(p); |
939 | cupsdAddPrinterHistory(p); | |
52215316 | 940 | |
941 | if (p->device_uri && strncmp(p->device_uri, "file:", 5) && | |
942 | p->state != IPP_PRINTER_STOPPED) | |
943 | { | |
944 | /* | |
945 | * See if the backend exists... | |
946 | */ | |
947 | ||
ad4be4c3 | 948 | snprintf(line, sizeof(line), "%s/backend/%s", ServerBin, |
52215316 | 949 | p->device_uri); |
950 | ||
951 | if ((valueptr = strchr(line + strlen(ServerBin), ':')) != NULL) | |
952 | *valueptr = '\0'; /* Chop everything but URI scheme */ | |
953 | ||
954 | if (access(line, 0)) | |
955 | { | |
956 | /* | |
957 | * Backend does not exist, stop printer... | |
958 | */ | |
959 | ||
960 | p->state = IPP_PRINTER_STOPPED; | |
961 | snprintf(p->state_message, sizeof(p->state_message), | |
962 | "Backend %s does not exist!", line); | |
963 | } | |
964 | } | |
965 | ||
a9de544f | 966 | p = NULL; |
e5cf24b2 | 967 | } |
a9de544f | 968 | else |
969 | { | |
f3e786fc | 970 | cupsdLogMessage(CUPSD_LOG_ERROR, |
971 | "Syntax error on line %d of printers.conf.", linenum); | |
a9de544f | 972 | return; |
973 | } | |
974 | } | |
a4b3db80 | 975 | else if (!p) |
a9de544f | 976 | { |
f3e786fc | 977 | cupsdLogMessage(CUPSD_LOG_ERROR, |
978 | "Syntax error on line %d of printers.conf.", linenum); | |
a9de544f | 979 | return; |
980 | } | |
90d20520 | 981 | else if (!strcasecmp(line, "Info")) |
a4b3db80 | 982 | { |
983 | if (value) | |
589eb420 | 984 | cupsdSetString(&p->info, value); |
a4b3db80 | 985 | } |
90d20520 | 986 | else if (!strcasecmp(line, "Location")) |
a4b3db80 | 987 | { |
988 | if (value) | |
589eb420 | 989 | cupsdSetString(&p->location, value); |
a4b3db80 | 990 | } |
90d20520 | 991 | else if (!strcasecmp(line, "DeviceURI")) |
a4b3db80 | 992 | { |
993 | if (value) | |
589eb420 | 994 | cupsdSetString(&p->device_uri, value); |
a4b3db80 | 995 | else |
996 | { | |
f3e786fc | 997 | cupsdLogMessage(CUPSD_LOG_ERROR, |
998 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 999 | return; |
1000 | } | |
1001 | } | |
a9bef0b2 | 1002 | else if (!strcasecmp(line, "PortMonitor")) |
1003 | { | |
1004 | if (value && strcmp(value, "none")) | |
589eb420 | 1005 | cupsdSetString(&p->port_monitor, value); |
a9bef0b2 | 1006 | else if (value) |
589eb420 | 1007 | cupsdClearString(&p->port_monitor); |
a9bef0b2 | 1008 | else |
1009 | { | |
f3e786fc | 1010 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1011 | "Syntax error on line %d of printers.conf.", linenum); | |
a9bef0b2 | 1012 | return; |
1013 | } | |
1014 | } | |
90d20520 | 1015 | else if (!strcasecmp(line, "State")) |
a9de544f | 1016 | { |
1017 | /* | |
c7fa9d06 | 1018 | * Set the initial queue state... |
6abc7437 | 1019 | */ |
1020 | ||
a4b3db80 | 1021 | if (value && !strcasecmp(value, "idle")) |
05e63c18 | 1022 | p->state = IPP_PRINTER_IDLE; |
a4b3db80 | 1023 | else if (value && !strcasecmp(value, "stopped")) |
05e63c18 | 1024 | p->state = IPP_PRINTER_STOPPED; |
a4b3db80 | 1025 | else |
1026 | { | |
f3e786fc | 1027 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1028 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1029 | return; |
1030 | } | |
05e63c18 | 1031 | } |
90d20520 | 1032 | else if (!strcasecmp(line, "StateMessage")) |
03081fd2 | 1033 | { |
1034 | /* | |
1035 | * Set the initial queue state message... | |
1036 | */ | |
1037 | ||
a4b3db80 | 1038 | if (value) |
1039 | strlcpy(p->state_message, value, sizeof(p->state_message)); | |
03081fd2 | 1040 | } |
ffd99efd | 1041 | else if (!strcasecmp(line, "StateTime")) |
1042 | { | |
1043 | /* | |
1044 | * Set the state time... | |
1045 | */ | |
1046 | ||
1047 | if (value) | |
1048 | p->state_time = atoi(value); | |
1049 | } | |
90d20520 | 1050 | else if (!strcasecmp(line, "Accepting")) |
05e63c18 | 1051 | { |
1052 | /* | |
1053 | * Set the initial accepting state... | |
1054 | */ | |
1055 | ||
a4b3db80 | 1056 | if (value && |
1057 | (!strcasecmp(value, "yes") || | |
1058 | !strcasecmp(value, "on") || | |
1059 | !strcasecmp(value, "true"))) | |
05e63c18 | 1060 | p->accepting = 1; |
a4b3db80 | 1061 | else if (value && |
1062 | (!strcasecmp(value, "no") || | |
1063 | !strcasecmp(value, "off") || | |
1064 | !strcasecmp(value, "false"))) | |
c7fa9d06 | 1065 | p->accepting = 0; |
a4b3db80 | 1066 | else |
1067 | { | |
f3e786fc | 1068 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1069 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1070 | return; |
1071 | } | |
a9de544f | 1072 | } |
25392f52 | 1073 | else if (!strcasecmp(line, "Shared")) |
1074 | { | |
1075 | /* | |
1076 | * Set the initial shared state... | |
1077 | */ | |
1078 | ||
1079 | if (value && | |
1080 | (!strcasecmp(value, "yes") || | |
1081 | !strcasecmp(value, "on") || | |
1082 | !strcasecmp(value, "true"))) | |
1083 | p->shared = 1; | |
1084 | else if (value && | |
1085 | (!strcasecmp(value, "no") || | |
1086 | !strcasecmp(value, "off") || | |
1087 | !strcasecmp(value, "false"))) | |
1088 | p->shared = 0; | |
1089 | else | |
1090 | { | |
f3e786fc | 1091 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1092 | "Syntax error on line %d of printers.conf.", linenum); | |
25392f52 | 1093 | return; |
1094 | } | |
1095 | } | |
90d20520 | 1096 | else if (!strcasecmp(line, "JobSheets")) |
a3e17a89 | 1097 | { |
aba2fa7e | 1098 | /* |
1099 | * Set the initial job sheets... | |
1100 | */ | |
a3e17a89 | 1101 | |
a4b3db80 | 1102 | if (value) |
1103 | { | |
1104 | for (valueptr = value; *valueptr && !isspace(*valueptr & 255); valueptr ++); | |
a3e17a89 | 1105 | |
a4b3db80 | 1106 | if (*valueptr) |
1107 | *valueptr++ = '\0'; | |
a3e17a89 | 1108 | |
f3e786fc | 1109 | cupsdSetString(&p->job_sheets[0], value); |
a3e17a89 | 1110 | |
a4b3db80 | 1111 | while (isspace(*valueptr & 255)) |
1112 | valueptr ++; | |
7db52463 | 1113 | |
aba2fa7e | 1114 | if (*valueptr) |
a4b3db80 | 1115 | { |
1116 | for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++); | |
a3e17a89 | 1117 | |
a4b3db80 | 1118 | if (*valueptr) |
1119 | *valueptr++ = '\0'; | |
1120 | ||
f3e786fc | 1121 | cupsdSetString(&p->job_sheets[1], value); |
a4b3db80 | 1122 | } |
1123 | } | |
1124 | else | |
1125 | { | |
f3e786fc | 1126 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1127 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1128 | return; |
a3e17a89 | 1129 | } |
1130 | } | |
90d20520 | 1131 | else if (!strcasecmp(line, "AllowUser")) |
d7845573 | 1132 | { |
a4b3db80 | 1133 | if (value) |
1134 | { | |
1135 | p->deny_users = 0; | |
589eb420 | 1136 | cupsdAddPrinterUser(p, value); |
a4b3db80 | 1137 | } |
1138 | else | |
1139 | { | |
f3e786fc | 1140 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1141 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1142 | return; |
1143 | } | |
d7845573 | 1144 | } |
90d20520 | 1145 | else if (!strcasecmp(line, "DenyUser")) |
d7845573 | 1146 | { |
a4b3db80 | 1147 | if (value) |
1148 | { | |
1149 | p->deny_users = 1; | |
589eb420 | 1150 | cupsdAddPrinterUser(p, value); |
a4b3db80 | 1151 | } |
1152 | else | |
1153 | { | |
f3e786fc | 1154 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1155 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1156 | return; |
1157 | } | |
d7845573 | 1158 | } |
90d20520 | 1159 | else if (!strcasecmp(line, "QuotaPeriod")) |
a4b3db80 | 1160 | { |
1161 | if (value) | |
1162 | p->quota_period = atoi(value); | |
1163 | else | |
1164 | { | |
f3e786fc | 1165 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1166 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1167 | return; |
1168 | } | |
1169 | } | |
90d20520 | 1170 | else if (!strcasecmp(line, "PageLimit")) |
a4b3db80 | 1171 | { |
1172 | if (value) | |
1173 | p->page_limit = atoi(value); | |
1174 | else | |
1175 | { | |
f3e786fc | 1176 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1177 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1178 | return; |
1179 | } | |
1180 | } | |
90d20520 | 1181 | else if (!strcasecmp(line, "KLimit")) |
a4b3db80 | 1182 | { |
1183 | if (value) | |
1184 | p->k_limit = atoi(value); | |
1185 | else | |
1186 | { | |
f3e786fc | 1187 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1188 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1189 | return; |
1190 | } | |
1191 | } | |
90d20520 | 1192 | else if (!strcasecmp(line, "OpPolicy")) |
a4b3db80 | 1193 | { |
1194 | if (value) | |
589eb420 | 1195 | cupsdSetString(&p->op_policy, value); |
a4b3db80 | 1196 | else |
1197 | { | |
f3e786fc | 1198 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1199 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1200 | return; |
1201 | } | |
1202 | } | |
90d20520 | 1203 | else if (!strcasecmp(line, "ErrorPolicy")) |
a4b3db80 | 1204 | { |
1205 | if (value) | |
589eb420 | 1206 | cupsdSetString(&p->error_policy, value); |
a4b3db80 | 1207 | else |
1208 | { | |
f3e786fc | 1209 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1210 | "Syntax error on line %d of printers.conf.", linenum); | |
a4b3db80 | 1211 | return; |
1212 | } | |
1213 | } | |
c7fa9d06 | 1214 | else |
a9de544f | 1215 | { |
1216 | /* | |
c7fa9d06 | 1217 | * Something else we don't understand... |
a9de544f | 1218 | */ |
1219 | ||
f3e786fc | 1220 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1221 | "Unknown configuration directive %s on line %d of printers.conf.", | |
1222 | line, linenum); | |
a9de544f | 1223 | } |
a9de544f | 1224 | } |
1225 | ||
7b0fde61 | 1226 | cupsFileClose(fp); |
a9de544f | 1227 | } |
1228 | ||
1229 | ||
d6de4648 | 1230 | /* |
589eb420 | 1231 | * 'cupsdSaveAllPrinters()' - Save all printer definitions to the printers.conf |
ffd99efd | 1232 | * file. |
d6de4648 | 1233 | */ |
1234 | ||
a9de544f | 1235 | void |
589eb420 | 1236 | cupsdSaveAllPrinters(void) |
a9de544f | 1237 | { |
f3e786fc | 1238 | int i; /* Looping var */ |
1239 | cups_file_t *fp; /* printers.conf file */ | |
1240 | char temp[1024]; /* Temporary string */ | |
1241 | char backup[1024]; /* printers.conf.O file */ | |
1242 | cupsd_printer_t *printer; /* Current printer class */ | |
1243 | time_t curtime; /* Current time */ | |
1244 | struct tm *curdate; /* Current date */ | |
cc0561c6 | 1245 | |
1246 | ||
1247 | /* | |
1248 | * Create the printers.conf file... | |
1249 | */ | |
1250 | ||
a6988fb1 | 1251 | snprintf(temp, sizeof(temp), "%s/printers.conf", ServerRoot); |
7db52463 | 1252 | snprintf(backup, sizeof(backup), "%s/printers.conf.O", ServerRoot); |
1253 | ||
1254 | if (rename(temp, backup)) | |
fe3a28b7 | 1255 | { |
1256 | if (errno != ENOENT) | |
1257 | cupsdLogMessage(CUPSD_LOG_ERROR, | |
1258 | "Unable to backup printers.conf - %s", strerror(errno)); | |
1259 | } | |
7db52463 | 1260 | |
7b0fde61 | 1261 | if ((fp = cupsFileOpen(temp, "w")) == NULL) |
cc0561c6 | 1262 | { |
f3e786fc | 1263 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1264 | "Unable to save printers.conf - %s", strerror(errno)); | |
7db52463 | 1265 | |
1266 | if (rename(backup, temp)) | |
f3e786fc | 1267 | cupsdLogMessage(CUPSD_LOG_ERROR, |
1268 | "Unable to restore printers.conf - %s", strerror(errno)); | |
cc0561c6 | 1269 | return; |
1270 | } | |
1271 | else | |
f3e786fc | 1272 | cupsdLogMessage(CUPSD_LOG_INFO, "Saving printers.conf..."); |
cc0561c6 | 1273 | |
35a2ba9d | 1274 | /* |
1275 | * Restrict access to the file... | |
1276 | */ | |
1277 | ||
aa7b8dba | 1278 | fchown(cupsFileNumber(fp), getuid(), Group); |
04907de7 | 1279 | fchmod(cupsFileNumber(fp), 0600); |
35a2ba9d | 1280 | |
cc0561c6 | 1281 | /* |
1282 | * Write a small header to the file... | |
1283 | */ | |
1284 | ||
1285 | curtime = time(NULL); | |
aa3b74e1 | 1286 | curdate = localtime(&curtime); |
9b4efe89 | 1287 | strftime(temp, sizeof(temp) - 1, "%Y-%m-%d %H:%M", curdate); |
cc0561c6 | 1288 | |
7b0fde61 | 1289 | cupsFilePuts(fp, "# Printer configuration file for " CUPS_SVERSION "\n"); |
1290 | cupsFilePrintf(fp, "# Written by cupsd on %s\n", temp); | |
cc0561c6 | 1291 | |
82306f04 | 1292 | /* |
1293 | * Write each local printer known to the system... | |
1294 | */ | |
1295 | ||
589eb420 | 1296 | for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers); |
82306f04 | 1297 | printer; |
589eb420 | 1298 | printer = (cupsd_printer_t *)cupsArrayNext(Printers)) |
cc0561c6 | 1299 | { |
1300 | /* | |
82306f04 | 1301 | * Skip remote destinations and printer classes... |
cc0561c6 | 1302 | */ |
1303 | ||
82306f04 | 1304 | if ((printer->type & CUPS_PRINTER_REMOTE) || |
1305 | (printer->type & CUPS_PRINTER_CLASS) || | |
1306 | (printer->type & CUPS_PRINTER_IMPLICIT)) | |
1307 | continue; | |
cc0561c6 | 1308 | |
82306f04 | 1309 | /* |
1310 | * Write printers as needed... | |
1311 | */ | |
cc0561c6 | 1312 | |
82306f04 | 1313 | if (printer == DefaultPrinter) |
1314 | cupsFilePrintf(fp, "<DefaultPrinter %s>\n", printer->name); | |
1315 | else | |
1316 | cupsFilePrintf(fp, "<Printer %s>\n", printer->name); | |
753453e4 | 1317 | |
82306f04 | 1318 | if (printer->info) |
1319 | cupsFilePrintf(fp, "Info %s\n", printer->info); | |
753453e4 | 1320 | |
82306f04 | 1321 | if (printer->location) |
1322 | cupsFilePrintf(fp, "Location %s\n", printer->location); | |
753453e4 | 1323 | |
82306f04 | 1324 | if (printer->device_uri) |
1325 | cupsFilePrintf(fp, "DeviceURI %s\n", printer->device_uri); | |
a9bef0b2 | 1326 | |
82306f04 | 1327 | if (printer->port_monitor) |
1328 | cupsFilePrintf(fp, "PortMonitor %s\n", printer->port_monitor); | |
753453e4 | 1329 | |
82306f04 | 1330 | if (printer->state == IPP_PRINTER_STOPPED) |
1331 | { | |
1332 | cupsFilePuts(fp, "State Stopped\n"); | |
1333 | cupsFilePrintf(fp, "StateMessage %s\n", printer->state_message); | |
1334 | } | |
1335 | else | |
1336 | cupsFilePuts(fp, "State Idle\n"); | |
753453e4 | 1337 | |
ffd99efd | 1338 | cupsFilePrintf(fp, "StateTime %d\n", (int)printer->state_time); |
1339 | ||
82306f04 | 1340 | if (printer->accepting) |
1341 | cupsFilePuts(fp, "Accepting Yes\n"); | |
1342 | else | |
1343 | cupsFilePuts(fp, "Accepting No\n"); | |
90231631 | 1344 | |
82306f04 | 1345 | if (printer->shared) |
1346 | cupsFilePuts(fp, "Shared Yes\n"); | |
1347 | else | |
1348 | cupsFilePuts(fp, "Shared No\n"); | |
25392f52 | 1349 | |
f3e786fc | 1350 | cupsFilePrintf(fp, "JobSheets %s %s\n", printer->job_sheets[0], |
1351 | printer->job_sheets[1]); | |
cc0561c6 | 1352 | |
82306f04 | 1353 | cupsFilePrintf(fp, "QuotaPeriod %d\n", printer->quota_period); |
1354 | cupsFilePrintf(fp, "PageLimit %d\n", printer->page_limit); | |
1355 | cupsFilePrintf(fp, "KLimit %d\n", printer->k_limit); | |
d7845573 | 1356 | |
82306f04 | 1357 | for (i = 0; i < printer->num_users; i ++) |
1358 | cupsFilePrintf(fp, "%sUser %s\n", printer->deny_users ? "Deny" : "Allow", | |
1359 | printer->users[i]); | |
d7845573 | 1360 | |
82306f04 | 1361 | if (printer->op_policy) |
1362 | cupsFilePrintf(fp, "OpPolicy %s\n", printer->op_policy); | |
1363 | if (printer->error_policy) | |
1364 | cupsFilePrintf(fp, "ErrorPolicy %s\n", printer->error_policy); | |
e175d98d | 1365 | |
82306f04 | 1366 | cupsFilePuts(fp, "</Printer>\n"); |
dd5cfc84 | 1367 | |
9ae34eb7 | 1368 | #ifdef __sgi |
82306f04 | 1369 | /* |
1370 | * Make IRIX desktop & printer status happy | |
1371 | */ | |
9ae34eb7 | 1372 | |
82306f04 | 1373 | write_irix_state(printer); |
9ae34eb7 | 1374 | #endif /* __sgi */ |
cc0561c6 | 1375 | } |
1376 | ||
7b0fde61 | 1377 | cupsFileClose(fp); |
a9de544f | 1378 | } |
1379 | ||
1380 | ||
f3d580b9 | 1381 | /* |
589eb420 | 1382 | * 'cupsdSetPrinterAttrs()' - Set printer attributes based upon the PPD file. |
f3d580b9 | 1383 | */ |
1384 | ||
a9de544f | 1385 | void |
f3e786fc | 1386 | cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ |
f3d580b9 | 1387 | { |
f3e786fc | 1388 | char uri[HTTP_MAX_URI]; |
1389 | /* URI for printer */ | |
1390 | char resource[HTTP_MAX_URI]; | |
1391 | /* Resource portion of URI */ | |
1392 | int i; /* Looping var */ | |
1393 | char filename[1024]; /* Name of PPD file */ | |
1394 | int num_media; /* Number of media options */ | |
1395 | cupsd_location_t *auth; /* Pointer to authentication element */ | |
1396 | const char *auth_supported;/* Authentication supported */ | |
5bd8a9fa | 1397 | cups_ptype_t printer_type; /* Printer type data */ |
f3e786fc | 1398 | ppd_file_t *ppd; /* PPD file data */ |
1399 | ppd_option_t *input_slot, /* InputSlot options */ | |
1400 | *media_type, /* MediaType options */ | |
1401 | *page_size, /* PageSize options */ | |
1402 | *output_bin, /* OutputBin options */ | |
1403 | *media_quality; /* EFMediaQualityMode options */ | |
1404 | ppd_attr_t *ppdattr; /* PPD attribute */ | |
1405 | ipp_attribute_t *attr; /* Attribute data */ | |
1406 | ipp_value_t *val; /* Attribute value */ | |
1407 | int num_finishings; /* Number of finishings */ | |
1408 | ipp_finish_t finishings[5]; /* finishings-supported values */ | |
aa7b8dba | 1409 | static const char * const sides[3] = /* sides-supported values */ |
f3d580b9 | 1410 | { |
aa7b8dba | 1411 | "one", |
1412 | "two-long-edge", | |
1413 | "two-short-edge" | |
f3d580b9 | 1414 | }; |
f3d580b9 | 1415 | |
1416 | ||
589eb420 | 1417 | DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name, |
74ea18d4 | 1418 | p->type)); |
22902293 | 1419 | |
3f2fa036 | 1420 | /* |
1421 | * Make sure that we have the common attributes defined... | |
1422 | */ | |
1423 | ||
1424 | if (!CommonData) | |
589eb420 | 1425 | cupsdCreateCommonData(); |
3f2fa036 | 1426 | |
c7fa9d06 | 1427 | /* |
584ef899 | 1428 | * Clear out old filters, if any... |
c7fa9d06 | 1429 | */ |
1430 | ||
589eb420 | 1431 | cupsdDeletePrinterFilters(p); |
c7fa9d06 | 1432 | |
7ebf3a09 | 1433 | /* |
1434 | * Figure out the authentication that is required for the printer. | |
1435 | */ | |
1436 | ||
1437 | auth_supported = "requesting-user-name"; | |
1438 | if (!(p->type & CUPS_PRINTER_REMOTE)) | |
1439 | { | |
1440 | if (p->type & CUPS_PRINTER_CLASS) | |
a6988fb1 | 1441 | snprintf(resource, sizeof(resource), "/classes/%s", p->name); |
7ebf3a09 | 1442 | else |
a6988fb1 | 1443 | snprintf(resource, sizeof(resource), "/printers/%s", p->name); |
7ebf3a09 | 1444 | |
589eb420 | 1445 | if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL) |
48e211f3 | 1446 | auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB); |
1447 | ||
1448 | if (auth) | |
7db52463 | 1449 | { |
aba2fa7e | 1450 | if (auth->type == AUTH_BASIC || auth->type == AUTH_BASICDIGEST) |
7db52463 | 1451 | auth_supported = "basic"; |
1452 | else if (auth->type == AUTH_DIGEST) | |
1453 | auth_supported = "digest"; | |
48e211f3 | 1454 | |
1455 | if (auth->type != AUTH_NONE) | |
1456 | p->type |= CUPS_PRINTER_AUTHENTICATED; | |
1457 | else | |
1458 | p->type &= ~CUPS_PRINTER_AUTHENTICATED; | |
7db52463 | 1459 | } |
48e211f3 | 1460 | else |
1461 | p->type &= ~CUPS_PRINTER_AUTHENTICATED; | |
7ebf3a09 | 1462 | } |
1463 | ||
f3d580b9 | 1464 | /* |
1465 | * Create the required IPP attributes for a printer... | |
1466 | */ | |
1467 | ||
1468 | if (p->attrs) | |
1469 | ippDelete(p->attrs); | |
1470 | ||
1471 | p->attrs = ippNew(); | |
1472 | ||
7ebf3a09 | 1473 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, |
1474 | "uri-authentication-supported", NULL, auth_supported); | |
f3d580b9 | 1475 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, |
1476 | "uri-security-supported", NULL, "none"); | |
1477 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, | |
1478 | p->name); | |
1479 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-location", | |
36992080 | 1480 | NULL, p->location ? p->location : ""); |
f3d580b9 | 1481 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info", |
36992080 | 1482 | NULL, p->info ? p->info : ""); |
f3d580b9 | 1483 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-more-info", |
753453e4 | 1484 | NULL, p->uri); |
f3d580b9 | 1485 | |
d7845573 | 1486 | if (p->num_users) |
1487 | { | |
1488 | if (p->deny_users) | |
1489 | ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
1490 | "requesting-user-name-denied", p->num_users, NULL, | |
1491 | p->users); | |
1492 | else | |
1493 | ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, | |
1494 | "requesting-user-name-allowed", p->num_users, NULL, | |
1495 | p->users); | |
1496 | } | |
1497 | ||
04d756fc | 1498 | ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, |
1499 | "job-quota-period", p->quota_period); | |
1500 | ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
1501 | "job-k-limit", p->k_limit); | |
1502 | ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
1503 | "job-page-limit", p->page_limit); | |
1504 | ||
92ed2c7c | 1505 | if (cupsArrayCount(Banners) > 0 && !(p->type & CUPS_PRINTER_REMOTE)) |
d21a7597 | 1506 | { |
1507 | /* | |
3f2fa036 | 1508 | * Setup the job-sheets-default attribute... |
d21a7597 | 1509 | */ |
1510 | ||
3f2fa036 | 1511 | attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, |
1512 | "job-sheets-default", 2, NULL, NULL); | |
d21a7597 | 1513 | |
3f2fa036 | 1514 | if (attr != NULL) |
d11458ff | 1515 | { |
fc957d47 | 1516 | attr->values[0].string.text = _cups_sp_alloc(Classification ? |
f3e786fc | 1517 | Classification : p->job_sheets[0]); |
fc957d47 | 1518 | attr->values[1].string.text = _cups_sp_alloc(Classification ? |
f3e786fc | 1519 | Classification : p->job_sheets[1]); |
d11458ff | 1520 | } |
d21a7597 | 1521 | } |
1522 | ||
5bd8a9fa | 1523 | printer_type = p->type; |
753453e4 | 1524 | |
a7a1daf4 | 1525 | p->raw = 0; |
1526 | ||
6bc08d08 | 1527 | if (p->type & CUPS_PRINTER_REMOTE) |
1528 | { | |
1529 | /* | |
1530 | * Tell the client this is a remote printer of some type... | |
1531 | */ | |
1532 | ||
e5c4f5a1 | 1533 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, |
1534 | "printer-uri-supported", NULL, p->uri); | |
1535 | ||
b537a9b8 | 1536 | if (p->make_model) |
1537 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, | |
1538 | "printer-make-and-model", NULL, p->make_model); | |
1539 | ||
07ed6749 | 1540 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, |
1541 | p->uri); | |
1542 | ||
a7a1daf4 | 1543 | p->raw = 1; |
6bc08d08 | 1544 | } |
1545 | else | |
f3d580b9 | 1546 | { |
1547 | /* | |
08d0dfa7 | 1548 | * Assign additional attributes depending on whether this is a printer |
1549 | * or class... | |
f3d580b9 | 1550 | */ |
1551 | ||
08d0dfa7 | 1552 | p->type &= ~CUPS_PRINTER_OPTIONS; |
1553 | ||
a2c6b8b1 | 1554 | if (p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)) |
cbbfcc63 | 1555 | { |
584ef899 | 1556 | p->raw = 1; |
1557 | ||
cbbfcc63 | 1558 | /* |
08d0dfa7 | 1559 | * Add class-specific attributes... |
cbbfcc63 | 1560 | */ |
1561 | ||
b537a9b8 | 1562 | if ((p->type & CUPS_PRINTER_IMPLICIT) && p->num_printers > 0 && |
1563 | p->printers[0]->make_model) | |
a2c6b8b1 | 1564 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, |
1565 | "printer-make-and-model", NULL, p->printers[0]->make_model); | |
1566 | else | |
1567 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, | |
1568 | "printer-make-and-model", NULL, "Local Printer Class"); | |
6bc08d08 | 1569 | |
07ed6749 | 1570 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, |
1571 | "file:///dev/null"); | |
1572 | ||
08d0dfa7 | 1573 | if (p->num_printers > 0) |
1574 | { | |
1575 | /* | |
1576 | * Add a list of member URIs and names... | |
1577 | */ | |
cbbfcc63 | 1578 | |
08d0dfa7 | 1579 | attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, |
1580 | "member-uris", p->num_printers, NULL, NULL); | |
08d0dfa7 | 1581 | p->type |= CUPS_PRINTER_OPTIONS; |
f3d580b9 | 1582 | |
08d0dfa7 | 1583 | for (i = 0; i < p->num_printers; i ++) |
1584 | { | |
d11458ff | 1585 | if (attr != NULL) |
fc957d47 | 1586 | attr->values[i].string.text = _cups_sp_alloc(p->printers[i]->uri); |
f3d580b9 | 1587 | |
08d0dfa7 | 1588 | p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type; |
1589 | } | |
f3d580b9 | 1590 | |
08d0dfa7 | 1591 | attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, |
1592 | "member-names", p->num_printers, NULL, NULL); | |
f3d580b9 | 1593 | |
d11458ff | 1594 | if (attr != NULL) |
1595 | { | |
1596 | for (i = 0; i < p->num_printers; i ++) | |
fc957d47 | 1597 | attr->values[i].string.text = _cups_sp_alloc(p->printers[i]->name); |
d11458ff | 1598 | } |
08d0dfa7 | 1599 | } |
1600 | } | |
1601 | else | |
cbbfcc63 | 1602 | { |
1603 | /* | |
05e63c18 | 1604 | * Add printer-specific attributes... Start by sanitizing the device |
1605 | * URI so it doesn't have a username or password in it... | |
cbbfcc63 | 1606 | */ |
f3d580b9 | 1607 | |
36992080 | 1608 | if (!p->device_uri) |
1609 | strcpy(uri, "file:/dev/null"); | |
1610 | else if (strstr(p->device_uri, "://") != NULL) | |
05e63c18 | 1611 | { |
1612 | /* | |
1613 | * http://..., ipp://..., etc. | |
1614 | */ | |
1615 | ||
2cb3f80d | 1616 | cupsdSanitizeURI(p->device_uri, uri, sizeof(uri)); |
05e63c18 | 1617 | } |
1618 | else | |
1619 | { | |
1620 | /* | |
1621 | * file:..., serial:..., etc. | |
1622 | */ | |
1623 | ||
36992080 | 1624 | strlcpy(uri, p->device_uri, sizeof(uri)); |
05e63c18 | 1625 | } |
1626 | ||
08d0dfa7 | 1627 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, |
05e63c18 | 1628 | uri); |
f3d580b9 | 1629 | |
cbbfcc63 | 1630 | /* |
08d0dfa7 | 1631 | * Assign additional attributes from the PPD file (if any)... |
cbbfcc63 | 1632 | */ |
f3d580b9 | 1633 | |
08d0dfa7 | 1634 | p->type |= CUPS_PRINTER_BW; |
8bc932be | 1635 | finishings[0] = IPP_FINISHINGS_NONE; |
08d0dfa7 | 1636 | num_finishings = 1; |
f3d580b9 | 1637 | |
a6988fb1 | 1638 | snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, |
1639 | p->name); | |
1640 | ||
08d0dfa7 | 1641 | if ((ppd = ppdOpenFile(filename)) != NULL) |
1642 | { | |
1643 | /* | |
1644 | * Add make/model and other various attributes... | |
1645 | */ | |
d6de4648 | 1646 | |
08d0dfa7 | 1647 | if (ppd->color_device) |
1648 | p->type |= CUPS_PRINTER_COLOR; | |
1649 | if (ppd->variable_sizes) | |
1650 | p->type |= CUPS_PRINTER_VARIABLE; | |
1651 | if (!ppd->manual_copies) | |
1652 | p->type |= CUPS_PRINTER_COPIES; | |
e532393d | 1653 | if ((ppdattr = ppdFindAttr(ppd, "cupsFax", NULL)) != NULL) |
1654 | if (ppdattr->value && !strcasecmp(ppdattr->value, "true")) | |
1655 | p->type |= CUPS_PRINTER_FAX; | |
f3d580b9 | 1656 | |
08d0dfa7 | 1657 | ippAddBoolean(p->attrs, IPP_TAG_PRINTER, "color-supported", |
1658 | ppd->color_device); | |
7ebf3a09 | 1659 | if (ppd->throughput) |
1660 | ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, | |
1661 | "pages-per-minute", ppd->throughput); | |
d6de4648 | 1662 | |
753453e4 | 1663 | if (ppd->nickname) |
cf0959e5 | 1664 | { |
1665 | /* | |
1666 | * The NickName can be localized in the character set specified | |
1667 | * by the LanugageEncoding attribute. Convert as needed to | |
1668 | * UTF-8... | |
1669 | */ | |
1670 | ||
1671 | transcode_nickname(p, ppd); | |
1672 | } | |
753453e4 | 1673 | else if (ppd->modelname) |
589eb420 | 1674 | cupsdSetString(&p->make_model, ppd->modelname); |
753453e4 | 1675 | else |
589eb420 | 1676 | cupsdSetString(&p->make_model, "Bad PPD File"); |
a2c6b8b1 | 1677 | |
cf0959e5 | 1678 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, |
1679 | "printer-make-and-model", NULL, p->make_model); | |
415199da | 1680 | |
08d0dfa7 | 1681 | /* |
1682 | * Add media options from the PPD file... | |
1683 | */ | |
d6de4648 | 1684 | |
08d0dfa7 | 1685 | if ((input_slot = ppdFindOption(ppd, "InputSlot")) != NULL) |
1686 | num_media = input_slot->num_choices; | |
1687 | else | |
1688 | num_media = 0; | |
1689 | ||
1690 | if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL) | |
1691 | num_media += media_type->num_choices; | |
1692 | ||
1693 | if ((page_size = ppdFindOption(ppd, "PageSize")) != NULL) | |
1694 | num_media += page_size->num_choices; | |
1695 | ||
daeeb91c | 1696 | if ((media_quality = ppdFindOption(ppd, "EFMediaQualityMode")) != NULL) |
1697 | num_media += media_quality->num_choices; | |
1698 | ||
00528abb | 1699 | if (num_media == 0) |
e2660aea | 1700 | { |
d318937f | 1701 | cupsdLogMessage(CUPSD_LOG_CRIT, |
1702 | "The PPD file for printer %s " | |
1703 | "contains no media options and is therefore " | |
1704 | "invalid!", p->name); | |
00528abb | 1705 | } |
1706 | else | |
1707 | { | |
1708 | attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
1709 | "media-supported", num_media, NULL, NULL); | |
1710 | if (attr != NULL) | |
d11458ff | 1711 | { |
00528abb | 1712 | val = attr->values; |
1713 | ||
1714 | if (input_slot != NULL) | |
1715 | for (i = 0; i < input_slot->num_choices; i ++, val ++) | |
fc957d47 | 1716 | val->string.text = _cups_sp_alloc(input_slot->choices[i].choice); |
00528abb | 1717 | |
1718 | if (media_type != NULL) | |
1719 | for (i = 0; i < media_type->num_choices; i ++, val ++) | |
fc957d47 | 1720 | val->string.text = _cups_sp_alloc(media_type->choices[i].choice); |
00528abb | 1721 | |
1722 | if (media_quality != NULL) | |
1723 | for (i = 0; i < media_quality->num_choices; i ++, val ++) | |
fc957d47 | 1724 | val->string.text = _cups_sp_alloc(media_quality->choices[i].choice); |
00528abb | 1725 | |
1726 | if (page_size != NULL) | |
1727 | { | |
1728 | for (i = 0; i < page_size->num_choices; i ++, val ++) | |
fc957d47 | 1729 | val->string.text = _cups_sp_alloc(page_size->choices[i].choice); |
00528abb | 1730 | |
1731 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", | |
1732 | NULL, page_size->defchoice); | |
1733 | } | |
1734 | else if (input_slot != NULL) | |
1735 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", | |
1736 | NULL, input_slot->defchoice); | |
1737 | else if (media_type != NULL) | |
1738 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", | |
1739 | NULL, media_type->defchoice); | |
1740 | else if (media_quality != NULL) | |
1741 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", | |
1742 | NULL, media_quality->defchoice); | |
1743 | else | |
1744 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", | |
1745 | NULL, "none"); | |
d11458ff | 1746 | } |
e2660aea | 1747 | } |
08d0dfa7 | 1748 | |
29ece07e | 1749 | /* |
1750 | * Output bin... | |
1751 | */ | |
1752 | ||
1753 | if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL) | |
1754 | { | |
1755 | attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
1756 | "output-bin-supported", output_bin->num_choices, | |
1757 | NULL, NULL); | |
1758 | ||
d11458ff | 1759 | if (attr != NULL) |
1760 | { | |
1761 | for (i = 0, val = attr->values; | |
1762 | i < output_bin->num_choices; | |
1763 | i ++, val ++) | |
fc957d47 | 1764 | val->string.text = _cups_sp_alloc(output_bin->choices[i].choice); |
d11458ff | 1765 | } |
1766 | } | |
29ece07e | 1767 | |
1768 | /* | |
1769 | * Duplexing, etc... | |
1770 | */ | |
1771 | ||
08d0dfa7 | 1772 | if (ppdFindOption(ppd, "Duplex") != NULL) |
1773 | { | |
1774 | p->type |= CUPS_PRINTER_DUPLEX; | |
1775 | ||
1776 | ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "sides-supported", | |
1777 | 3, NULL, sides); | |
1778 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "sides-default", | |
1779 | NULL, "one"); | |
1780 | } | |
1781 | ||
1782 | if (ppdFindOption(ppd, "Collate") != NULL) | |
1783 | p->type |= CUPS_PRINTER_COLLATE; | |
1784 | ||
1785 | if (ppdFindOption(ppd, "StapleLocation") != NULL) | |
1786 | { | |
1787 | p->type |= CUPS_PRINTER_STAPLE; | |
8bc932be | 1788 | finishings[num_finishings++] = IPP_FINISHINGS_STAPLE; |
08d0dfa7 | 1789 | } |
1790 | ||
1791 | if (ppdFindOption(ppd, "BindEdge") != NULL) | |
1792 | { | |
1793 | p->type |= CUPS_PRINTER_BIND; | |
8bc932be | 1794 | finishings[num_finishings++] = IPP_FINISHINGS_BIND; |
08d0dfa7 | 1795 | } |
1796 | ||
1797 | for (i = 0; i < ppd->num_sizes; i ++) | |
1798 | if (ppd->sizes[i].length > 1728) | |
1799 | p->type |= CUPS_PRINTER_LARGE; | |
1800 | else if (ppd->sizes[i].length > 1008) | |
1801 | p->type |= CUPS_PRINTER_MEDIUM; | |
1802 | else | |
1803 | p->type |= CUPS_PRINTER_SMALL; | |
d6de4648 | 1804 | |
584ef899 | 1805 | /* |
1806 | * Add a filter from application/vnd.cups-raw to printer/name to | |
1807 | * handle "raw" printing by users. | |
1808 | */ | |
1809 | ||
d318937f | 1810 | add_printer_filter(p, "application/vnd.cups-raw 0 -"); |
584ef899 | 1811 | |
08d0dfa7 | 1812 | /* |
1813 | * Add any filters in the PPD file... | |
1814 | */ | |
d6de4648 | 1815 | |
08d0dfa7 | 1816 | DEBUG_printf(("ppd->num_filters = %d\n", ppd->num_filters)); |
1817 | for (i = 0; i < ppd->num_filters; i ++) | |
1818 | { | |
1819 | DEBUG_printf(("ppd->filters[%d] = \"%s\"\n", i, ppd->filters[i])); | |
d318937f | 1820 | add_printer_filter(p, ppd->filters[i]); |
08d0dfa7 | 1821 | } |
d6de4648 | 1822 | |
08d0dfa7 | 1823 | if (ppd->num_filters == 0) |
584ef899 | 1824 | { |
1825 | /* | |
1826 | * If there are no filters, add a PostScript printing filter. | |
1827 | */ | |
1828 | ||
d318937f | 1829 | add_printer_filter(p, "application/vnd.cups-postscript 0 -"); |
584ef899 | 1830 | } |
d6de4648 | 1831 | |
a9bef0b2 | 1832 | /* |
1833 | * Show current and available port monitors for this printer... | |
1834 | */ | |
1835 | ||
1836 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "port-monitor", | |
1837 | NULL, p->port_monitor ? p->port_monitor : "none"); | |
1838 | ||
1839 | ||
1840 | for (i = 1, ppdattr = ppdFindAttr(ppd, "cupsPortMonitor", NULL); | |
f2bc527f | 1841 | ppdattr; |
a9bef0b2 | 1842 | i ++, ppdattr = ppdFindNextAttr(ppd, "cupsPortMonitor", NULL)); |
1843 | ||
1844 | if (ppd->protocols) | |
1845 | { | |
1846 | if (strstr(ppd->protocols, "TBCP")) | |
1847 | i ++; | |
1848 | else if (strstr(ppd->protocols, "BCP")) | |
1849 | i ++; | |
1850 | } | |
1851 | ||
1852 | attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, | |
1853 | "port-monitor-supported", i, NULL, NULL); | |
1854 | ||
fc957d47 | 1855 | attr->values[0].string.text = _cups_sp_alloc("none"); |
a9bef0b2 | 1856 | |
1857 | for (i = 1, ppdattr = ppdFindAttr(ppd, "cupsPortMonitor", NULL); | |
f2bc527f | 1858 | ppdattr; |
1859 | i ++, ppdattr = ppdFindNextAttr(ppd, "cupsPortMonitor", NULL)) | |
fc957d47 | 1860 | attr->values[i].string.text = _cups_sp_alloc(ppdattr->value); |
a9bef0b2 | 1861 | |
1862 | if (ppd->protocols) | |
1863 | { | |
1864 | if (strstr(ppd->protocols, "TBCP")) | |
fc957d47 | 1865 | attr->values[i].string.text = _cups_sp_alloc("tbcp"); |
a9bef0b2 | 1866 | else if (strstr(ppd->protocols, "BCP")) |
fc957d47 | 1867 | attr->values[i].string.text = _cups_sp_alloc("bcp"); |
a9bef0b2 | 1868 | } |
1869 | ||
1870 | /* | |
1871 | * Close the PPD and set the type... | |
1872 | */ | |
1873 | ||
08d0dfa7 | 1874 | ppdClose(ppd); |
753453e4 | 1875 | |
5bd8a9fa | 1876 | printer_type = p->type; |
cbbfcc63 | 1877 | } |
584ef899 | 1878 | else if (!access(filename, 0)) |
cbbfcc63 | 1879 | { |
6897133b | 1880 | int pline; /* PPD line number */ |
1881 | ppd_status_t pstatus; /* PPD load status */ | |
1882 | ||
1883 | ||
1884 | pstatus = ppdLastError(&pline); | |
1885 | ||
f3e786fc | 1886 | cupsdLogMessage(CUPSD_LOG_ERROR, "PPD file for %s cannot be loaded!", p->name); |
7a76892d | 1887 | |
1888 | if (pstatus <= PPD_ALLOC_ERROR) | |
f3e786fc | 1889 | cupsdLogMessage(CUPSD_LOG_ERROR, "%s", strerror(errno)); |
7a76892d | 1890 | else |
f3e786fc | 1891 | cupsdLogMessage(CUPSD_LOG_ERROR, "%s on line %d.", ppdErrorString(pstatus), |
7a76892d | 1892 | pline); |
cbbfcc63 | 1893 | |
f3e786fc | 1894 | cupsdLogMessage(CUPSD_LOG_INFO, "Hint: Run \"cupstestppd %s\" and fix any errors.", |
4e43f59e | 1895 | filename); |
1896 | ||
584ef899 | 1897 | /* |
1898 | * Add a filter from application/vnd.cups-raw to printer/name to | |
1899 | * handle "raw" printing by users. | |
1900 | */ | |
1901 | ||
d318937f | 1902 | add_printer_filter(p, "application/vnd.cups-raw 0 -"); |
584ef899 | 1903 | |
1904 | /* | |
1905 | * Add a PostScript filter, since this is still possibly PS printer. | |
1906 | */ | |
1907 | ||
d318937f | 1908 | add_printer_filter(p, "application/vnd.cups-postscript 0 -"); |
cbbfcc63 | 1909 | } |
0c06ac87 | 1910 | else |
1911 | { | |
1912 | /* | |
ef0a945a | 1913 | * If we have an interface script, add a filter entry for it... |
0c06ac87 | 1914 | */ |
1915 | ||
a6988fb1 | 1916 | snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot, |
1917 | p->name); | |
ef0a945a | 1918 | if (access(filename, X_OK) == 0) |
1919 | { | |
1920 | /* | |
1921 | * Yes, we have a System V style interface script; use it! | |
1922 | */ | |
1923 | ||
6bc08d08 | 1924 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, |
1925 | "printer-make-and-model", NULL, "Local System V Printer"); | |
1926 | ||
a6988fb1 | 1927 | snprintf(filename, sizeof(filename), "*/* 0 %s/interfaces/%s", |
1928 | ServerRoot, p->name); | |
d318937f | 1929 | add_printer_filter(p, filename); |
ef0a945a | 1930 | } |
36992080 | 1931 | else if (p->device_uri && |
b2e10895 | 1932 | !strncmp(p->device_uri, "ipp://", 6) && |
753453e4 | 1933 | (strstr(p->device_uri, "/printers/") != NULL || |
1934 | strstr(p->device_uri, "/classes/") != NULL)) | |
1935 | { | |
1936 | /* | |
1937 | * Tell the client this is really a hard-wired remote printer. | |
1938 | */ | |
1939 | ||
5bd8a9fa | 1940 | printer_type |= CUPS_PRINTER_REMOTE; |
753453e4 | 1941 | |
1942 | /* | |
e5c4f5a1 | 1943 | * Point the printer-uri-supported attribute to the |
753453e4 | 1944 | * remote printer... |
1945 | */ | |
1946 | ||
e5c4f5a1 | 1947 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, |
1948 | "printer-uri-supported", NULL, p->device_uri); | |
753453e4 | 1949 | |
1950 | /* | |
1951 | * Then set the make-and-model accordingly... | |
1952 | */ | |
1953 | ||
1954 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, | |
1955 | "printer-make-and-model", NULL, "Remote Printer"); | |
1956 | ||
1957 | /* | |
1958 | * Print all files directly... | |
1959 | */ | |
1960 | ||
a7a1daf4 | 1961 | p->raw = 1; |
753453e4 | 1962 | } |
ef0a945a | 1963 | else |
1964 | { | |
1965 | /* | |
2aeb2b1d | 1966 | * Otherwise we have neither - treat this as a "dumb" printer |
1967 | * with no PPD file... | |
ef0a945a | 1968 | */ |
1969 | ||
6bc08d08 | 1970 | ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, |
1971 | "printer-make-and-model", NULL, "Local Raw Printer"); | |
1972 | ||
a7a1daf4 | 1973 | p->raw = 1; |
ef0a945a | 1974 | } |
0c06ac87 | 1975 | } |
ef0a945a | 1976 | |
1977 | ippAddIntegers(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, | |
1978 | "finishings-supported", num_finishings, (int *)finishings); | |
1979 | ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, | |
8bc932be | 1980 | "finishings-default", IPP_FINISHINGS_NONE); |
5b88701c | 1981 | } |
cbbfcc63 | 1982 | } |
d6de4648 | 1983 | |
d318937f | 1984 | /* |
1985 | * Populate the document-format-supported attribute... | |
1986 | */ | |
1987 | ||
1988 | add_printer_formats(p); | |
1989 | ||
589eb420 | 1990 | DEBUG_printf(("cupsdSetPrinterAttrs: leaving name = %s, type = %x\n", p->name, |
74ea18d4 | 1991 | p->type)); |
957c6597 | 1992 | |
1993 | #ifdef __sgi | |
1994 | /* | |
dd5cfc84 | 1995 | * Write the IRIX printer config and status files... |
9ae34eb7 | 1996 | */ |
1997 | ||
dd5cfc84 | 1998 | write_irix_config(p); |
9ae34eb7 | 1999 | write_irix_state(p); |
957c6597 | 2000 | #endif /* __sgi */ |
f3d580b9 | 2001 | } |
2002 | ||
2003 | ||
62bcac22 | 2004 | /* |
589eb420 | 2005 | * 'cupsdSetPrinterReasons()' - Set/update the reasons strings. |
62bcac22 | 2006 | */ |
2007 | ||
2008 | void | |
f3e786fc | 2009 | cupsdSetPrinterReasons( |
2010 | cupsd_printer_t *p, /* I - Printer */ | |
2011 | const char *s) /* I - Reasons strings */ | |
62bcac22 | 2012 | { |
2013 | int i; /* Looping var */ | |
2014 | const char *sptr; /* Pointer into reasons */ | |
2015 | char reason[255], /* Reason string */ | |
2016 | *rptr; /* Pointer into reason */ | |
2017 | ||
2018 | ||
2019 | if (s[0] == '-' || s[0] == '+') | |
2020 | { | |
2021 | /* | |
2022 | * Add/remove reasons... | |
2023 | */ | |
2024 | ||
2025 | sptr = s + 1; | |
2026 | } | |
2027 | else | |
2028 | { | |
2029 | /* | |
2030 | * Replace reasons... | |
2031 | */ | |
2032 | ||
2033 | sptr = s; | |
2034 | ||
2035 | for (i = 0; i < p->num_reasons; i ++) | |
2036 | free(p->reasons[i]); | |
2037 | ||
2038 | p->num_reasons = 0; | |
2039 | } | |
2040 | ||
2041 | /* | |
2042 | * Loop through all of the reasons... | |
2043 | */ | |
2044 | ||
2045 | while (*sptr) | |
2046 | { | |
2047 | /* | |
2048 | * Skip leading whitespace and commas... | |
2049 | */ | |
2050 | ||
da275f55 | 2051 | while (isspace(*sptr & 255) || *sptr == ',') |
62bcac22 | 2052 | sptr ++; |
2053 | ||
da275f55 | 2054 | for (rptr = reason; *sptr && !isspace(*sptr & 255) && *sptr != ','; sptr ++) |
62bcac22 | 2055 | if (rptr < (reason + sizeof(reason) - 1)) |
2056 | *rptr++ = *sptr; | |
2057 | ||
2058 | if (rptr == reason) | |
2059 | break; | |
2060 | ||
2061 | *rptr = '\0'; | |
2062 | ||
2063 | if (s[0] == '-') | |
2064 | { | |
2065 | /* | |
2066 | * Remove reason... | |
2067 | */ | |
2068 | ||
2069 | for (i = 0; i < p->num_reasons; i ++) | |
2070 | if (!strcasecmp(reason, p->reasons[i])) | |
2071 | { | |
2072 | /* | |
2073 | * Found a match, so remove it... | |
2074 | */ | |
2075 | ||
2076 | p->num_reasons --; | |
2077 | free(p->reasons[i]); | |
2078 | ||
2079 | if (i < p->num_reasons) | |
2080 | memmove(p->reasons + i, p->reasons + i + 1, | |
2081 | (p->num_reasons - i) * sizeof(char *)); | |
2082 | ||
2083 | i --; | |
2084 | } | |
2085 | } | |
0614322d | 2086 | else if (p->num_reasons < (int)(sizeof(p->reasons) / sizeof(p->reasons[0]))) |
62bcac22 | 2087 | { |
2088 | /* | |
2089 | * Add reason... | |
2090 | */ | |
2091 | ||
2092 | for (i = 0; i < p->num_reasons; i ++) | |
2093 | if (!strcasecmp(reason, p->reasons[i])) | |
2094 | break; | |
2095 | ||
2096 | if (i >= p->num_reasons) | |
2097 | { | |
2098 | p->reasons[i] = strdup(reason); | |
2099 | p->num_reasons ++; | |
2100 | } | |
2101 | } | |
2102 | } | |
2103 | } | |
2104 | ||
2105 | ||
f3d580b9 | 2106 | /* |
589eb420 | 2107 | * 'cupsdSetPrinterState()' - Update the current state of a printer. |
cbbfcc63 | 2108 | */ |
2109 | ||
2110 | void | |
f3e786fc | 2111 | cupsdSetPrinterState( |
2112 | cupsd_printer_t *p, /* I - Printer to change */ | |
2113 | ipp_pstate_t s, /* I - New state */ | |
2114 | int update) /* I - Update printers.conf? */ | |
cbbfcc63 | 2115 | { |
2116 | ipp_pstate_t old_state; /* Old printer state */ | |
2117 | ||
2118 | ||
e63d9801 | 2119 | /* |
2120 | * Can't set status of remote printers... | |
2121 | */ | |
2122 | ||
2123 | if (p->type & CUPS_PRINTER_REMOTE) | |
2124 | return; | |
2125 | ||
cbbfcc63 | 2126 | /* |
2127 | * Set the new state... | |
2128 | */ | |
2129 | ||
62bcac22 | 2130 | old_state = p->state; |
2131 | p->state = s; | |
cbbfcc63 | 2132 | |
2133 | if (old_state != s) | |
c802720f | 2134 | { |
ba886a95 | 2135 | /* |
2136 | * Let the browse code know this needs to be updated... | |
2137 | */ | |
2138 | ||
2139 | BrowseNext = p; | |
62bcac22 | 2140 | p->state_time = time(NULL); |
cbbfcc63 | 2141 | p->browse_time = 0; |
2142 | ||
c802720f | 2143 | #ifdef __sgi |
2144 | write_irix_state(p); | |
2145 | #endif /* __sgi */ | |
2146 | } | |
2147 | ||
589eb420 | 2148 | cupsdAddPrinterHistory(p); |
62bcac22 | 2149 | |
cbbfcc63 | 2150 | /* |
2151 | * Save the printer configuration if a printer goes from idle or processing | |
2152 | * to stopped (or visa-versa)... | |
2153 | */ | |
2154 | ||
aa3b74e1 | 2155 | if ((old_state == IPP_PRINTER_STOPPED) != (s == IPP_PRINTER_STOPPED) && |
2156 | update) | |
c8a55d2c | 2157 | { |
2158 | if (p->type & CUPS_PRINTER_CLASS) | |
589eb420 | 2159 | cupsdSaveAllClasses(); |
c8a55d2c | 2160 | else |
589eb420 | 2161 | cupsdSaveAllPrinters(); |
c8a55d2c | 2162 | } |
cbbfcc63 | 2163 | } |
2164 | ||
2165 | ||
2166 | /* | |
589eb420 | 2167 | * 'cupsdStopPrinter()' - Stop a printer from printing any jobs... |
cbbfcc63 | 2168 | */ |
2169 | ||
2170 | void | |
f3e786fc | 2171 | cupsdStopPrinter(cupsd_printer_t *p, /* I - Printer to stop */ |
2172 | int update)/* I - Update printers.conf? */ | |
cbbfcc63 | 2173 | { |
f3e786fc | 2174 | cupsd_job_t *job; /* Active print job */ |
dc4ff34c | 2175 | |
5c8eff27 | 2176 | |
2177 | /* | |
2178 | * Set the printer state... | |
2179 | */ | |
2180 | ||
589eb420 | 2181 | cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update); |
5c8eff27 | 2182 | |
dc4ff34c | 2183 | /* |
2184 | * See if we have a job printing on this printer... | |
2185 | */ | |
2186 | ||
cbbfcc63 | 2187 | if (p->job) |
ac1510ea | 2188 | { |
dc4ff34c | 2189 | /* |
2190 | * Get pointer to job... | |
2191 | */ | |
2192 | ||
589eb420 | 2193 | job = (cupsd_job_t *)p->job; |
dc4ff34c | 2194 | |
2195 | /* | |
2196 | * Stop it... | |
2197 | */ | |
2198 | ||
7726c8b4 | 2199 | cupsdStopJob(job, 0); |
dc4ff34c | 2200 | |
2201 | /* | |
2202 | * Reset the state to pending... | |
2203 | */ | |
2204 | ||
2205 | job->state->values[0].integer = IPP_JOB_PENDING; | |
2206 | ||
7726c8b4 | 2207 | cupsdSaveJob(job); |
ac1510ea | 2208 | } |
cbbfcc63 | 2209 | } |
2210 | ||
2211 | ||
87650f55 | 2212 | /* |
2213 | * 'cupsdUpdatePrinters()' - Update printers after a partial reload. | |
2214 | */ | |
2215 | ||
2216 | void | |
2217 | cupsdUpdatePrinters(void) | |
2218 | { | |
2219 | cupsd_printer_t *p; /* Current printer */ | |
2220 | ||
2221 | ||
2222 | /* | |
2223 | * Loop through the printers and recreate the printer attributes | |
2224 | * for any local printers since the policy and/or access control | |
2225 | * stuff may have changed. Also, if browsing is disabled, remove | |
2226 | * any remote printers... | |
2227 | */ | |
2228 | ||
2229 | for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); | |
2230 | p; | |
2231 | p = (cupsd_printer_t *)cupsArrayNext(Printers)) | |
2232 | { | |
2233 | if (!Browsing && (p->type & (CUPS_PRINTER_IMPLICIT | CUPS_PRINTER_REMOTE))) | |
2234 | { | |
2235 | if (p->type & CUPS_PRINTER_IMPLICIT) | |
2236 | cupsArrayRemove(ImplicitPrinters, p); | |
2237 | ||
ef3e1d49 | 2238 | cupsArraySave(Printers); |
87650f55 | 2239 | cupsdDeletePrinter(p, 0); |
ef3e1d49 | 2240 | cupsArrayRestore(Printers); |
64ecb863 | 2241 | continue; |
87650f55 | 2242 | } |
2243 | else if (!(p->type & CUPS_PRINTER_REMOTE)) | |
2244 | cupsdSetPrinterAttrs(p); | |
64ecb863 | 2245 | |
2246 | /* | |
2247 | * Update the operation policy pointer... | |
2248 | */ | |
2249 | ||
2250 | if ((p->op_policy_ptr = cupsdFindPolicy(p->op_policy)) == NULL) | |
2251 | p->op_policy_ptr = DefaultPolicyPtr; | |
87650f55 | 2252 | } |
2253 | } | |
2254 | ||
2255 | ||
ed3e11d8 | 2256 | /* |
589eb420 | 2257 | * 'cupsdValidateDest()' - Validate a printer/class destination. |
ed3e11d8 | 2258 | */ |
2259 | ||
2260 | const char * /* O - Printer or class name */ | |
f3e786fc | 2261 | cupsdValidateDest( |
2262 | const char *hostname, /* I - Host name */ | |
2263 | const char *resource, /* I - Resource name */ | |
2264 | cups_ptype_t *dtype, /* O - Type (printer or class) */ | |
2265 | cupsd_printer_t **printer) /* O - Printer pointer */ | |
ed3e11d8 | 2266 | { |
f3e786fc | 2267 | cupsd_printer_t *p; /* Current printer */ |
2268 | char localname[1024],/* Localized hostname */ | |
2269 | *lptr, /* Pointer into localized hostname */ | |
2270 | *sptr; /* Pointer into server name */ | |
ed3e11d8 | 2271 | |
2272 | ||
589eb420 | 2273 | DEBUG_printf(("cupsdValidateDest(\"%s\", \"%s\", %p, %p)\n", hostname, resource, |
bd5510a5 | 2274 | dtype, printer)); |
2275 | ||
2276 | /* | |
2277 | * Initialize return values... | |
2278 | */ | |
2279 | ||
2280 | if (printer) | |
2281 | *printer = NULL; | |
2282 | ||
2283 | *dtype = (cups_ptype_t)0; | |
962e5a9f | 2284 | |
ed3e11d8 | 2285 | /* |
2286 | * See if the resource is a class or printer... | |
2287 | */ | |
2288 | ||
b2e10895 | 2289 | if (!strncmp(resource, "/classes/", 9)) |
ed3e11d8 | 2290 | { |
2291 | /* | |
2292 | * Class... | |
2293 | */ | |
2294 | ||
ed3e11d8 | 2295 | resource += 9; |
2296 | } | |
b2e10895 | 2297 | else if (!strncmp(resource, "/printers/", 10)) |
ed3e11d8 | 2298 | { |
2299 | /* | |
2300 | * Printer... | |
2301 | */ | |
2302 | ||
ed3e11d8 | 2303 | resource += 10; |
2304 | } | |
2305 | else | |
2306 | { | |
2307 | /* | |
2308 | * Bad resource name... | |
2309 | */ | |
2310 | ||
2311 | return (NULL); | |
2312 | } | |
2313 | ||
2314 | /* | |
ad517a9f | 2315 | * See if the printer or class name exists... |
ed3e11d8 | 2316 | */ |
2317 | ||
589eb420 | 2318 | p = cupsdFindDest(resource); |
f8226c83 | 2319 | |
ad517a9f | 2320 | if (p == NULL && strchr(resource, '@') == NULL) |
2321 | return (NULL); | |
2322 | else if (p != NULL) | |
2323 | { | |
bd5510a5 | 2324 | if (printer) |
2325 | *printer = p; | |
2326 | ||
997cf8b0 | 2327 | *dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT | |
2328 | CUPS_PRINTER_REMOTE); | |
f8226c83 | 2329 | return (p->name); |
2330 | } | |
ed3e11d8 | 2331 | |
9fe0309f | 2332 | /* |
962e5a9f | 2333 | * Change localhost to the server name... |
9fe0309f | 2334 | */ |
2335 | ||
b2e10895 | 2336 | if (!strcasecmp(hostname, "localhost")) |
962e5a9f | 2337 | hostname = ServerName; |
2338 | ||
def978d5 | 2339 | strlcpy(localname, hostname, sizeof(localname)); |
9fe0309f | 2340 | |
b2e10895 | 2341 | if (!strcasecmp(hostname, ServerName)) |
9fe0309f | 2342 | { |
2343 | /* | |
962e5a9f | 2344 | * Localize the hostname... |
9fe0309f | 2345 | */ |
2346 | ||
962e5a9f | 2347 | lptr = strchr(localname, '.'); |
2348 | sptr = strchr(ServerName, '.'); | |
2349 | ||
2350 | if (sptr != NULL && lptr != NULL) | |
9fe0309f | 2351 | { |
962e5a9f | 2352 | /* |
2353 | * Strip the common domain name components... | |
2354 | */ | |
2355 | ||
2356 | while (lptr != NULL) | |
9fe0309f | 2357 | { |
b2e10895 | 2358 | if (!strcasecmp(lptr, sptr)) |
962e5a9f | 2359 | { |
2360 | *lptr = '\0'; | |
2361 | break; | |
2362 | } | |
2363 | else | |
2364 | lptr = strchr(lptr + 1, '.'); | |
9fe0309f | 2365 | } |
9fe0309f | 2366 | } |
2367 | } | |
2368 | ||
b30416bb | 2369 | DEBUG_printf(("localized hostname is \"%s\"...\n", localname)); |
ed3e11d8 | 2370 | |
2371 | /* | |
2372 | * Find a matching printer or class... | |
2373 | */ | |
2374 | ||
589eb420 | 2375 | for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); |
90231631 | 2376 | p; |
589eb420 | 2377 | p = (cupsd_printer_t *)cupsArrayNext(Printers)) |
b2e10895 | 2378 | if (!strcasecmp(p->hostname, localname) && |
2379 | !strcasecmp(p->name, resource)) | |
962e5a9f | 2380 | { |
bd5510a5 | 2381 | if (printer) |
2382 | *printer = p; | |
2383 | ||
997cf8b0 | 2384 | *dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT | |
2385 | CUPS_PRINTER_REMOTE); | |
ed3e11d8 | 2386 | return (p->name); |
962e5a9f | 2387 | } |
ed3e11d8 | 2388 | |
2389 | return (NULL); | |
2390 | } | |
2391 | ||
2392 | ||
cbbfcc63 | 2393 | /* |
589eb420 | 2394 | * 'cupsdWritePrintcap()' - Write a pseudo-printcap file for older applications |
f3e786fc | 2395 | * that need it... |
9cd605da | 2396 | */ |
2397 | ||
3a74d6bf | 2398 | void |
589eb420 | 2399 | cupsdWritePrintcap(void) |
9cd605da | 2400 | { |
f3e786fc | 2401 | cups_file_t *fp; /* printcap file */ |
589eb420 | 2402 | cupsd_printer_t *p; /* Current printer */ |
9cd605da | 2403 | |
2404 | ||
3a74d6bf | 2405 | #ifdef __sgi |
2406 | /* | |
2407 | * Update the IRIX printer state for the default printer; if | |
2408 | * no printers remain, then the default printer file will be | |
2409 | * removed... | |
2410 | */ | |
2411 | ||
2412 | write_irix_state(DefaultPrinter); | |
2413 | #endif /* __sgi */ | |
2414 | ||
9cd605da | 2415 | /* |
2416 | * See if we have a printcap file; if not, don't bother writing it. | |
2417 | */ | |
2418 | ||
42f94780 | 2419 | if (!Printcap || !*Printcap) |
9cd605da | 2420 | return; |
2421 | ||
2422 | /* | |
7efb04c8 | 2423 | * Open the printcap file... |
9cd605da | 2424 | */ |
2425 | ||
7b0fde61 | 2426 | if ((fp = cupsFileOpen(Printcap, "w")) == NULL) |
9cd605da | 2427 | return; |
2428 | ||
7b40ae49 | 2429 | /* |
2430 | * Put a comment header at the top so that users will know where the | |
2431 | * data has come from... | |
2432 | */ | |
2433 | ||
7b0fde61 | 2434 | cupsFilePuts(fp, "# This file was automatically generated by cupsd(8) from the\n"); |
2435 | cupsFilePrintf(fp, "# %s/printers.conf file. All changes to this file\n", | |
f3e786fc | 2436 | ServerRoot); |
7b0fde61 | 2437 | cupsFilePuts(fp, "# will be lost.\n"); |
7b40ae49 | 2438 | |
90231631 | 2439 | if (Printers) |
7efb04c8 | 2440 | { |
90231631 | 2441 | /* |
2442 | * Write a new printcap with the current list of printers. | |
2443 | */ | |
7cdd8a45 | 2444 | |
90231631 | 2445 | switch (PrintcapFormat) |
2446 | { | |
2447 | case PRINTCAP_BSD: | |
2448 | /* | |
2449 | * Each printer is put in the file as: | |
2450 | * | |
2451 | * Printer1: | |
2452 | * Printer2: | |
2453 | * Printer3: | |
2454 | * ... | |
2455 | * PrinterN: | |
2456 | */ | |
7efb04c8 | 2457 | |
90231631 | 2458 | if (DefaultPrinter) |
2459 | cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name, | |
2460 | DefaultPrinter->info, ServerName, DefaultPrinter->name); | |
7efb04c8 | 2461 | |
589eb420 | 2462 | for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); |
90231631 | 2463 | p; |
589eb420 | 2464 | p = (cupsd_printer_t *)cupsArrayNext(Printers)) |
90231631 | 2465 | if (p != DefaultPrinter) |
2466 | cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info, | |
2467 | ServerName, p->name); | |
2468 | break; | |
7efb04c8 | 2469 | |
90231631 | 2470 | case PRINTCAP_SOLARIS: |
2471 | /* | |
2472 | * Each printer is put in the file as: | |
2473 | * | |
2474 | * _all:all=Printer1,Printer2,Printer3,...,PrinterN | |
2475 | * _default:use=DefaultPrinter | |
2476 | * Printer1:\ | |
2477 | * :bsdaddr=ServerName,Printer1:\ | |
2478 | * :description=Description: | |
2479 | * Printer2: | |
2480 | * :bsdaddr=ServerName,Printer2:\ | |
2481 | * :description=Description: | |
2482 | * Printer3: | |
2483 | * :bsdaddr=ServerName,Printer3:\ | |
2484 | * :description=Description: | |
2485 | * ... | |
2486 | * PrinterN: | |
2487 | * :bsdaddr=ServerName,PrinterN:\ | |
2488 | * :description=Description: | |
2489 | */ | |
7efb04c8 | 2490 | |
90231631 | 2491 | cupsFilePuts(fp, "_all:all="); |
589eb420 | 2492 | for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); |
90231631 | 2493 | p; |
589eb420 | 2494 | p = (cupsd_printer_t *)cupsArrayCurrent(Printers)) |
90231631 | 2495 | cupsFilePrintf(fp, "%s%c", p->name, |
2496 | cupsArrayNext(Printers) ? ',' : '\n'); | |
2497 | ||
2498 | if (DefaultPrinter) | |
2499 | cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name); | |
2500 | ||
589eb420 | 2501 | for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); |
90231631 | 2502 | p; |
589eb420 | 2503 | p = (cupsd_printer_t *)cupsArrayNext(Printers)) |
90231631 | 2504 | cupsFilePrintf(fp, "%s:\\\n" |
2505 | "\t:bsdaddr=%s,%s:\\\n" | |
2506 | "\t:description=%s:\n", | |
2507 | p->name, ServerName, p->name, p->info ? p->info : ""); | |
2508 | break; | |
2509 | } | |
7efb04c8 | 2510 | } |
9cd605da | 2511 | |
2512 | /* | |
957c6597 | 2513 | * Close the file... |
9cd605da | 2514 | */ |
2515 | ||
7b0fde61 | 2516 | cupsFileClose(fp); |
9cd605da | 2517 | } |
2518 | ||
2519 | ||
2cb3f80d | 2520 | /* |
2521 | * 'cupsdSanitizeURI()' - Sanitize a device URI... | |
2522 | */ | |
2523 | ||
2524 | char * /* O - New device URI */ | |
2525 | cupsdSanitizeURI(const char *uri, /* I - Original device URI */ | |
2526 | char *buffer, /* O - New device URI */ | |
2527 | int buflen) /* I - Size of new device URI buffer */ | |
2528 | { | |
2529 | char *start, /* Start of data after scheme */ | |
2530 | *slash, /* First slash after scheme:// */ | |
2531 | *ptr; /* Pointer into user@host:port part */ | |
2532 | ||
2533 | ||
2534 | /* | |
2535 | * Range check input... | |
2536 | */ | |
2537 | ||
2538 | if (!uri || !buffer || buflen < 2) | |
2539 | return (NULL); | |
2540 | ||
2541 | /* | |
2542 | * Copy the device URI to the new buffer... | |
2543 | */ | |
2544 | ||
2545 | strlcpy(buffer, uri, buflen); | |
2546 | ||
2547 | /* | |
2548 | * Find the end of the scheme:// part... | |
2549 | */ | |
2550 | ||
2551 | if ((ptr = strchr(buffer, ':')) == NULL) | |
2552 | return (buffer); /* No scheme: part... */ | |
2553 | ||
2554 | for (start = ptr + 1; *start; start ++) | |
2555 | if (*start != '/') | |
2556 | break; | |
2557 | ||
2558 | /* | |
2559 | * Find the next slash (/) in the URI... | |
2560 | */ | |
2561 | ||
2562 | if ((slash = strchr(start, '/')) == NULL) | |
2563 | slash = start + strlen(start); /* No slash, point to the end */ | |
2564 | ||
2565 | /* | |
2566 | * Check for an @ sign before the slash... | |
2567 | */ | |
2568 | ||
2569 | if ((ptr = strchr(start, '@')) != NULL && ptr < slash) | |
2570 | { | |
2571 | /* | |
2572 | * Found an @ sign and it is before the resource part, so we have | |
2573 | * an authentication string. Copy the remaining URI over the | |
2574 | * authentication string... | |
2575 | */ | |
2576 | ||
2625096f | 2577 | _cups_strcpy(start, ptr + 1); |
2cb3f80d | 2578 | } |
2579 | ||
2580 | /* | |
2581 | * Return the new device URI... | |
2582 | */ | |
2583 | ||
2584 | return (buffer); | |
2585 | } | |
2586 | ||
2587 | ||
d318937f | 2588 | /* |
2589 | * 'add_printer_filter()' - Add a MIME filter for a printer. | |
2590 | */ | |
2591 | ||
2592 | static void | |
2593 | add_printer_filter( | |
2594 | cupsd_printer_t *p, /* I - Printer to add to */ | |
2595 | const char *filter) /* I - Filter to add */ | |
2596 | { | |
2597 | char super[MIME_MAX_SUPER], /* Super-type for filter */ | |
2598 | type[MIME_MAX_TYPE], /* Type for filter */ | |
2599 | program[1024]; /* Program/filter name */ | |
2600 | int cost; /* Cost of filter */ | |
2601 | mime_type_t *temptype; /* MIME type looping var */ | |
2602 | ||
2603 | ||
2604 | /* | |
2605 | * Range check input... | |
2606 | */ | |
2607 | ||
2608 | if (p == NULL || p->filetype == NULL || filter == NULL) | |
2609 | return; | |
2610 | ||
2611 | /* | |
2612 | * Parse the filter string; it should be in the following format: | |
2613 | * | |
2614 | * super/type cost program | |
2615 | */ | |
2616 | ||
2617 | if (sscanf(filter, "%15[^/]/%31s%d%1023s", super, type, &cost, program) != 4) | |
2618 | { | |
2619 | cupsdLogMessage(CUPSD_LOG_ERROR, "%s: invalid filter string \"%s\"!", | |
2620 | p->name, filter); | |
2621 | return; | |
2622 | } | |
2623 | ||
2624 | /* | |
2625 | * Add the filter to the MIME database, supporting wildcards as needed... | |
2626 | */ | |
2627 | ||
2628 | for (temptype = mimeFirstType(MimeDatabase); | |
2629 | temptype; | |
2630 | temptype = mimeNextType(MimeDatabase)) | |
2631 | if (((super[0] == '*' && strcasecmp(temptype->super, "printer")) || | |
2632 | !strcasecmp(temptype->super, super)) && | |
2633 | (type[0] == '*' || !strcasecmp(temptype->type, type))) | |
2634 | { | |
2635 | cupsdLogMessage(CUPSD_LOG_DEBUG2, | |
2636 | "add_printer_filter: %s: adding filter %s/%s %s/%s %d %s", | |
2637 | p->name, temptype->super, temptype->type, | |
2638 | p->filetype->super, p->filetype->type, | |
2639 | cost, program); | |
2640 | mimeAddFilter(MimeDatabase, temptype, p->filetype, cost, program); | |
2641 | } | |
2642 | } | |
2643 | ||
2644 | ||
2645 | /* | |
2646 | * 'add_printer_formats()' - Add document-format-supported values for a printer. | |
2647 | */ | |
2648 | ||
2649 | static void | |
2650 | add_printer_formats(cupsd_printer_t *p) /* I - Printer */ | |
2651 | { | |
2652 | int i; /* Looping var */ | |
2653 | mime_type_t *type; /* Current MIME type */ | |
2654 | cups_array_t *filters; /* Filters */ | |
2655 | int num_types; /* Number of supported types */ | |
2656 | const char **types; /* Array of supported type names */ | |
2657 | char mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2]; | |
2658 | /* MIME type name */ | |
2659 | ||
2660 | ||
2661 | /* | |
2662 | * Raw (and remote) queues advertise all of the supported MIME | |
2663 | * types... | |
2664 | */ | |
2665 | ||
2666 | if (p->raw) | |
2667 | { | |
2668 | ippAddStrings(p->attrs, IPP_TAG_PRINTER, | |
2669 | (ipp_tag_t)(IPP_TAG_MIMETYPE | IPP_TAG_COPY), | |
2670 | "document-format-supported", NumMimeTypes, NULL, MimeTypes); | |
2671 | return; | |
2672 | } | |
2673 | ||
2674 | /* | |
2675 | * Otherwise, loop through the supported MIME types and see if there | |
2676 | * are filters for them... | |
2677 | */ | |
2678 | ||
2679 | if ((types = calloc(NumMimeTypes, sizeof(char *))) == NULL) | |
2680 | { | |
2681 | cupsdLogMessage(CUPSD_LOG_EMERG, | |
2682 | "Unable to allocate memory for \"%s\" MIME type list!", | |
2683 | p->name); | |
2684 | return; | |
2685 | } | |
2686 | ||
2687 | cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_printer_formats: %d types, %d filters", | |
2688 | mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase)); | |
2689 | ||
2690 | types[0] = _cups_sp_alloc("application/octet-stream"); | |
2691 | ||
2692 | for (num_types = 1, type = mimeFirstType(MimeDatabase); | |
2693 | type; | |
2694 | type = mimeNextType(MimeDatabase)) | |
2695 | { | |
2696 | if (!strcasecmp(type->super, "application") && | |
2697 | !strcasecmp(type->type, "octet-stream")) | |
2698 | continue; | |
2699 | ||
2700 | snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type); | |
2701 | ||
2702 | if ((filters = mimeFilter(MimeDatabase, type, p->filetype, NULL)) != NULL) | |
2703 | { | |
2704 | cupsdLogMessage(CUPSD_LOG_DEBUG2, | |
2705 | "add_printer_formats: %s: %s needs %d filters", | |
2706 | p->name, mimetype, cupsArrayCount(filters)); | |
2707 | ||
2708 | cupsArrayDelete(filters); | |
2709 | types[num_types] = _cups_sp_alloc(mimetype); | |
2710 | num_types ++; | |
2711 | } | |
2712 | else | |
2713 | cupsdLogMessage(CUPSD_LOG_DEBUG2, | |
2714 | "add_printer_formats: %s: %s not supported", | |
2715 | p->name, mimetype); | |
2716 | } | |
2717 | ||
2718 | cupsdLogMessage(CUPSD_LOG_DEBUG2, | |
2719 | "add_printer_formats: %s: %d supported types", | |
2720 | p->name, num_types); | |
2721 | ||
2722 | /* | |
2723 | * Add the file formats that can be filtered... | |
2724 | */ | |
2725 | ||
2726 | ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, | |
2727 | "document-format-supported", num_types, NULL, types); | |
2728 | ||
2729 | /* | |
2730 | * Free the temporary data... | |
2731 | */ | |
2732 | ||
2733 | for (i = 0; i < num_types; i ++) | |
2734 | _cups_sp_free(types[i]); | |
2735 | ||
2736 | free(types); | |
2737 | } | |
2738 | ||
2739 | ||
90231631 | 2740 | /* |
2741 | * 'compare_printers()' - Compare two printers. | |
2742 | */ | |
2743 | ||
2744 | static int /* O - Result of comparison */ | |
2745 | compare_printers(void *first, /* I - First printer */ | |
2746 | void *second, /* I - Second printer */ | |
2747 | void *data) /* I - App data (not used) */ | |
2748 | { | |
589eb420 | 2749 | return (strcasecmp(((cupsd_printer_t *)first)->name, |
2750 | ((cupsd_printer_t *)second)->name)); | |
90231631 | 2751 | } |
2752 | ||
2753 | ||
cf0959e5 | 2754 | /* |
2755 | * 'transcode_nickname()' - Convert the PPD NickName to UTF-8... | |
2756 | */ | |
2757 | ||
2758 | static void | |
2759 | transcode_nickname(cupsd_printer_t *p, /* I - Printer */ | |
2760 | ppd_file_t *ppd)/* I - PPD file */ | |
2761 | { | |
2762 | cups_utf8_t utf8[256]; /* UTF-8 version of nickname */ | |
2763 | cups_encoding_t encoding; /* Encoding of PPD file */ | |
2764 | const char *nickptr; /* Pointer into nickname */ | |
2765 | ||
2766 | ||
2767 | /* | |
2768 | * See if we need to convert to UTF-8... | |
2769 | */ | |
2770 | ||
2771 | if (!ppd->lang_encoding || !strcasecmp(ppd->lang_encoding, "UTF-8")) | |
2772 | { | |
2773 | /* | |
2774 | * No language encoding, or encoding uses the non-standard UTF-8 | |
2775 | * value, so no transcoding is required... | |
2776 | */ | |
2777 | ||
2778 | goto no_transcode; | |
2779 | } | |
2780 | ||
2781 | for (nickptr = ppd->nickname; *nickptr; nickptr ++) | |
2782 | if (*nickptr & 0x80) | |
2783 | break; | |
2784 | ||
2785 | if (!*nickptr) | |
2786 | { | |
2787 | /* | |
2788 | * No non-ASCII characters, so no transcoding is required... | |
2789 | */ | |
2790 | ||
2791 | goto no_transcode; | |
2792 | } | |
2793 | ||
2794 | /* | |
2795 | * OK, we need to transcode... | |
2796 | */ | |
2797 | ||
2798 | if (!strcasecmp(ppd->lang_encoding, "ISOLatin1")) | |
2799 | encoding = CUPS_ISO8859_1; | |
2800 | else if (!strcasecmp(ppd->lang_encoding, "ISOLatin2")) | |
2801 | encoding = CUPS_ISO8859_2; | |
2802 | else if (!strcasecmp(ppd->lang_encoding, "ISOLatin5")) | |
2803 | encoding = CUPS_ISO8859_5; | |
2804 | else if (!strcasecmp(ppd->lang_encoding, "JIS83-RKSJ")) | |
2805 | encoding = CUPS_WINDOWS_932; | |
2806 | else if (!strcasecmp(ppd->lang_encoding, "MacStandard")) | |
2807 | encoding = CUPS_MAC_ROMAN; | |
2808 | else if (!strcasecmp(ppd->lang_encoding, "WindowsANSI")) | |
2809 | encoding = CUPS_WINDOWS_1252; | |
2810 | else | |
2811 | { | |
2812 | /* | |
2813 | * Unknown encoding, treat as UTF-8... | |
2814 | */ | |
2815 | ||
2816 | goto no_transcode; | |
2817 | } | |
2818 | ||
2819 | cupsCharsetToUTF8(utf8, ppd->nickname, sizeof(utf8), encoding); | |
2820 | ||
2821 | cupsdSetString(&p->make_model, (char *)utf8); | |
2822 | ||
2823 | return; | |
2824 | ||
2825 | /* | |
2826 | * Yeah, yeah, gotos are evil, but code bloat is more evil... | |
2827 | */ | |
2828 | ||
2829 | no_transcode: | |
2830 | ||
2831 | cupsdSetString(&p->make_model, ppd->nickname); | |
2832 | return; | |
2833 | } | |
2834 | ||
2835 | ||
9ae34eb7 | 2836 | #ifdef __sgi |
2837 | /* | |
dd5cfc84 | 2838 | * 'write_irix_config()' - Update the config files used by the IRIX |
2839 | * desktop tools. | |
9ae34eb7 | 2840 | */ |
2841 | ||
2842 | static void | |
f3e786fc | 2843 | write_irix_config(cupsd_printer_t *p) /* I - Printer to update */ |
9ae34eb7 | 2844 | { |
7b0fde61 | 2845 | char filename[1024]; /* Interface script filename */ |
2846 | cups_file_t *fp; /* Interface script file */ | |
9ae34eb7 | 2847 | |
2848 | ||
dd5cfc84 | 2849 | |
9ae34eb7 | 2850 | /* |
dd5cfc84 | 2851 | * Add dummy interface and GUI scripts to fool SGI's "challenged" printing |
2852 | * tools. First the interface script that tells the tools what kind of | |
2853 | * printer we have... | |
9ae34eb7 | 2854 | */ |
2855 | ||
dd5cfc84 | 2856 | snprintf(filename, sizeof(filename), "/var/spool/lp/interface/%s", p->name); |
9ae34eb7 | 2857 | |
dd5cfc84 | 2858 | if (p->type & CUPS_PRINTER_CLASS) |
2859 | unlink(filename); | |
7b0fde61 | 2860 | else if ((fp = cupsFileOpen(filename, "w")) != NULL) |
9ae34eb7 | 2861 | { |
7b0fde61 | 2862 | cupsFilePuts(fp, "#!/bin/sh\n"); |
dd5cfc84 | 2863 | |
2864 | if ((attr = ippFindAttribute(p->attrs, "printer-make-and-model", | |
2865 | IPP_TAG_TEXT)) != NULL) | |
7b0fde61 | 2866 | cupsFilePrintf(fp, "NAME=\"%s\"\n", attr->values[0].string.text); |
dd5cfc84 | 2867 | else if (p->type & CUPS_PRINTER_CLASS) |
7b0fde61 | 2868 | cupsFilePuts(fp, "NAME=\"Printer Class\"\n"); |
dd5cfc84 | 2869 | else |
7b0fde61 | 2870 | cupsFilePuts(fp, "NAME=\"Remote Destination\"\n"); |
dd5cfc84 | 2871 | |
2872 | if (p->type & CUPS_PRINTER_COLOR) | |
7b0fde61 | 2873 | cupsFilePuts(fp, "TYPE=ColorPostScript\n"); |
dd5cfc84 | 2874 | else |
7b0fde61 | 2875 | cupsFilePuts(fp, "TYPE=MonoPostScript\n"); |
dd5cfc84 | 2876 | |
7b0fde61 | 2877 | cupsFilePrintf(fp, "HOSTNAME=%s\n", ServerName); |
2878 | cupsFilePrintf(fp, "HOSTPRINTER=%s\n", p->name); | |
9ae34eb7 | 2879 | |
7b0fde61 | 2880 | cupsFileClose(fp); |
9ae34eb7 | 2881 | |
dd5cfc84 | 2882 | chmod(filename, 0755); |
9ae34eb7 | 2883 | chown(filename, User, Group); |
2884 | } | |
2885 | ||
2886 | /* | |
dd5cfc84 | 2887 | * Then the member file that tells which device file the queue is connected |
2888 | * to... Networked printers use "/dev/null" in this file, so that's what | |
2889 | * we use (the actual device URI can confuse some apps...) | |
9ae34eb7 | 2890 | */ |
2891 | ||
dd5cfc84 | 2892 | snprintf(filename, sizeof(filename), "/var/spool/lp/member/%s", p->name); |
9ae34eb7 | 2893 | |
dd5cfc84 | 2894 | if (p->type & CUPS_PRINTER_CLASS) |
2895 | unlink(filename); | |
7b0fde61 | 2896 | else if ((fp = cupsFileOpen(filename, "w")) != NULL) |
9ae34eb7 | 2897 | { |
7b0fde61 | 2898 | cupsFilePuts(fp, "/dev/null\n"); |
9ae34eb7 | 2899 | |
7b0fde61 | 2900 | cupsFileClose(fp); |
9ae34eb7 | 2901 | |
dd5cfc84 | 2902 | chmod(filename, 0644); |
2903 | chown(filename, User, Group); | |
2904 | } | |
9ae34eb7 | 2905 | |
dd5cfc84 | 2906 | /* |
2907 | * The gui_interface file is a script or program that launches a GUI | |
2908 | * option panel for the printer, using options specified on the | |
2909 | * command-line in the third argument. The option panel must send | |
2910 | * any printing options to stdout on a single line when the user | |
2911 | * accepts them, or nothing if the user cancels the dialog. | |
2912 | * | |
2913 | * The default options panel program is /usr/bin/glpoptions, from | |
2914 | * the ESP Print Pro software. You can select another using the | |
2915 | * PrintcapGUI option. | |
2916 | */ | |
2917 | ||
2918 | snprintf(filename, sizeof(filename), "/var/spool/lp/gui_interface/ELF/%s.gui", p->name); | |
9ae34eb7 | 2919 | |
dd5cfc84 | 2920 | if (p->type & CUPS_PRINTER_CLASS) |
2921 | unlink(filename); | |
7b0fde61 | 2922 | else if ((fp = cupsFileOpen(filename, "w")) != NULL) |
dd5cfc84 | 2923 | { |
7b0fde61 | 2924 | cupsFilePuts(fp, "#!/bin/sh\n"); |
2925 | cupsFilePrintf(fp, "%s -d %s -o \"$3\"\n", PrintcapGUI, p->name); | |
9ae34eb7 | 2926 | |
7b0fde61 | 2927 | cupsFileClose(fp); |
9ae34eb7 | 2928 | |
2929 | chmod(filename, 0755); | |
2930 | chown(filename, User, Group); | |
2931 | } | |
2932 | ||
dd5cfc84 | 2933 | /* |
2934 | * The POD config file is needed by the printstatus command to show | |
2935 | * the printer location and device. | |
2936 | */ | |
2937 | ||
2938 | snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.config", p->name); | |
2939 | ||
2940 | if (p->type & CUPS_PRINTER_CLASS) | |
2941 | unlink(filename); | |
7b0fde61 | 2942 | else if ((fp = cupsFileOpen(filename, "w")) != NULL) |
dd5cfc84 | 2943 | { |
7b0fde61 | 2944 | cupsFilePrintf(fp, "Printer Class | %s\n", |
dd5cfc84 | 2945 | (p->type & CUPS_PRINTER_COLOR) ? "ColorPostScript" : "MonoPostScript"); |
7b0fde61 | 2946 | cupsFilePrintf(fp, "Printer Model | %s\n", p->make_model ? p->make_model : ""); |
2947 | cupsFilePrintf(fp, "Location Code | %s\n", p->location ? p->location : ""); | |
2948 | cupsFilePrintf(fp, "Physical Location | %s\n", p->info ? p->info : ""); | |
2949 | cupsFilePrintf(fp, "Port Path | %s\n", p->device_uri ? p->device_uri : ""); | |
2950 | cupsFilePrintf(fp, "Config Path | /var/spool/lp/pod/%s.config\n", p->name); | |
2951 | cupsFilePrintf(fp, "Active Status Path | /var/spool/lp/pod/%s.status\n", p->name); | |
2952 | cupsFilePuts(fp, "Status Update Wait | 10 seconds\n"); | |
dd5cfc84 | 2953 | |
7b0fde61 | 2954 | cupsFileClose(fp); |
dd5cfc84 | 2955 | |
2956 | chmod(filename, 0664); | |
2957 | chown(filename, User, Group); | |
2958 | } | |
b2e10895 | 2959 | } |
dd5cfc84 | 2960 | |
2961 | ||
2962 | /* | |
2963 | * 'write_irix_state()' - Update the status files used by IRIX printing | |
2964 | * desktop tools. | |
2965 | */ | |
2966 | ||
2967 | static void | |
f3e786fc | 2968 | write_irix_state(cupsd_printer_t *p) /* I - Printer to update */ |
dd5cfc84 | 2969 | { |
7b0fde61 | 2970 | char filename[1024]; /* Interface script filename */ |
2971 | cups_file_t *fp; /* Interface script file */ | |
2972 | int tag; /* Status tag value */ | |
dd5cfc84 | 2973 | |
2974 | ||
2975 | if (p) | |
2976 | { | |
2977 | /* | |
2978 | * The POD status file is needed for the printstatus window to | |
2979 | * provide the current status of the printer. | |
2980 | */ | |
2981 | ||
2982 | snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.status", p->name); | |
2983 | ||
2984 | if (p->type & CUPS_PRINTER_CLASS) | |
2985 | unlink(filename); | |
7b0fde61 | 2986 | else if ((fp = cupsFileOpen(filename, "w")) != NULL) |
dd5cfc84 | 2987 | { |
7b0fde61 | 2988 | cupsFilePrintf(fp, "Operational Status | %s\n", |
dd5cfc84 | 2989 | (p->state == IPP_PRINTER_IDLE) ? "Idle" : |
2990 | (p->state == IPP_PRINTER_PROCESSING) ? "Busy" : | |
2991 | "Faulted"); | |
7b0fde61 | 2992 | cupsFilePrintf(fp, "Information | 01 00 00 | %s\n", CUPS_SVERSION); |
2993 | cupsFilePrintf(fp, "Information | 02 00 00 | Device URI: %s\n", | |
36992080 | 2994 | p->device_uri ? p->device_uri : ""); |
7b0fde61 | 2995 | cupsFilePrintf(fp, "Information | 03 00 00 | %s jobs\n", |
dd5cfc84 | 2996 | p->accepting ? "Accepting" : "Not accepting"); |
7b0fde61 | 2997 | cupsFilePrintf(fp, "Information | 04 00 00 | %s\n", p->state_message); |
dd5cfc84 | 2998 | |
7b0fde61 | 2999 | cupsFileClose(fp); |
dd5cfc84 | 3000 | |
3001 | chmod(filename, 0664); | |
3002 | chown(filename, User, Group); | |
3003 | } | |
3004 | ||
3005 | /* | |
3006 | * The activeicons file is needed to provide desktop icons for printers: | |
3007 | * | |
3008 | * [ quoted from /usr/lib/print/tagit ] | |
3009 | * | |
3010 | * --- Type of printer tags (base values) | |
3011 | * | |
3012 | * Dumb=66048 # 0x10200 | |
3013 | * DumbColor=66080 # 0x10220 | |
3014 | * Raster=66112 # 0x10240 | |
3015 | * ColorRaster=66144 # 0x10260 | |
3016 | * Plotter=66176 # 0x10280 | |
3017 | * PostScript=66208 # 0x102A0 | |
3018 | * ColorPostScript=66240 # 0x102C0 | |
3019 | * MonoPostScript=66272 # 0x102E0 | |
3020 | * | |
3021 | * --- Printer state modifiers for local printers | |
3022 | * | |
3023 | * Idle=0 # 0x0 | |
3024 | * Busy=1 # 0x1 | |
3025 | * Faulted=2 # 0x2 | |
3026 | * Unknown=3 # 0x3 (Faulted due to unknown reason) | |
3027 | * | |
3028 | * --- Printer state modifiers for network printers | |
3029 | * | |
3030 | * NetIdle=8 # 0x8 | |
3031 | * NetBusy=9 # 0x9 | |
3032 | * NetFaulted=10 # 0xA | |
3033 | * NetUnknown=11 # 0xB (Faulted due to unknown reason) | |
3034 | */ | |
3035 | ||
3036 | snprintf(filename, sizeof(filename), "/var/spool/lp/activeicons/%s", p->name); | |
3037 | ||
3038 | if (p->type & CUPS_PRINTER_CLASS) | |
3039 | unlink(filename); | |
7b0fde61 | 3040 | else if ((fp = cupsFileOpen(filename, "w")) != NULL) |
dd5cfc84 | 3041 | { |
3042 | if (p->type & CUPS_PRINTER_COLOR) | |
3043 | tag = 66240; | |
3044 | else | |
3045 | tag = 66272; | |
3046 | ||
3047 | if (p->type & CUPS_PRINTER_REMOTE) | |
3048 | tag |= 8; | |
3049 | ||
3050 | if (p->state == IPP_PRINTER_PROCESSING) | |
3051 | tag |= 1; | |
3052 | ||
3053 | else if (p->state == IPP_PRINTER_STOPPED) | |
3054 | tag |= 2; | |
3055 | ||
7b0fde61 | 3056 | cupsFilePuts(fp, "#!/bin/sh\n"); |
3057 | cupsFilePrintf(fp, "#Tag %d\n", tag); | |
dd5cfc84 | 3058 | |
7b0fde61 | 3059 | cupsFileClose(fp); |
dd5cfc84 | 3060 | |
3061 | chmod(filename, 0755); | |
3062 | chown(filename, User, Group); | |
3063 | } | |
3064 | } | |
3065 | ||
9ae34eb7 | 3066 | /* |
3067 | * The default file is needed by the printers window to show | |
3068 | * the default printer. | |
3069 | */ | |
3070 | ||
3071 | snprintf(filename, sizeof(filename), "/var/spool/lp/default"); | |
3072 | ||
3073 | if (DefaultPrinter != NULL) | |
3074 | { | |
7b0fde61 | 3075 | if ((fp = cupsFileOpen(filename, "w")) != NULL) |
9ae34eb7 | 3076 | { |
7b0fde61 | 3077 | cupsFilePrintf(fp, "%s\n", DefaultPrinter->name); |
9ae34eb7 | 3078 | |
7b0fde61 | 3079 | cupsFileClose(fp); |
9ae34eb7 | 3080 | |
3081 | chmod(filename, 0644); | |
3082 | chown(filename, User, Group); | |
3083 | } | |
3084 | } | |
3085 | else | |
3086 | unlink(filename); | |
3087 | } | |
3088 | #endif /* __sgi */ | |
3089 | ||
3090 | ||
9cd605da | 3091 | /* |
b2e10895 | 3092 | * End of "$Id$". |
a129ddbd | 3093 | */ |