/*
- * "$Id: ipp.c 5552 2006-05-20 12:00:37Z mike $"
+ * "$Id: ipp.c 5554 2006-05-20 12:23:40Z mike $"
*
* IPP routines for the Common UNIX Printing System (CUPS) scheduler.
*
static void add_class(cupsd_client_t *con, ipp_attribute_t *uri);
static int add_file(cupsd_client_t *con, cupsd_job_t *job,
mime_type_t *filetype, int compression);
-static cupsd_job_t *add_job(cupsd_client_t *con, cupsd_printer_t *printer,
+static cupsd_job_t *add_job(cupsd_client_t *con, ipp_attribute_t *uri,
+ cupsd_printer_t **dprinter,
mime_type_t *filetype);
static void add_job_state_reasons(cupsd_client_t *con, cupsd_job_t *job);
static void add_job_subscriptions(cupsd_client_t *con, cupsd_job_t *job);
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
+ username[HTTP_MAX_URI], /* Username portion of URI */
+ host[HTTP_MAX_URI], /* Host portion of URI */
+ resource[HTTP_MAX_URI]; /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
cupsdAddPrinterHistory(printer);
if (dtype & CUPS_PRINTER_CLASS)
- {
cupsdSaveAllClasses();
-
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" now accepting jobs (\"%s\").",
- printer->name, get_username(con));
- }
else
- {
cupsdSaveAllPrinters();
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" now accepting jobs (\"%s\").",
- printer->name, get_username(con));
- }
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" now accepting jobs (\"%s\").", name,
+ get_username(con));
/*
* Everything was ok, so return OK status...
cupsd_printer_t *pclass, /* Class */
*member; /* Member printer/class */
cups_ptype_t dtype; /* Destination type */
+ const char *dest; /* Printer or class name */
ipp_attribute_t *attr; /* Printer attribute */
int modify; /* Non-zero if we just modified */
char newname[IPP_MAX_NAME]; /* New class name */
* Search for the printer or class URI...
*/
- if (!cupsdValidateDest(attr->values[i].string.text, &dtype, &member))
+ httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &member)) == NULL)
{
/*
* Bad URI...
static cupsd_job_t * /* O - Job object */
add_job(cupsd_client_t *con, /* I - Client connection */
- cupsd_printer_t *printer, /* I - Destination printer */
+ ipp_attribute_t *uri, /* I - printer-uri */
+ cupsd_printer_t **dprinter, /* I - Destination printer */
mime_type_t *filetype) /* I - First print file type, if any */
{
http_status_t status; /* Policy status */
ipp_attribute_t *attr; /* Current attribute */
+ const char *dest; /* Destination */
+ cups_ptype_t dtype; /* Destination type (printer or class) */
const char *val; /* Default option value */
int priority; /* Job priority */
char *title; /* Job name/title */
cupsd_job_t *job; /* Current job */
- char job_uri[HTTP_MAX_URI]; /* Job URI */
+ char job_uri[HTTP_MAX_URI], /* Job URI */
+ method[HTTP_MAX_URI], /* Method portion of URI */
+ username[HTTP_MAX_URI], /* Username portion of URI */
+ host[HTTP_MAX_URI], /* Host portion of URI */
+ resource[HTTP_MAX_URI]; /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ cupsd_printer_t *printer; /* Printer data */
int kbytes; /* Size of print file */
int i; /* Looping var */
int lowerpagerange; /* Page range bound */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
- con, con->http.fd, printer, printer->name,
- filetype, filetype->super, filetype->type);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
+
+ /*
+ * Is the destination valid?
+ */
+
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ {
+ /*
+ * Bad URI...
+ */
+
+ send_ipp_status(con, IPP_NOT_FOUND,
+ _("The printer or class was not found."));
+ return (NULL);
+ }
+
+ if (dprinter)
+ *dprinter = printer;
/*
* Check remote printing to non-shared printer...
{
send_ipp_status(con, IPP_NOT_ACCEPTING,
_("Destination \"%s\" is not accepting jobs."),
- printer->name);
+ dest);
return (NULL);
}
if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs)
cupsdCleanJobs();
- if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs)
+ if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs)
{
send_ipp_status(con, IPP_NOT_POSSIBLE,
_("Too many active jobs."));
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
{
send_ipp_status(con, IPP_INTERNAL_ERROR,
- _("Unable to add job for destination \"%s\"!"),
- printer->name);
+ _("Unable to add job for destination \"%s\"!"), dest);
return (NULL);
}
- job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
- CUPS_PRINTER_REMOTE);
+ job->dtype = dtype;
job->attrs = con->request;
con->request = NULL;
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
http_status_t status; /* Policy status */
+ const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type */
- char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
userpass[HTTP_MAX_URI], /* Username portion of URI */
- hostname[HTTP_MAX_URI], /* Host portion of URI */
+ host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
ipp_attribute_t *attr; /* Attribute in request */
* And if the destination is valid...
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), userpass, sizeof(userpass), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text,
- scheme, sizeof(scheme), userpass, sizeof(userpass),
- hostname, sizeof(hostname), &port,
- resource, sizeof(resource));
-
if ((!strncmp(resource, "/printers/", 10) && resource[10]) ||
(!strncmp(resource, "/classes/", 9) && resource[9]))
{
_("The printer or class was not found."));
return;
}
+ else if (strcmp(resource, "/printers/"))
+ {
+ send_ipp_status(con, IPP_NOT_FOUND,
+ _("The printer-uri \"%s\" is not valid."),
+ uri->values[0].string.text);
+ return;
+ }
/*
* Check policy...
* Check policy...
*/
- if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
- NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
* Cancel all of the jobs on the named printer...
*/
- cupsdCancelJobs(printer->name, username, purge);
+ cupsdCancelJobs(dest, username, purge);
cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".",
- printer->name, purge ? "purged" : "cancelled",
- get_username(con));
+ dest, purge ? "purged" : "cancelled", get_username(con));
}
con->response->request.status.status_code = IPP_OK;
{
ipp_attribute_t *attr; /* Current attribute */
int jobid; /* Job ID */
- char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
cupsd_job_t *job; /* Job information */
+ const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
cupsd_printer_t *printer; /* Printer data */
* Find the current job on the specified printer...
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
if (job->state_value <= IPP_JOB_PROCESSING &&
- !strcasecmp(job->dest, printer->name))
+ !strcasecmp(job->dest, dest))
break;
if (job)
else
{
send_ipp_status(con, IPP_NOT_POSSIBLE, _("No active jobs on %s!"),
- printer->name);
+ dest);
return;
}
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
- sizeof(scheme), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
create_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
- cupsd_printer_t *printer; /* Printer */
- cupsd_job_t *job; /* New job */
+ cupsd_job_t *job; /* New job */
cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", con,
con->http.fd, uri->values[0].string.text);
- /*
- * Is the destination valid?
- */
-
- if (!cupsdValidateDest(uri->values[0].string.text, NULL, &printer))
- {
- /*
- * Bad URI...
- */
-
- send_ipp_status(con, IPP_NOT_FOUND,
- _("The printer or class was not found."));
- return;
- }
-
/*
* Create the job object...
*/
- if ((job = add_job(con, printer, NULL)) == NULL)
+ if ((job = add_job(con, uri, NULL, NULL)) == NULL)
return;
/*
dtype = CUPS_PRINTER_CLASS;
printer = NULL;
}
- else if ((dest = cupsdValidateDest(uri->values[0].string.text, &dtype,
- &printer)) == NULL)
+ else if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
if (printer)
{
- if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
- NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
ipp_attribute_t *uri) /* I - URI of printer or class */
{
http_status_t status; /* Policy status */
+ const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
+ username[HTTP_MAX_URI], /* Username portion of URI */
+ host[HTTP_MAX_URI], /* Host portion of URI */
+ resource[HTTP_MAX_URI]; /* Resource portion of URI */
+ int port; /* Port portion of URI */
cupsd_printer_t *printer; /* Printer/class */
char filename[1024]; /* Script/PPD filename */
* Do we have a valid URI?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
* Remove old jobs...
*/
- cupsdCancelJobs(printer->name, NULL, 1);
+ cupsdCancelJobs(dest, NULL, 1);
/*
* Remove old subscriptions and send a "deleted printer" event...
cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, printer, NULL,
"%s \"%s\" deleted by \"%s\".",
(dtype & CUPS_PRINTER_CLASS) ? "Class" : "Printer",
- printer->name, get_username(con));
+ dest, get_username(con));
cupsdExpireSubscriptions(printer, NULL);
* Remove any old PPD or script files...
*/
- snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot,
- printer->name);
+ snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot, dest);
unlink(filename);
- snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot,
- printer->name);
+ snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, dest);
unlink(filename);
if (dtype & CUPS_PRINTER_CLASS)
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" deleted by \"%s\".",
- printer->name, get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" deleted by \"%s\".", dest,
+ get_username(con));
cupsdDeletePrinter(printer, 0);
cupsdSaveAllClasses();
}
else
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" deleted by \"%s\".",
- printer->name, get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" deleted by \"%s\".", dest,
+ get_username(con));
cupsdDeletePrinter(printer, 0);
cupsdSaveAllPrinters();
const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
cups_ptype_t dmask; /* Destination type mask */
- char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
- sizeof(scheme), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/") ||
dmask = CUPS_PRINTER_CLASS;
printer = NULL;
}
- else if ((dest = cupsdValidateDest(uri->values[0].string.text, &dtype,
- &printer)) == NULL)
+ else if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
if (printer)
{
- if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
- NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
ipp_attribute_t *uri) /* I - Printer URI */
{
http_status_t status; /* Policy status */
+ const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
+ username[HTTP_MAX_URI],
+ /* Username portion of URI */
+ host[HTTP_MAX_URI],
+ /* Host portion of URI */
+ resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int port; /* Port portion of URI */
cupsd_printer_t *printer; /* Printer/class */
cups_array_t *ra; /* Requested attributes array */
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
cups_array_t *ra; /* Requested attributes array */
ipp_attribute_t *attr; /* Attribute */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char scheme[HTTP_MAX_URI],
- /* Scheme portion of URI */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
username[HTTP_MAX_URI],
/* Username portion of URI */
host[HTTP_MAX_URI],
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
- sizeof(scheme), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/") ||
return;
}
}
- else if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ else if (!cupsdValidateDest(host, resource, &dtype, &printer))
{
/*
* Bad URI...
*dest; /* Destination */
cups_ptype_t stype, /* Source type (printer or class) */
dtype; /* Destination type (printer or class) */
- char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
return;
}
- if ((dest = cupsdValidateDest(attr->values[0].string.text, &dtype,
- &dprinter)) == NULL)
+ httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((dest = cupsdValidateDest(host, resource, &dtype, &dprinter)) == NULL)
{
/*
* Bad URI...
* Check policy...
*/
- if ((status = cupsdCheckPolicy(dprinter->op_policy_ptr, con,
- NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(dprinter->op_policy_ptr, con, NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
* See if we have a job URI or a printer URI...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
- sizeof(scheme), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(uri->name, "printer-uri"))
* Move all jobs...
*/
- if ((src = cupsdValidateDest(uri->values[0].string.text, &stype,
- &sprinter)) == NULL)
+ if ((src = cupsdValidateDest(host, resource, &stype, &sprinter)) == NULL)
{
/*
* Bad URI...
{
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
- const char *default_format; /* document-format-default value */
cupsd_job_t *job; /* New job */
char filename[1024]; /* Job filename */
mime_type_t *filetype; /* Type of file */
return;
}
- /*
- * Is the destination valid?
- */
-
- if (!cupsdValidateDest(uri->values[0].string.text, NULL, &printer))
- {
- /*
- * Bad URI...
- */
-
- send_ipp_status(con, IPP_NOT_FOUND,
- _("The printer or class was not found."));
- return;
- }
-
/*
* Is it a format we support?
*/
* Grab format from client...
*/
- if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super,
- type) != 2)
+ if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2)
{
send_ipp_status(con, IPP_BAD_REQUEST,
_("Could not scan type \"%s\"!"),
return;
}
}
- else if ((default_format = cupsGetOption("document-format",
- printer->num_options,
- printer->options)) != NULL)
- {
- /*
- * Use default document format...
- */
-
- if (sscanf(default_format, "%15[^/]/%31[^;]", super, type) != 2)
- {
- send_ipp_status(con, IPP_BAD_REQUEST,
- _("Could not scan type \"%s\"!"),
- default_format);
- return;
- }
- }
else
{
/*
- * Auto-type it!
+ * No document format attribute? Auto-type it!
*/
strcpy(super, "application");
doc_name ? doc_name->values[0].string.text : NULL,
&compression);
- if (!filetype)
- filetype = mimeType(MimeDatabase, super, type);
- }
- else
- filetype = mimeType(MimeDatabase, super, type);
-
- if (filetype &&
- (!format ||
- (!strcmp(super, "application") && !strcmp(type, "octet-stream"))))
- {
- /*
- * Replace the document-format attribute value with the auto-typed or
- * default one.
- */
+ if (filetype)
+ {
+ /*
+ * Replace the document-format attribute value with the auto-typed one.
+ */
- snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
- filetype->type);
+ snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
+ filetype->type);
- if (format)
- {
- _cupsStrFree(format->values[0].string.text);
+ if (format)
+ {
+ _cupsStrFree(format->values[0].string.text);
- format->values[0].string.text = _cupsStrAlloc(mimetype);
+ format->values[0].string.text = _cupsStrAlloc(mimetype);
+ }
+ else
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
+ "document-format", NULL, mimetype);
}
else
- ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
- "document-format", NULL, mimetype);
+ filetype = mimeType(MimeDatabase, super, type);
}
- else if (!filetype)
+ else
+ filetype = mimeType(MimeDatabase, super, type);
+
+ if (!filetype)
{
send_ipp_status(con, IPP_DOCUMENT_FORMAT,
_("Unsupported format \'%s/%s\'!"), super, type);
* Create the job object...
*/
- if ((job = add_job(con, printer, filetype)) == NULL)
+ if ((job = add_job(con, uri, &printer, filetype)) == NULL)
return;
/*
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI], /* Method portion of URI */
+ username[HTTP_MAX_URI], /* Username portion of URI */
+ host[HTTP_MAX_URI], /* Host portion of URI */
+ resource[HTTP_MAX_URI]; /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
ipp_attribute_t *attr; /* printer-state-message text */
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
cupsdSaveAllClasses();
cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" rejecting jobs (\"%s\").",
- printer->name, get_username(con));
+ name, get_username(con));
}
else
{
cupsdSaveAllPrinters();
cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" rejecting jobs (\"%s\").",
- printer->name, get_username(con));
+ name, get_username(con));
}
/*
{
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
- const char *default_format;/* document-format-default value */
int jobid; /* Job ID number */
cupsd_job_t *job; /* Current job */
char job_uri[HTTP_MAX_URI],
return;
}
}
- else if ((default_format = cupsGetOption("document-format",
- printer->num_options,
- printer->options)) != NULL)
- {
- /*
- * Use default document format...
- */
-
- if (sscanf(default_format, "%15[^/]/%31[^;]", super, type) != 2)
- {
- send_ipp_status(con, IPP_BAD_REQUEST,
- _("Could not scan type \"%s\"!"),
- default_format);
- return;
- }
- }
else
{
/*
doc_name ? doc_name->values[0].string.text : NULL,
&compression);
- if (!filetype)
- filetype = mimeType(MimeDatabase, super, type);
- }
- else
- filetype = mimeType(MimeDatabase, super, type);
-
- if (filetype &&
- (!format ||
- (!strcmp(super, "application") && !strcmp(type, "octet-stream"))))
- {
- /*
- * Replace the document-format attribute value with the auto-typed or
- * default one.
- */
-
- snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
- filetype->type);
-
- if (format)
+ if (filetype)
{
- _cupsStrFree(format->values[0].string.text);
+ /*
+ * Replace the document-format attribute value with the auto-typed one.
+ */
+
+ snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
+ filetype->type);
- format->values[0].string.text = _cupsStrAlloc(mimetype);
+ if (format)
+ {
+ _cupsStrFree(format->values[0].string.text);
+ format->values[0].string.text = _cupsStrAlloc(mimetype);
+ }
+ else
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
+ "document-format", NULL, mimetype);
}
else
- ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
- "document-format", NULL, mimetype);
+ filetype = mimeType(MimeDatabase, super, type);
}
- else if (!filetype)
+ else
+ filetype = mimeType(MimeDatabase, super, type);
+
+ if (!filetype)
{
send_ipp_status(con, IPP_DOCUMENT_FORMAT,
_("Unsupported format \'%s/%s\'!"), super, type);
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
+ username[HTTP_MAX_URI],
+ /* Username portion of URI */
+ host[HTTP_MAX_URI],
+ /* Host portion of URI */
+ resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer */
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
cupsdWritePrintcap();
cupsdLogMessage(CUPSD_LOG_INFO,
- "Default destination set to \"%s\" by \"%s\".",
- printer->name, get_username(con));
+ "Default destination set to \"%s\" by \"%s\".", name,
+ get_username(con));
/*
* Everything was ok, so return OK status...
attr->values[0].string.text);
cupsdSetString(&printer->error_policy, attr->values[0].string.text);
}
- else if (!strcmp(attr->name, "notify-lease-duration-default") ||
+ else if (!strcmp(attr->name, "document-format-default") ||
+ !strcmp(attr->name, "notify-lease-duration-default") ||
!strcmp(attr->name, "notify-events-default"))
continue;
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
+ username[HTTP_MAX_URI],
+ /* Username portion of URI */
+ host[HTTP_MAX_URI],
+ /* Host portion of URI */
+ resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
if (dtype & CUPS_PRINTER_CLASS)
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" started by \"%s\".",
- printer->name, get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" started by \"%s\".", name,
+ get_username(con));
cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED, printer, NULL,
- "Class \"%s\" started by \"%s\".", printer->name,
- get_username(con));
+ "Class \"%s\" started by \"%s\".", name, get_username(con));
}
else
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" started by \"%s\".",
- printer->name, get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" started by \"%s\".", name,
+ get_username(con));
cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED, printer, NULL,
- "Printer \"%s\" started by \"%s\".", printer->name,
- get_username(con));
+ "Printer \"%s\" started by \"%s\".", name, get_username(con));
}
cupsdCheckJobs();
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
+ username[HTTP_MAX_URI],
+ /* Username portion of URI */
+ host[HTTP_MAX_URI],
+ /* Host portion of URI */
+ resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
ipp_attribute_t *attr; /* printer-state-message attribute */
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
/*
* Bad URI...
if (dtype & CUPS_PRINTER_CLASS)
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" stopped by \"%s\".",
- printer->name, get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" stopped by \"%s\".", name,
+ get_username(con));
cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED, printer, NULL,
- "Class \"%s\" stopped by \"%s\".", printer->name,
- get_username(con));
+ "Class \"%s\" stopped by \"%s\".", name, get_username(con));
}
else
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" stopped by \"%s\".",
- printer->name, get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" stopped by \"%s\".", name,
+ get_username(con));
cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED, printer, NULL,
- "Printer \"%s\" stopped by \"%s\".", printer->name,
- get_username(con));
+ "Printer \"%s\" stopped by \"%s\".", name, get_username(con));
}
/*
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
cups_ptype_t dtype; /* Destination type (printer or class) */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
+ username[HTTP_MAX_URI],
+ /* Username portion of URI */
+ host[HTTP_MAX_URI],
+ /* Host portion of URI */
+ resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int port; /* Port portion of URI */
char super[MIME_MAX_SUPER],
/* Supertype of file */
type[MIME_MAX_TYPE];
* Is the destination valid?
*/
- if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
+
+ if (cupsdValidateDest(host, resource, &dtype, &printer) == NULL)
{
/*
* Bad URI...
/*
- * End of "$Id: ipp.c 5552 2006-05-20 12:00:37Z mike $".
+ * End of "$Id: ipp.c 5554 2006-05-20 12:23:40Z mike $".
*/