*
* Printer routines for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
static void delete_printer_filters(cupsd_printer_t *p);
static void dirty_printer(cupsd_printer_t *p);
static void load_ppd(cupsd_printer_t *p);
-static void log_ipp_conformance(cupsd_printer_t *p, const char *reason);
static ipp_t *new_media_col(_pwg_size_t *size, const char *source,
const char *type);
static void write_xml_string(cups_file_t *fp, const char *s);
};
static const int ops[] = /* operations-supported values */
{
- IPP_PRINT_JOB,
- IPP_VALIDATE_JOB,
- IPP_CREATE_JOB,
- IPP_SEND_DOCUMENT,
- IPP_CANCEL_JOB,
- IPP_GET_JOB_ATTRIBUTES,
- IPP_GET_JOBS,
- IPP_GET_PRINTER_ATTRIBUTES,
- IPP_HOLD_JOB,
- IPP_RELEASE_JOB,
- IPP_RESTART_JOB,
- IPP_PAUSE_PRINTER,
- IPP_RESUME_PRINTER,
- IPP_PURGE_JOBS,
- IPP_SET_PRINTER_ATTRIBUTES,
- IPP_SET_JOB_ATTRIBUTES,
- IPP_GET_PRINTER_SUPPORTED_VALUES,
- IPP_CREATE_PRINTER_SUBSCRIPTION,
- IPP_CREATE_JOB_SUBSCRIPTION,
- IPP_GET_SUBSCRIPTION_ATTRIBUTES,
- IPP_GET_SUBSCRIPTIONS,
- IPP_RENEW_SUBSCRIPTION,
- IPP_CANCEL_SUBSCRIPTION,
- IPP_GET_NOTIFICATIONS,
- IPP_ENABLE_PRINTER,
- IPP_DISABLE_PRINTER,
- IPP_HOLD_NEW_JOBS,
- IPP_RELEASE_HELD_NEW_JOBS,
- IPP_CANCEL_JOBS,
- IPP_CANCEL_MY_JOBS,
- IPP_CLOSE_JOB,
- CUPS_GET_DEFAULT,
- CUPS_GET_PRINTERS,
- CUPS_ADD_PRINTER,
- CUPS_DELETE_PRINTER,
- CUPS_GET_CLASSES,
- CUPS_ADD_CLASS,
- CUPS_DELETE_CLASS,
- CUPS_ACCEPT_JOBS,
- CUPS_REJECT_JOBS,
- CUPS_SET_DEFAULT,
- CUPS_GET_DEVICES,
- CUPS_GET_PPDS,
- CUPS_MOVE_JOB,
- CUPS_AUTHENTICATE_JOB,
- CUPS_GET_PPD,
- CUPS_GET_DOCUMENT,
- IPP_RESTART_JOB
+ IPP_OP_PRINT_JOB,
+ IPP_OP_VALIDATE_JOB,
+ IPP_OP_CREATE_JOB,
+ IPP_OP_SEND_DOCUMENT,
+ IPP_OP_CANCEL_JOB,
+ IPP_OP_GET_JOB_ATTRIBUTES,
+ IPP_OP_GET_JOBS,
+ IPP_OP_GET_PRINTER_ATTRIBUTES,
+ IPP_OP_HOLD_JOB,
+ IPP_OP_RELEASE_JOB,
+ IPP_OP_PAUSE_PRINTER,
+ IPP_OP_RESUME_PRINTER,
+ IPP_OP_PURGE_JOBS,
+ IPP_OP_SET_PRINTER_ATTRIBUTES,
+ IPP_OP_SET_JOB_ATTRIBUTES,
+ IPP_OP_GET_PRINTER_SUPPORTED_VALUES,
+ IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS,
+ IPP_OP_CREATE_JOB_SUBSCRIPTIONS,
+ IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES,
+ IPP_OP_GET_SUBSCRIPTIONS,
+ IPP_OP_RENEW_SUBSCRIPTION,
+ IPP_OP_CANCEL_SUBSCRIPTION,
+ IPP_OP_GET_NOTIFICATIONS,
+ IPP_OP_ENABLE_PRINTER,
+ IPP_OP_DISABLE_PRINTER,
+ IPP_OP_HOLD_NEW_JOBS,
+ IPP_OP_RELEASE_HELD_NEW_JOBS,
+ IPP_OP_CANCEL_JOBS,
+ IPP_OP_CANCEL_MY_JOBS,
+ IPP_OP_CLOSE_JOB,
+ IPP_OP_CUPS_GET_DEFAULT,
+ IPP_OP_CUPS_GET_PRINTERS,
+ IPP_OP_CUPS_ADD_MODIFY_PRINTER,
+ IPP_OP_CUPS_DELETE_PRINTER,
+ IPP_OP_CUPS_GET_CLASSES,
+ IPP_OP_CUPS_ADD_MODIFY_CLASS,
+ IPP_OP_CUPS_DELETE_CLASS,
+ IPP_OP_CUPS_ACCEPT_JOBS,
+ IPP_OP_CUPS_REJECT_JOBS,
+ IPP_OP_CUPS_SET_DEFAULT,
+ IPP_OP_CUPS_GET_DEVICES,
+ IPP_OP_CUPS_GET_PPDS,
+ IPP_OP_CUPS_MOVE_JOB,
+ IPP_OP_CUPS_AUTHENTICATE_JOB,
+ IPP_OP_CUPS_GET_PPD,
+ IPP_OP_CUPS_GET_DOCUMENT,
+ IPP_OP_RESTART_JOB
};
static const char * const charsets[] =/* charset-supported values */
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of printers.conf.", linenum);
}
- else if (!_cups_strcasecmp(line, "</Printer>"))
+ else if (!_cups_strcasecmp(line, "</Printer>") || !_cups_strcasecmp(line, "</DefaultPrinter>"))
{
if (p != NULL)
{
else if (!_cups_strcasecmp(line, "Type"))
{
if (value)
- p->type = atoi(value);
+ p->type = (cups_ptype_t)atoi(value);
else
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of printers.conf.", linenum);
else if (!_cups_strcasecmp(line, "ErrorPolicy"))
{
if (value)
- cupsdSetString(&p->error_policy, value);
+ {
+ if (strcmp(value, "retry-current-job") &&
+ strcmp(value, "abort-job") &&
+ strcmp(value, "retry-job") &&
+ strcmp(value, "stop-printer"))
+ cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid ErrorPolicy \"%s\" on line %d or printers.conf.", ErrorPolicy, linenum);
+ else
+ cupsdSetString(&p->error_policy, value);
+ }
else
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Syntax error on line %d of printers.conf.", linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d of printers.conf.", linenum);
}
else if (!_cups_strcasecmp(line, "Attribute") && value)
{
{
cupsFilePuts(fp, "State Stopped\n");
- if (printer->state_message)
+ if (printer->state_message[0])
cupsFilePutConf(fp, "StateMessage", printer->state_message);
}
else
if (i)
*ptr++ = ',';
- strlcpy(ptr, marker->values[i].string.text,
- value + sizeof(value) - ptr);
+ strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
ptr += strlen(ptr);
}
if (i)
*ptr++ = ',';
- strlcpy(ptr, marker->values[i].string.text,
- value + sizeof(value) - ptr);
+ strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
ptr += strlen(ptr);
}
if (i)
*ptr++ = ',';
- strlcpy(ptr, marker->values[i].string.text,
- value + sizeof(value) - ptr);
+ strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
ptr += strlen(ptr);
}
cupsFilePrintf(fp, "Attribute marker-change-time %ld\n",
(long)printer->marker_time);
- cupsFilePuts(fp, "</Printer>\n");
+ if (printer == DefaultPrinter)
+ cupsFilePuts(fp, "</DefaultPrinter>\n");
+ else
+ cupsFilePuts(fp, "</Printer>\n");
}
cupsdCloseCreatedConfFile(fp, filename);
strcmp(p->auth_info_required[0], "none"))
p->type |= CUPS_PRINTER_AUTHENTICATED;
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED;
return (1);
}
if ((auth_type = auth->type) == CUPSD_AUTH_DEFAULT)
auth_type = cupsdDefaultAuthType();
- if (auth_type == CUPSD_AUTH_BASIC || auth_type == CUPSD_AUTH_BASICDIGEST)
+ if (auth_type == CUPSD_AUTH_BASIC)
auth_supported = "basic";
- else if (auth_type == CUPSD_AUTH_DIGEST)
- auth_supported = "digest";
#ifdef HAVE_GSSAPI
else if (auth_type == CUPSD_AUTH_NEGOTIATE)
auth_supported = "negotiate";
if (auth_type != CUPSD_AUTH_NONE)
p->type |= CUPS_PRINTER_AUTHENTICATED;
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED;
}
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED;
/*
* Create the required IPP attributes for a printer...
if (p->type & CUPS_PRINTER_CLASS)
{
p->raw = 1;
- p->type &= ~CUPS_PRINTER_OPTIONS;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS;
/*
* Add class-specific attributes...
if (attr != NULL)
attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name);
- p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
}
}
}
_cupsStrFree(p->reasons[i]);
if (i < p->num_reasons)
- memmove(p->reasons + i, p->reasons + i + 1,
- (p->num_reasons - i) * sizeof(char *));
+ memmove(p->reasons + i, p->reasons + i + 1, (size_t)(p->num_reasons - i) * sizeof(char *));
if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED)
cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
if (i >= p->num_reasons)
{
- if (!strncmp(reason, "cups-ipp-missing-", 17) ||
- !strncmp(reason, "cups-ipp-wrong-", 15))
- log_ipp_conformance(p, reason);
-
if (i >= (int)(sizeof(p->reasons) / sizeof(p->reasons[0])))
{
cupsdLogMessage(CUPSD_LOG_ALERT,
{
char *ptr; /* Pointer into maxsize(nnnn) program */
- maxsize = strtoll(program + 8, &ptr, 10);
+ maxsize = (size_t)strtoll(program + 8, &ptr, 10);
if (*ptr != ')')
{
filter;
filter = (mime_filter_t *)cupsArrayNext(MimeDatabase->filters))
{
- if (filter->dst == p->filetype && filter->filter &&
- strstr(filter->filter, "PrintJobMgr"))
+ if (filter->dst == p->filetype && strstr(filter->filter, "PrintJobMgr"))
break;
}
cupsdLogMessage(CUPSD_LOG_DEBUG, "load_ppd: Loading %s...", ppd_name);
- p->type &= ~CUPS_PRINTER_OPTIONS;
+ cupsdClearString(&(p->make_model));
+
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS;
p->type |= CUPS_PRINTER_BW;
finishings[0] = IPP_FINISHINGS_NONE;
if (ppd_attr->value && !_cups_strcasecmp(ppd_attr->value, "true"))
p->type |= CUPS_PRINTER_FAX;
- ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported",
- ppd->color_device);
+ ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported", (char)ppd->color_device);
if (p->pc && p->pc->charge_info_uri)
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"job-password-encryption-supported", NULL, "none");
ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
- "job-password-supported", strlen(p->pc->password));
+ "job-password-supported", (int)strlen(p->pc->password));
}
if (ppd->throughput)
CGContextRef context; /* The CG context used for resizing */
snprintf(outPath, sizeof(outPath), "%s/%s.png", CacheDir, p->name);
- outUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
- (UInt8 *)outPath,
- strlen(outPath),
- FALSE);
- icnsFileUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
- (UInt8 *)ppd_attr->value,
- strlen(ppd_attr->value),
- FALSE);
+ outUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)outPath, (CFIndex)strlen(outPath), FALSE);
+ icnsFileUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)ppd_attr->value, (CFIndex)strlen(ppd_attr->value), FALSE);
if (outUrl && icnsFileUrl)
{
sourceRef = CGImageSourceCreateWithURL(icnsFileUrl, NULL);
if (sourceRef)
{
- for (i = 0; i < CGImageSourceGetCount(sourceRef); i ++)
+ for (i = 0; i < (int)CGImageSourceGetCount(sourceRef); i ++)
{
- imageRef = CGImageSourceCreateImageAtIndex(sourceRef, i, NULL);
+ imageRef = CGImageSourceCreateImageAtIndex(sourceRef, (size_t)i, NULL);
if (!imageRef)
continue;
pstatus = ppdLastError(&pline);
- cupsdLogMessage(CUPSD_LOG_ERROR, "PPD file for %s cannot be loaded!",
- p->name);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "PPD file for %s cannot be loaded.", p->name);
if (pstatus <= PPD_ALLOC_ERROR)
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s: %s", ppd_name, strerror(errno));
else
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s on line %d.",
- ppdErrorString(pstatus), pline);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s on line %d of %s.", ppdErrorString(pstatus), pline, ppd_name);
cupsdLogMessage(CUPSD_LOG_INFO,
"Hint: Run \"cupstestppd %s\" and fix any errors.",
}
-/*
- * 'log_ipp_conformance()' - Log an IPP conformance issue with a printer.
- */
-
-static void
-log_ipp_conformance(
- cupsd_printer_t *p, /* I - Printer */
- const char *reason) /* I - Printer state reason */
-{
- const char *message; /* Message to log */
-#ifdef __APPLE__
- aslmsg aslm; /* Apple System Log message */
-#endif /* __APPLE__ */
-
-
- /*
- * Strip the leading "cups-ipp-" from the reason and create a log message for
- * it...
- */
-
- reason += 9;
- if (!strcmp(reason, "missing-cancel-job"))
- message = "Printer does not support REQUIRED Cancel-Job operation.";
- else if (!strcmp(reason, "missing-get-job-attributes"))
- message = "Printer does not support REQUIRED Get-Job-Attributes operation.";
- else if (!strcmp(reason, "missing-print-job"))
- message = "Printer does not support REQUIRED Print-Job operation.";
- else if (!strcmp(reason, "missing-validate-job"))
- message = "Printer does not support REQUIRED Validate-Job operation.";
- else if (!strcmp(reason, "missing-get-printer-attributes"))
- message = "Printer does not support REQUIRED Get-Printer-Attributes operation.";
- else if (!strcmp(reason, "missing-send-document"))
- message = "Printer supports Create-Job but not Send-Document operation.";
- else if (!strcmp(reason, "missing-job-history"))
- message = "Printer does not provide REQUIRED job history.";
- else if (!strcmp(reason, "missing-job-id"))
- message = "Printer does not provide REQUIRED job-id attribute.";
- else if (!strcmp(reason, "missing-job-state"))
- message = "Printer does not provide REQUIRED job-state attribute.";
- else if (!strcmp(reason, "missing-operations-supported"))
- message = "Printer does not provide REQUIRED operations-supported "
- "attribute.";
- else if (!strcmp(reason, "missing-printer-is-accepting-jobs"))
- message = "Printer does not provide REQUIRED printer-is-accepting-jobs "
- "attribute.";
- else if (!strcmp(reason, "missing-printer-state-reasons"))
- message = "Printer does not provide REQUIRED printer-state-reasons "
- "attribute.";
- else if (!strcmp(reason, "wrong-http-version"))
- message = "Printer does not use REQUIRED HTTP/1.1 transport.";
- else
- message = "Unknown IPP conformance failure.";
-
- cupsdLogMessage(CUPSD_LOG_WARN, "%s: %s", p->name, message);
-
-#ifdef __APPLE__
- /*
- * Report the failure information to Apple if the user opts into providing
- * feedback to Apple...
- */
-
- aslm = asl_new(ASL_TYPE_MSG);
- if (aslm)
- {
- asl_set(aslm, "com.apple.message.domain", "com.apple.printing.ipp.conformance");
- asl_set(aslm, "com.apple.message.domain_scope", "com.apple.printing.ipp.conformance");
- asl_set(aslm, "com.apple.message.signature", reason);
- asl_set(aslm, "com.apple.message.signature2",
- p->make_model ? p->make_model : "Unknown");
- asl_log(NULL, aslm, ASL_LEVEL_NOTICE, "%s: %s",
- p->make_model ? p->make_model : "Unknown", message);
- asl_free(aslm);
- }
-#endif /* __APPLE__ */
-}
-
-
/*
* 'new_media_col()' - Create a media-col collection value.
*/
if (*s == '&')
{
if (s > start)
- cupsFileWrite(fp, start, s - start);
+ cupsFileWrite(fp, start, (size_t)(s - start));
cupsFilePuts(fp, "&");
start = s + 1;
else if (*s == '<')
{
if (s > start)
- cupsFileWrite(fp, start, s - start);
+ cupsFileWrite(fp, start, (size_t)(s - start));
cupsFilePuts(fp, "<");
start = s + 1;