2 * "$Id: util.c 7850 2008-08-20 00:07:25Z mike $"
4 * Printing utilities for CUPS.
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * cupsCancelJob() - Cancel a print job on the default server.
20 * cupsCancelJob2() - Cancel or purge a print job.
21 * cupsCreateJob() - Create an empty job for streaming.
22 * cupsFinishDocument() - Finish sending a document.
23 * cupsFreeJobs() - Free memory used by job data.
24 * cupsGetClasses() - Get a list of printer classes from the default
26 * cupsGetDefault() - Get the default printer or class for the default
28 * cupsGetDefault2() - Get the default printer or class for the specified
30 * cupsGetJobs() - Get the jobs from the default server.
31 * cupsGetJobs2() - Get the jobs from the specified server.
32 * cupsGetPPD() - Get the PPD file for a printer on the default
34 * cupsGetPPD2() - Get the PPD file for a printer from the specified
36 * cupsGetPPD3() - Get the PPD file for a printer on the specified
37 * server if it has changed.
38 * cupsGetPrinters() - Get a list of printers from the default server.
39 * cupsGetServerPPD() - Get an available PPD file from the server.
40 * cupsPrintFile() - Print a file to a printer or class on the default
42 * cupsPrintFile2() - Print a file to a printer or class on the
44 * cupsPrintFiles() - Print one or more files to a printer or class on
46 * cupsPrintFiles2() - Print one or more files to a printer or class on
47 * the specified server.
48 * cupsStartDocument() - Add a document to a job created with
50 * cups_get_printer_uri() - Get the printer-uri-supported attribute for the
51 * first printer in a class.
55 * Include necessary headers...
58 #include "cups-private.h"
61 #if defined(WIN32) || defined(__EMX__)
65 #endif /* WIN32 || __EMX__ */
72 static int cups_get_printer_uri(http_t
*http
, const char *name
,
73 char *host
, int hostsize
, int *port
,
74 char *resource
, int resourcesize
,
79 * 'cupsCancelJob()' - Cancel a print job on the default server.
81 * Pass @code CUPS_JOBID_ALL@ to cancel all jobs or @code CUPS_JOBID_CURRENT@
82 * to cancel the current job on the named destination.
84 * Use the @link cupsLastError@ and @link cupsLastErrorString@ functions to get
85 * the cause of any failure.
88 int /* O - 1 on success, 0 on failure */
89 cupsCancelJob(const char *name
, /* I - Name of printer or class */
90 int job_id
) /* I - Job ID, @code CUPS_JOBID_CURRENT@ for the current job, or @code CUPS_JOBID_ALL@ for all jobs */
92 return (cupsCancelJob2(CUPS_HTTP_DEFAULT
, name
, job_id
, 0)
93 < IPP_REDIRECTION_OTHER_SITE
);
98 * 'cupsCancelJob2()' - Cancel or purge a print job.
100 * Canceled jobs remain in the job history while purged jobs are removed
101 * from the job history.
103 * Pass @code CUPS_JOBID_ALL@ to cancel all jobs or @code CUPS_JOBID_CURRENT@
104 * to cancel the current job on the named destination.
106 * Use the @link cupsLastError@ and @link cupsLastErrorString@ functions to get
107 * the cause of any failure.
109 * @since CUPS 1.4/Mac OS X 10.6@
112 ipp_status_t
/* O - IPP status */
113 cupsCancelJob2(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
114 const char *name
, /* I - Name of printer or class */
115 int job_id
, /* I - Job ID, @code CUPS_JOBID_CURRENT@ for the current job, or @code CUPS_JOBID_ALL@ for all jobs */
116 int purge
) /* I - 1 to purge, 0 to cancel */
118 char uri
[HTTP_MAX_URI
]; /* Job/printer URI */
119 ipp_t
*request
; /* IPP request */
123 * Range check input...
126 if (job_id
< -1 || (!name
&& job_id
== 0))
128 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
133 * Connect to the default server as needed...
137 if ((http
= _cupsConnect()) == NULL
)
138 return (IPP_SERVICE_UNAVAILABLE
);
141 * Build an IPP_CANCEL_JOB or IPP_PURGE_JOBS request, which requires the following
145 * attributes-natural-language
146 * job-uri or printer-uri + job-id
147 * requesting-user-name
148 * [purge-job] or [purge-jobs]
151 request
= ippNewRequest(job_id
< 0 ? IPP_PURGE_JOBS
: IPP_CANCEL_JOB
);
155 httpAssembleURIf(HTTP_URI_CODING_ALL
, uri
, sizeof(uri
), "ipp", NULL
,
156 "localhost", ippPort(), "/printers/%s", name
);
158 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri", NULL
,
160 ippAddInteger(request
, IPP_TAG_OPERATION
, IPP_TAG_INTEGER
, "job-id",
165 snprintf(uri
, sizeof(uri
), "ipp://localhost/jobs/%d", job_id
);
167 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "job-uri", NULL
, uri
);
170 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
173 if (purge
&& job_id
>= 0)
174 ippAddBoolean(request
, IPP_TAG_OPERATION
, "purge-job", 1);
175 else if (!purge
&& job_id
< 0)
176 ippAddBoolean(request
, IPP_TAG_OPERATION
, "purge-jobs", 0);
182 ippDelete(cupsDoRequest(http
, request
, "/jobs/"));
184 return (cupsLastError());
189 * 'cupsCreateJob()' - Create an empty job for streaming.
191 * Use this function when you want to stream print data using the
192 * @link cupsStartDocument@, @link cupsWriteRequestData@, and
193 * @link cupsFinishDocument@ functions. If you have one or more files to
194 * print, use the @link cupsPrintFile2@ or @link cupsPrintFiles2@ function
197 * @since CUPS 1.4/Mac OS X 10.6@
200 int /* O - Job ID or 0 on error */
202 http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
203 const char *name
, /* I - Destination name */
204 const char *title
, /* I - Title of job */
205 int num_options
, /* I - Number of options */
206 cups_option_t
*options
) /* I - Options */
208 char printer_uri
[1024], /* Printer URI */
209 resource
[1024]; /* Printer resource */
210 ipp_t
*request
, /* Create-Job request */
211 *response
; /* Create-Job response */
212 ipp_attribute_t
*attr
; /* job-id attribute */
213 int job_id
= 0; /* job-id value */
216 DEBUG_printf(("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", "
217 "num_options=%d, options=%p)",
218 http
, name
, title
, num_options
, options
));
221 * Range check input...
226 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
231 * Build a Create-Job request...
234 if ((request
= ippNewRequest(IPP_CREATE_JOB
)) == NULL
)
236 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(ENOMEM
), 0);
240 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
), "ipp",
241 NULL
, "localhost", ippPort(), "/printers/%s", name
);
242 snprintf(resource
, sizeof(resource
), "/printers/%s", name
);
244 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
246 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
249 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "job-name", NULL
,
251 cupsEncodeOptions(request
, num_options
, options
);
254 * Send the request and get the job-id...
257 response
= cupsDoRequest(http
, request
, resource
);
259 if ((attr
= ippFindAttribute(response
, "job-id", IPP_TAG_INTEGER
)) != NULL
)
260 job_id
= attr
->values
[0].integer
;
273 * 'cupsFinishDocument()' - Finish sending a document.
275 * The document must have been started using @link cupsStartDocument@.
277 * @since CUPS 1.4/Mac OS X 10.6@
280 ipp_status_t
/* O - Status of document submission */
281 cupsFinishDocument(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
282 const char *name
) /* I - Destination name */
284 char resource
[1024]; /* Printer resource */
287 snprintf(resource
, sizeof(resource
), "/printers/%s", name
);
289 ippDelete(cupsGetResponse(http
, resource
));
291 return (cupsLastError());
296 * 'cupsFreeJobs()' - Free memory used by job data.
300 cupsFreeJobs(int num_jobs
, /* I - Number of jobs */
301 cups_job_t
*jobs
) /* I - Jobs */
303 int i
; /* Looping var */
304 cups_job_t
*job
; /* Current job */
307 if (num_jobs
<= 0 || !jobs
)
310 for (i
= num_jobs
, job
= jobs
; i
> 0; i
--, job
++)
312 _cupsStrFree(job
->dest
);
313 _cupsStrFree(job
->user
);
314 _cupsStrFree(job
->format
);
315 _cupsStrFree(job
->title
);
323 * 'cupsGetClasses()' - Get a list of printer classes from the default server.
325 * This function is deprecated - use @link cupsGetDests@ instead.
330 int /* O - Number of classes */
331 cupsGetClasses(char ***classes
) /* O - Classes */
333 int n
; /* Number of classes */
334 ipp_t
*request
, /* IPP Request */
335 *response
; /* IPP Response */
336 ipp_attribute_t
*attr
; /* Current attribute */
337 char **temp
; /* Temporary pointer */
338 http_t
*http
; /* Connection to server */
343 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
350 if ((http
= _cupsConnect()) == NULL
)
354 * Build a CUPS_GET_CLASSES request, which requires the following
358 * attributes-natural-language
359 * requested-attributes
362 request
= ippNewRequest(CUPS_GET_CLASSES
);
364 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
365 "requested-attributes", NULL
, "printer-name");
368 * Do the request and get back a response...
373 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
375 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
376 if (attr
->name
!= NULL
&&
377 strcasecmp(attr
->name
, "printer-name") == 0 &&
378 attr
->value_tag
== IPP_TAG_NAME
)
381 temp
= malloc(sizeof(char *));
383 temp
= realloc(*classes
, sizeof(char *) * (n
+ 1));
403 temp
[n
] = strdup(attr
->values
[0].string
.text
);
415 * 'cupsGetDefault()' - Get the default printer or class for the default server.
417 * This function returns the default printer or class as defined by
418 * the LPDEST or PRINTER environment variables. If these environment
419 * variables are not set, the server default destination is returned.
420 * Applications should use the @link cupsGetDests@ and @link cupsGetDest@
421 * functions to get the user-defined default printer, as this function does
422 * not support the lpoptions-defined default printer.
425 const char * /* O - Default printer or @code NULL@ */
429 * Return the default printer...
432 return (cupsGetDefault2(CUPS_HTTP_DEFAULT
));
437 * 'cupsGetDefault2()' - Get the default printer or class for the specified server.
439 * This function returns the default printer or class as defined by
440 * the LPDEST or PRINTER environment variables. If these environment
441 * variables are not set, the server default destination is returned.
442 * Applications should use the @link cupsGetDests@ and @link cupsGetDest@
443 * functions to get the user-defined default printer, as this function does
444 * not support the lpoptions-defined default printer.
446 * @since CUPS 1.1.21/Mac OS X 10.4@
449 const char * /* O - Default printer or @code NULL@ */
450 cupsGetDefault2(http_t
*http
) /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
452 ipp_t
*request
, /* IPP Request */
453 *response
; /* IPP Response */
454 ipp_attribute_t
*attr
; /* Current attribute */
455 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
459 * See if we have a user default printer set...
462 if (_cupsUserDefault(cg
->def_printer
, sizeof(cg
->def_printer
)))
463 return (cg
->def_printer
);
466 * Connect to the server as needed...
470 if ((http
= _cupsConnect()) == NULL
)
474 * Build a CUPS_GET_DEFAULT request, which requires the following
478 * attributes-natural-language
481 request
= ippNewRequest(CUPS_GET_DEFAULT
);
484 * Do the request and get back a response...
487 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
489 if ((attr
= ippFindAttribute(response
, "printer-name",
490 IPP_TAG_NAME
)) != NULL
)
492 strlcpy(cg
->def_printer
, attr
->values
[0].string
.text
,
493 sizeof(cg
->def_printer
));
495 return (cg
->def_printer
);
506 * 'cupsGetJobs()' - Get the jobs from the default server.
508 * A "whichjobs" value of @code CUPS_WHICHJOBS_ALL@ returns all jobs regardless
509 * of state, while @code CUPS_WHICHJOBS_ACTIVE@ returns jobs that are
510 * pending, processing, or held and @code CUPS_WHICHJOBS_COMPLETED@ returns
511 * jobs that are stopped, canceled, aborted, or completed.
514 int /* O - Number of jobs */
515 cupsGetJobs(cups_job_t
**jobs
, /* O - Job data */
516 const char *name
, /* I - @code NULL@ = all destinations, otherwise show jobs for named destination */
517 int myjobs
, /* I - 0 = all users, 1 = mine */
518 int whichjobs
) /* I - @code CUPS_WHICHJOBS_ALL@, @code CUPS_WHICHJOBS_ACTIVE@, or @code CUPS_WHICHJOBS_COMPLETED@ */
524 return (cupsGetJobs2(CUPS_HTTP_DEFAULT
, jobs
, name
, myjobs
, whichjobs
));
530 * 'cupsGetJobs2()' - Get the jobs from the specified server.
532 * A "whichjobs" value of @code CUPS_WHICHJOBS_ALL@ returns all jobs regardless
533 * of state, while @code CUPS_WHICHJOBS_ACTIVE@ returns jobs that are
534 * pending, processing, or held and @code CUPS_WHICHJOBS_COMPLETED@ returns
535 * jobs that are stopped, canceled, aborted, or completed.
537 * @since CUPS 1.1.21/Mac OS X 10.4@
540 int /* O - Number of jobs */
541 cupsGetJobs2(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
542 cups_job_t
**jobs
, /* O - Job data */
543 const char *name
, /* I - @code NULL@ = all destinations, otherwise show jobs for named destination */
544 int myjobs
, /* I - 0 = all users, 1 = mine */
545 int whichjobs
) /* I - @code CUPS_WHICHJOBS_ALL@, @code CUPS_WHICHJOBS_ACTIVE@, or @code CUPS_WHICHJOBS_COMPLETED@ */
547 int n
; /* Number of jobs */
548 ipp_t
*request
, /* IPP Request */
549 *response
; /* IPP Response */
550 ipp_attribute_t
*attr
; /* Current attribute */
551 cups_job_t
*temp
; /* Temporary pointer */
553 priority
, /* job-priority */
554 size
; /* job-k-octets */
555 ipp_jstate_t state
; /* job-state */
556 time_t completed_time
, /* time-at-completed */
557 creation_time
, /* time-at-creation */
558 processing_time
; /* time-at-processing */
559 const char *dest
, /* job-printer-uri */
560 *format
, /* document-format */
561 *title
, /* job-name */
562 *user
; /* job-originating-user-name */
563 char uri
[HTTP_MAX_URI
]; /* URI for jobs */
564 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
565 static const char * const attrs
[] = /* Requested attributes */
571 "job-originating-user-name",
582 * Range check input...
587 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
593 * Get the right URI...
598 if (httpAssembleURIf(HTTP_URI_CODING_ALL
, uri
, sizeof(uri
), "ipp", NULL
,
599 "localhost", 0, "/printers/%s", name
) != HTTP_URI_OK
)
601 _cupsSetError(IPP_INTERNAL_ERROR
, _("Unable to create printer-uri"), 1);
607 strcpy(uri
, "ipp://localhost/");
610 if ((http
= _cupsConnect()) == NULL
)
614 * Build an IPP_GET_JOBS request, which requires the following
618 * attributes-natural-language
620 * requesting-user-name
623 * requested-attributes
626 request
= ippNewRequest(IPP_GET_JOBS
);
628 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
629 "printer-uri", NULL
, uri
);
631 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
,
632 "requesting-user-name", NULL
, cupsUser());
635 ippAddBoolean(request
, IPP_TAG_OPERATION
, "my-jobs", 1);
637 if (whichjobs
== CUPS_WHICHJOBS_COMPLETED
)
638 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
639 "which-jobs", NULL
, "completed");
640 else if (whichjobs
== CUPS_WHICHJOBS_ALL
)
641 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
642 "which-jobs", NULL
, "all");
644 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
645 "requested-attributes", sizeof(attrs
) / sizeof(attrs
[0]),
649 * Do the request and get back a response...
655 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
657 for (attr
= response
->attrs
; attr
; attr
= attr
->next
)
660 * Skip leading attributes until we hit a job...
663 while (attr
&& attr
->group_tag
!= IPP_TAG_JOB
)
670 * Pull the needed attributes from this job...
676 state
= IPP_JOB_PENDING
;
679 format
= "application/octet-stream";
685 while (attr
&& attr
->group_tag
== IPP_TAG_JOB
)
687 if (!strcmp(attr
->name
, "job-id") &&
688 attr
->value_tag
== IPP_TAG_INTEGER
)
689 id
= attr
->values
[0].integer
;
690 else if (!strcmp(attr
->name
, "job-state") &&
691 attr
->value_tag
== IPP_TAG_ENUM
)
692 state
= (ipp_jstate_t
)attr
->values
[0].integer
;
693 else if (!strcmp(attr
->name
, "job-priority") &&
694 attr
->value_tag
== IPP_TAG_INTEGER
)
695 priority
= attr
->values
[0].integer
;
696 else if (!strcmp(attr
->name
, "job-k-octets") &&
697 attr
->value_tag
== IPP_TAG_INTEGER
)
698 size
= attr
->values
[0].integer
;
699 else if (!strcmp(attr
->name
, "time-at-completed") &&
700 attr
->value_tag
== IPP_TAG_INTEGER
)
701 completed_time
= attr
->values
[0].integer
;
702 else if (!strcmp(attr
->name
, "time-at-creation") &&
703 attr
->value_tag
== IPP_TAG_INTEGER
)
704 creation_time
= attr
->values
[0].integer
;
705 else if (!strcmp(attr
->name
, "time-at-processing") &&
706 attr
->value_tag
== IPP_TAG_INTEGER
)
707 processing_time
= attr
->values
[0].integer
;
708 else if (!strcmp(attr
->name
, "job-printer-uri") &&
709 attr
->value_tag
== IPP_TAG_URI
)
711 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
714 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
715 attr
->value_tag
== IPP_TAG_NAME
)
716 user
= attr
->values
[0].string
.text
;
717 else if (!strcmp(attr
->name
, "document-format") &&
718 attr
->value_tag
== IPP_TAG_MIMETYPE
)
719 format
= attr
->values
[0].string
.text
;
720 else if (!strcmp(attr
->name
, "job-name") &&
721 (attr
->value_tag
== IPP_TAG_TEXT
||
722 attr
->value_tag
== IPP_TAG_NAME
))
723 title
= attr
->values
[0].string
.text
;
729 * See if we have everything needed...
741 * Allocate memory for the job...
745 temp
= malloc(sizeof(cups_job_t
));
747 temp
= realloc(*jobs
, sizeof(cups_job_t
) * (n
+ 1));
755 _cupsSetError(IPP_INTERNAL_ERROR
, NULL
, 0);
757 cupsFreeJobs(n
, *jobs
);
770 * Copy the data over...
773 temp
->dest
= _cupsStrAlloc(dest
);
774 temp
->user
= _cupsStrAlloc(user
);
775 temp
->format
= _cupsStrAlloc(format
);
776 temp
->title
= _cupsStrAlloc(title
);
778 temp
->priority
= priority
;
781 temp
->completed_time
= completed_time
;
782 temp
->creation_time
= creation_time
;
783 temp
->processing_time
= processing_time
;
792 if (n
== 0 && cg
->last_error
>= IPP_BAD_REQUEST
)
800 * 'cupsGetPPD()' - Get the PPD file for a printer on the default server.
802 * For classes, @code cupsGetPPD@ returns the PPD file for the first printer
805 * The returned filename is stored in a static buffer and is overwritten with
806 * each call to @code cupsGetPPD@ or @link cupsGetPPD2@. The caller "owns" the
807 * file that is created and must @code unlink@ the returned filename.
810 const char * /* O - Filename for PPD file */
811 cupsGetPPD(const char *name
) /* I - Destination name */
813 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
814 time_t modtime
= 0; /* Modification time */
818 * Return the PPD file...
821 cg
->ppd_filename
[0] = '\0';
823 if (cupsGetPPD3(CUPS_HTTP_DEFAULT
, name
, &modtime
, cg
->ppd_filename
,
824 sizeof(cg
->ppd_filename
)) == HTTP_OK
)
825 return (cg
->ppd_filename
);
832 * 'cupsGetPPD2()' - Get the PPD file for a printer from the specified server.
834 * For classes, @code cupsGetPPD2@ returns the PPD file for the first printer
837 * The returned filename is stored in a static buffer and is overwritten with
838 * each call to @link cupsGetPPD@ or @code cupsGetPPD2@. The caller "owns" the
839 * file that is created and must @code unlink@ the returned filename.
841 * @since CUPS 1.1.21/Mac OS X 10.4@
844 const char * /* O - Filename for PPD file */
845 cupsGetPPD2(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
846 const char *name
) /* I - Destination name */
848 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
849 time_t modtime
= 0; /* Modification time */
852 cg
->ppd_filename
[0] = '\0';
854 if (cupsGetPPD3(http
, name
, &modtime
, cg
->ppd_filename
,
855 sizeof(cg
->ppd_filename
)) == HTTP_OK
)
856 return (cg
->ppd_filename
);
863 * 'cupsGetPPD3()' - Get the PPD file for a printer on the specified
864 * server if it has changed.
866 * The "modtime" parameter contains the modification time of any
867 * locally-cached content and is updated with the time from the PPD file on
870 * The "buffer" parameter contains the local PPD filename. If it contains
871 * the empty string, a new temporary file is created, otherwise the existing
872 * file will be overwritten as needed. The caller "owns" the file that is
873 * created and must @code unlink@ the returned filename.
875 * On success, @code HTTP_OK@ is returned for a new PPD file and
876 * @code HTTP_NOT_MODIFIED@ if the existing PPD file is up-to-date. Any other
877 * status is an error.
879 * For classes, @code cupsGetPPD3@ returns the PPD file for the first printer
882 * @since CUPS 1.4/Mac OS X 10.6@
885 http_status_t
/* O - HTTP status */
886 cupsGetPPD3(http_t
*http
, /* I - HTTP connection or @code CUPS_HTTP_DEFAULT@ */
887 const char *name
, /* I - Destination name */
888 time_t *modtime
, /* IO - Modification time */
889 char *buffer
, /* I - Filename buffer */
890 size_t bufsize
) /* I - Size of filename buffer */
892 int http_port
; /* Port number */
893 char http_hostname
[HTTP_MAX_HOST
];
894 /* Hostname associated with connection */
895 http_t
*http2
; /* Alternate HTTP connection */
896 int fd
; /* PPD file */
897 char localhost
[HTTP_MAX_URI
],/* Local hostname */
898 hostname
[HTTP_MAX_URI
], /* Hostname */
899 resource
[HTTP_MAX_URI
]; /* Resource name */
900 int port
; /* Port number */
901 http_status_t status
; /* HTTP status from server */
902 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
906 * Range check input...
909 DEBUG_printf(("cupsGetPPD3(http=%p, name=\"%s\", modtime=%p(%d), buffer=%p, "
910 "bufsize=%d)", http
, name
, modtime
,
911 modtime
? (int)*modtime
: 0, buffer
, (int)bufsize
));
915 _cupsSetError(IPP_INTERNAL_ERROR
, _("No printer name"), 1);
916 return (HTTP_NOT_ACCEPTABLE
);
921 _cupsSetError(IPP_INTERNAL_ERROR
, _("No modification time"), 1);
922 return (HTTP_NOT_ACCEPTABLE
);
925 if (!buffer
|| bufsize
<= 1)
927 _cupsSetError(IPP_INTERNAL_ERROR
, _("Bad filename buffer"), 1);
928 return (HTTP_NOT_ACCEPTABLE
);
933 * See if the PPD file is available locally...
936 if (!cg
->servername
[0])
939 if (!strcasecmp(cg
->servername
, "localhost"))
941 char ppdname
[1024]; /* PPD filename */
942 struct stat ppdinfo
; /* PPD file information */
945 snprintf(ppdname
, sizeof(ppdname
), "%s/ppd/%s.ppd", cg
->cups_serverroot
,
947 if (!stat(ppdname
, &ppdinfo
))
950 * OK, the file exists, use it!
957 if (symlink(ppdname
, buffer
) && errno
!= EEXIST
)
959 _cupsSetError(IPP_INTERNAL_ERROR
, NULL
, 0);
961 return (HTTP_SERVER_ERROR
);
966 int tries
; /* Number of tries */
967 const char *tmpdir
; /* TMPDIR environment variable */
968 struct timeval curtime
; /* Current time */
971 * Previously we put root temporary files in the default CUPS temporary
972 * directory under /var/spool/cups. However, since the scheduler cleans
973 * out temporary files there and runs independently of the user apps, we
974 * don't want to use it unless specifically told to by cupsd.
977 if ((tmpdir
= getenv("TMPDIR")) == NULL
)
979 tmpdir
= "/private/tmp"; /* /tmp is a symlink to /private/tmp */
982 # endif /* __APPLE__ */
985 * Make the temporary name using the specified directory...
993 * Get the current time of day...
996 gettimeofday(&curtime
, NULL
);
999 * Format a string using the hex time values...
1002 snprintf(buffer
, bufsize
, "%s/%08lx%05lx", tmpdir
,
1003 (unsigned long)curtime
.tv_sec
,
1004 (unsigned long)curtime
.tv_usec
);
1007 * Try to make a symlink...
1010 if (!symlink(ppdname
, buffer
))
1015 while (tries
< 1000);
1019 _cupsSetError(IPP_INTERNAL_ERROR
, NULL
, 0);
1021 return (HTTP_SERVER_ERROR
);
1025 if (*modtime
>= ppdinfo
.st_mtime
)
1026 return (HTTP_NOT_MODIFIED
);
1029 *modtime
= ppdinfo
.st_mtime
;
1037 * Try finding a printer URI for this printer...
1041 if ((http
= _cupsConnect()) == NULL
)
1042 return (HTTP_SERVICE_UNAVAILABLE
);
1044 if (!cups_get_printer_uri(http
, name
, hostname
, sizeof(hostname
), &port
,
1045 resource
, sizeof(resource
), 0))
1046 return (HTTP_NOT_FOUND
);
1048 DEBUG_printf(("2cupsGetPPD3: Printer hostname=\"%s\", port=%d", hostname
,
1052 * Remap local hostname to localhost...
1055 httpGetHostname(NULL
, localhost
, sizeof(localhost
));
1057 DEBUG_printf(("2cupsGetPPD3: Local hostname=\"%s\"", localhost
));
1059 if (!strcasecmp(localhost
, hostname
))
1060 strcpy(hostname
, "localhost");
1063 * Get the hostname and port number we are connected to...
1066 httpGetHostname(http
, http_hostname
, sizeof(http_hostname
));
1067 http_port
= _httpAddrPort(http
->hostaddr
);
1069 DEBUG_printf(("2cupsGetPPD3: Connection hostname=\"%s\", port=%d",
1070 http_hostname
, http_port
));
1073 * Reconnect to the correct server as needed...
1076 if (!strcasecmp(http_hostname
, hostname
) && port
== http_port
)
1078 else if ((http2
= httpConnectEncrypt(hostname
, port
,
1079 cupsEncryption())) == NULL
)
1081 DEBUG_puts("1cupsGetPPD3: Unable to connect to server");
1083 return (HTTP_SERVICE_UNAVAILABLE
);
1087 * Get a temp file...
1091 fd
= open(buffer
, O_CREAT
| O_TRUNC
| O_WRONLY
, 0600);
1093 fd
= cupsTempFd(buffer
, bufsize
);
1098 * Can't open file; close the server connection and return NULL...
1101 _cupsSetError(IPP_INTERNAL_ERROR
, NULL
, 0);
1106 return (HTTP_SERVER_ERROR
);
1110 * And send a request to the HTTP server...
1113 strlcat(resource
, ".ppd", sizeof(resource
));
1116 httpSetField(http2
, HTTP_FIELD_IF_MODIFIED_SINCE
,
1117 httpGetDateString(*modtime
));
1119 status
= cupsGetFd(http2
, resource
, fd
);
1124 * See if we actually got the file or an error...
1127 if (status
== HTTP_OK
)
1128 *modtime
= httpGetDateTime(httpGetField(http2
, HTTP_FIELD_DATE
));
1129 else if (status
!= HTTP_NOT_MODIFIED
)
1131 _cupsSetHTTPError(status
);
1133 unlink(cg
->ppd_filename
);
1140 * Return the PPD file...
1143 DEBUG_printf(("1cupsGetPPD3: Returning status %d", status
));
1150 * 'cupsGetPrinters()' - Get a list of printers from the default server.
1152 * This function is deprecated - use @link cupsGetDests@ instead.
1157 int /* O - Number of printers */
1158 cupsGetPrinters(char ***printers
) /* O - Printers */
1160 int n
; /* Number of printers */
1161 ipp_t
*request
, /* IPP Request */
1162 *response
; /* IPP Response */
1163 ipp_attribute_t
*attr
; /* Current attribute */
1164 char **temp
; /* Temporary pointer */
1165 http_t
*http
; /* Connection to server */
1169 * Range check input...
1174 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
1182 * Try to connect to the server...
1185 if ((http
= _cupsConnect()) == NULL
)
1189 * Build a CUPS_GET_PRINTERS request, which requires the following
1192 * attributes-charset
1193 * attributes-natural-language
1194 * requested-attributes
1197 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1199 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1200 "requested-attributes", NULL
, "printer-name");
1202 ippAddInteger(request
, IPP_TAG_OPERATION
, IPP_TAG_ENUM
,
1205 ippAddInteger(request
, IPP_TAG_OPERATION
, IPP_TAG_ENUM
,
1206 "printer-type-mask", CUPS_PRINTER_CLASS
);
1209 * Do the request and get back a response...
1214 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1216 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1217 if (attr
->name
!= NULL
&&
1218 strcasecmp(attr
->name
, "printer-name") == 0 &&
1219 attr
->value_tag
== IPP_TAG_NAME
)
1222 temp
= malloc(sizeof(char *));
1224 temp
= realloc(*printers
, sizeof(char *) * (n
+ 1));
1229 * Ran out of memory!
1235 free((*printers
)[n
]);
1239 ippDelete(response
);
1244 temp
[n
] = strdup(attr
->values
[0].string
.text
);
1248 ippDelete(response
);
1256 * 'cupsGetServerPPD()' - Get an available PPD file from the server.
1258 * This function returns the named PPD file from the server. The
1259 * list of available PPDs is provided by the IPP @code CUPS_GET_PPDS@
1262 * You must remove (unlink) the PPD file when you are finished with
1263 * it. The PPD filename is stored in a static location that will be
1264 * overwritten on the next call to @link cupsGetPPD@, @link cupsGetPPD2@,
1265 * or @link cupsGetServerPPD@.
1267 * @since CUPS 1.3/Mac OS X 10.5@
1270 char * /* O - Name of PPD file or @code NULL@ on error */
1271 cupsGetServerPPD(http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
1272 const char *name
) /* I - Name of PPD file ("ppd-name") */
1274 int fd
; /* PPD file descriptor */
1275 ipp_t
*request
; /* IPP request */
1276 _cups_globals_t
*cg
= _cupsGlobals();
1277 /* Pointer to library globals */
1281 * Range check input...
1286 _cupsSetError(IPP_INTERNAL_ERROR
, _("No PPD name"), 1);
1292 if ((http
= _cupsConnect()) == NULL
)
1296 * Get a temp file...
1299 if ((fd
= cupsTempFd(cg
->ppd_filename
, sizeof(cg
->ppd_filename
))) < 0)
1302 * Can't open file; close the server connection and return NULL...
1305 _cupsSetError(IPP_INTERNAL_ERROR
, NULL
, 0);
1311 * Get the PPD file...
1314 request
= ippNewRequest(CUPS_GET_PPD
);
1315 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "ppd-name", NULL
,
1318 ippDelete(cupsDoIORequest(http
, request
, "/", -1, fd
));
1322 if (cupsLastError() != IPP_OK
)
1324 unlink(cg
->ppd_filename
);
1328 return (cg
->ppd_filename
);
1333 * 'cupsPrintFile()' - Print a file to a printer or class on the default server.
1336 int /* O - Job ID or 0 on error */
1337 cupsPrintFile(const char *name
, /* I - Destination name */
1338 const char *filename
, /* I - File to print */
1339 const char *title
, /* I - Title of job */
1340 int num_options
,/* I - Number of options */
1341 cups_option_t
*options
) /* I - Options */
1343 DEBUG_printf(("cupsPrintFile(name=\"%s\", filename=\"%s\", "
1344 "title=\"%s\", num_options=%d, options=%p)",
1345 name
, filename
, title
, num_options
, options
));
1347 return (cupsPrintFiles2(CUPS_HTTP_DEFAULT
, name
, 1, &filename
, title
,
1348 num_options
, options
));
1353 * 'cupsPrintFile2()' - Print a file to a printer or class on the specified
1356 * @since CUPS 1.1.21/Mac OS X 10.4@
1359 int /* O - Job ID or 0 on error */
1361 http_t
*http
, /* I - Connection to server */
1362 const char *name
, /* I - Destination name */
1363 const char *filename
, /* I - File to print */
1364 const char *title
, /* I - Title of job */
1365 int num_options
, /* I - Number of options */
1366 cups_option_t
*options
) /* I - Options */
1368 DEBUG_printf(("cupsPrintFile2(http=%p, name=\"%s\", filename=\"%s\", "
1369 "title=\"%s\", num_options=%d, options=%p)",
1370 http
, name
, filename
, title
, num_options
, options
));
1372 return (cupsPrintFiles2(http
, name
, 1, &filename
, title
, num_options
,
1378 * 'cupsPrintFiles()' - Print one or more files to a printer or class on the
1382 int /* O - Job ID or 0 on error */
1384 const char *name
, /* I - Destination name */
1385 int num_files
, /* I - Number of files */
1386 const char **files
, /* I - File(s) to print */
1387 const char *title
, /* I - Title of job */
1388 int num_options
, /* I - Number of options */
1389 cups_option_t
*options
) /* I - Options */
1391 DEBUG_printf(("cupsPrintFiles(name=\"%s\", num_files=%d, "
1392 "files=%p, title=\"%s\", num_options=%d, options=%p)",
1393 name
, num_files
, files
, title
, num_options
, options
));
1396 * Print the file(s)...
1399 return (cupsPrintFiles2(CUPS_HTTP_DEFAULT
, name
, num_files
, files
, title
,
1400 num_options
, options
));
1405 * 'cupsPrintFiles2()' - Print one or more files to a printer or class on the
1408 * @since CUPS 1.1.21/Mac OS X 10.4@
1411 int /* O - Job ID or 0 on error */
1413 http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
1414 const char *name
, /* I - Destination name */
1415 int num_files
, /* I - Number of files */
1416 const char **files
, /* I - File(s) to print */
1417 const char *title
, /* I - Title of job */
1418 int num_options
, /* I - Number of options */
1419 cups_option_t
*options
) /* I - Options */
1421 int i
; /* Looping var */
1422 int job_id
; /* New job ID */
1423 const char *docname
; /* Basename of current filename */
1424 const char *format
; /* Document format */
1425 cups_file_t
*fp
; /* Current file */
1426 char buffer
[8192]; /* Copy buffer */
1427 ssize_t bytes
; /* Bytes in buffer */
1428 http_status_t status
; /* Status of write */
1429 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1430 ipp_status_t cancel_status
; /* Status code to preserve */
1431 char *cancel_message
; /* Error message to preserve */
1434 DEBUG_printf(("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, "
1435 "files=%p, title=\"%s\", num_options=%d, options=%p)",
1436 http
, name
, num_files
, files
, title
, num_options
, options
));
1439 * Range check input...
1442 if (!name
|| num_files
< 1 || !files
)
1444 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(EINVAL
), 0);
1450 * Create the print job...
1453 if ((job_id
= cupsCreateJob(http
, name
, title
, num_options
, options
)) == 0)
1457 * Send each of the files...
1460 if (cupsGetOption("raw", num_options
, options
))
1461 format
= CUPS_FORMAT_RAW
;
1462 else if ((format
= cupsGetOption("document-format", num_options
,
1464 format
= CUPS_FORMAT_AUTO
;
1466 for (i
= 0; i
< num_files
; i
++)
1469 * Start the next file...
1472 if ((docname
= strrchr(files
[i
], '/')) != NULL
)
1477 if ((fp
= cupsFileOpen(files
[i
], "rb")) == NULL
)
1480 * Unable to open print file, cancel the job and return...
1483 _cupsSetError(IPP_DOCUMENT_ACCESS_ERROR
, NULL
, 0);
1487 status
= cupsStartDocument(http
, name
, job_id
, docname
, format
,
1488 i
== (num_files
- 1));
1490 while (status
== HTTP_CONTINUE
&&
1491 (bytes
= cupsFileRead(fp
, buffer
, sizeof(buffer
))) > 0)
1492 status
= cupsWriteRequestData(http
, buffer
, bytes
);
1496 if (status
!= HTTP_CONTINUE
|| cupsFinishDocument(http
, name
) != IPP_OK
)
1499 * Unable to queue, cancel the job and return...
1509 * If we get here, something happened while sending the print job so we need
1510 * to cancel the job without setting the last error (since we need to preserve
1511 * the current error...
1516 cancel_status
= cg
->last_error
;
1517 cancel_message
= cg
->last_status_message
?
1518 _cupsStrRetain(cg
->last_status_message
) : NULL
;
1520 cupsCancelJob2(http
, name
, job_id
, 0);
1522 cg
->last_error
= cancel_status
;
1523 cg
->last_status_message
= cancel_message
;
1530 * 'cupsStartDocument()' - Add a document to a job created with cupsCreateJob().
1532 * Use @link cupsWriteRequestData@ to write data for the document and
1533 * @link cupsFinishDocument@ to finish the document and get the submission status.
1535 * The MIME type constants @code CUPS_FORMAT_AUTO@, @code CUPS_FORMAT_PDF@,
1536 * @code CUPS_FORMAT_POSTSCRIPT@, @code CUPS_FORMAT_RAW@, and
1537 * @code CUPS_FORMAT_TEXT@ are provided for the "format" argument, although
1538 * any supported MIME type string can be supplied.
1540 * @since CUPS 1.4/Mac OS X 10.6@
1543 http_status_t
/* O - HTTP status of request */
1545 http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
1546 const char *name
, /* I - Destination name */
1547 int job_id
, /* I - Job ID from @link cupsCreateJob@ */
1548 const char *docname
, /* I - Name of document */
1549 const char *format
, /* I - MIME type or @code CUPS_FORMAT_foo@ */
1550 int last_document
) /* I - 1 for last document in job, 0 otherwise */
1552 char resource
[1024], /* Resource for destinatio */
1553 printer_uri
[1024]; /* Printer URI */
1554 ipp_t
*request
; /* Send-Document request */
1555 http_status_t status
; /* HTTP status */
1559 * Create a Send-Document request...
1562 if ((request
= ippNewRequest(IPP_SEND_DOCUMENT
)) == NULL
)
1564 _cupsSetError(IPP_INTERNAL_ERROR
, strerror(ENOMEM
), 0);
1568 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
), "ipp",
1569 NULL
, "localhost", ippPort(), "/printers/%s", name
);
1570 snprintf(resource
, sizeof(resource
), "/printers/%s", name
);
1572 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1574 ippAddInteger(request
, IPP_TAG_OPERATION
, IPP_TAG_INTEGER
, "job-id", job_id
);
1575 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1578 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "document-name",
1581 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_MIMETYPE
,
1582 "document-format", NULL
, format
);
1583 ippAddBoolean(request
, IPP_TAG_OPERATION
, "last-document", last_document
);
1586 * Send and delete the request, then return the status...
1589 status
= cupsSendRequest(http
, request
, resource
, CUPS_LENGTH_VARIABLE
);
1598 * 'cups_get_printer_uri()' - Get the printer-uri-supported attribute for the
1599 * first printer in a class.
1602 static int /* O - 1 on success, 0 on failure */
1603 cups_get_printer_uri(
1604 http_t
*http
, /* I - Connection to server */
1605 const char *name
, /* I - Name of printer or class */
1606 char *host
, /* I - Hostname buffer */
1607 int hostsize
, /* I - Size of hostname buffer */
1608 int *port
, /* O - Port number */
1609 char *resource
, /* I - Resource buffer */
1610 int resourcesize
, /* I - Size of resource buffer */
1611 int depth
) /* I - Depth of query */
1613 int i
; /* Looping var */
1614 int http_port
; /* Port number */
1615 http_t
*http2
; /* Alternate HTTP connection */
1616 ipp_t
*request
, /* IPP request */
1617 *response
; /* IPP response */
1618 ipp_attribute_t
*attr
; /* Current attribute */
1619 char uri
[HTTP_MAX_URI
], /* printer-uri attribute */
1620 scheme
[HTTP_MAX_URI
], /* Scheme name */
1621 username
[HTTP_MAX_URI
], /* Username:password */
1622 classname
[255], /* Temporary class name */
1623 http_hostname
[HTTP_MAX_HOST
];
1624 /* Hostname associated with connection */
1625 static const char * const requested_attrs
[] =
1626 { /* Requested attributes */
1628 "printer-uri-supported",
1633 DEBUG_printf(("7cups_get_printer_uri(http=%p, name=\"%s\", host=%p, "
1634 "hostsize=%d, resource=%p, resourcesize=%d, depth=%d)",
1635 http
, name
, host
, hostsize
, resource
, resourcesize
, depth
));
1638 * Setup the printer URI...
1641 if (httpAssembleURIf(HTTP_URI_CODING_ALL
, uri
, sizeof(uri
), "ipp", NULL
,
1642 "localhost", 0, "/printers/%s", name
) != HTTP_URI_OK
)
1644 _cupsSetError(IPP_INTERNAL_ERROR
, _("Unable to create printer-uri"), 1);
1652 DEBUG_printf(("9cups_get_printer_uri: printer-uri=\"%s\"", uri
));
1655 * Get the hostname and port number we are connected to...
1658 httpGetHostname(http
, http_hostname
, sizeof(http_hostname
));
1659 http_port
= _httpAddrPort(http
->hostaddr
);
1662 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
1665 * attributes-charset
1666 * attributes-natural-language
1668 * requested-attributes
1671 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
1673 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1676 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
,
1677 "requested-attributes",
1678 sizeof(requested_attrs
) / sizeof(requested_attrs
[0]),
1679 NULL
, requested_attrs
);
1682 * Do the request and get back a response...
1685 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1687 if ((attr
= ippFindAttribute(response
, "member-uris", IPP_TAG_URI
)) != NULL
)
1690 * Get the first actual printer name in the class...
1693 for (i
= 0; i
< attr
->num_values
; i
++)
1695 httpSeparateURI(HTTP_URI_CODING_ALL
, attr
->values
[i
].string
.text
,
1696 scheme
, sizeof(scheme
), username
, sizeof(username
),
1697 host
, hostsize
, port
, resource
, resourcesize
);
1698 if (!strncmp(resource
, "/printers/", 10))
1704 ippDelete(response
);
1711 * No printers in this class - try recursively looking for a printer,
1712 * but not more than 3 levels deep...
1717 for (i
= 0; i
< attr
->num_values
; i
++)
1719 httpSeparateURI(HTTP_URI_CODING_ALL
, attr
->values
[i
].string
.text
,
1720 scheme
, sizeof(scheme
), username
, sizeof(username
),
1721 host
, hostsize
, port
, resource
, resourcesize
);
1722 if (!strncmp(resource
, "/classes/", 9))
1725 * Found a class! Connect to the right server...
1728 if (!strcasecmp(http_hostname
, host
) && *port
== http_port
)
1730 else if ((http2
= httpConnectEncrypt(host
, *port
,
1731 cupsEncryption())) == NULL
)
1733 DEBUG_puts("8cups_get_printer_uri: Unable to connect to server");
1739 * Look up printers on that server...
1742 strlcpy(classname
, resource
+ 9, sizeof(classname
));
1744 cups_get_printer_uri(http2
, classname
, host
, hostsize
, port
,
1745 resource
, resourcesize
, depth
+ 1);
1748 * Close the connection as needed...
1760 else if ((attr
= ippFindAttribute(response
, "printer-uri-supported",
1761 IPP_TAG_URI
)) != NULL
)
1763 httpSeparateURI(HTTP_URI_CODING_ALL
,
1764 _httpResolveURI(attr
->values
[0].string
.text
, uri
,
1765 sizeof(uri
), 0, NULL
, NULL
),
1766 scheme
, sizeof(scheme
), username
, sizeof(username
),
1767 host
, hostsize
, port
, resource
, resourcesize
);
1768 ippDelete(response
);
1770 if (!strncmp(resource
, "/classes/", 9))
1772 _cupsSetError(IPP_INTERNAL_ERROR
,
1773 _("No printer-uri found for class"), 1);
1784 ippDelete(response
);
1787 if (cupsLastError() != IPP_NOT_FOUND
)
1788 _cupsSetError(IPP_INTERNAL_ERROR
, _("No printer-uri found"), 1);
1798 * End of "$Id: util.c 7850 2008-08-20 00:07:25Z mike $".