]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/printers.c
Fix build errors on Linux for new journald logging.
[thirdparty/cups.git] / scheduler / printers.c
index 48e7e0e4e29265f584dac1bb8d55b68adda23624..86b3e5939cb06e2aca715aa83d6467099759605f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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
@@ -50,7 +50,6 @@ static int    compare_printers(void *first, void *second, void *data);
 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);
@@ -96,11 +95,12 @@ cupsdAddPrinter(const char *name)   /* I - Name of printer */
                                             uuid, sizeof(uuid)));
   cupsdSetDeviceURI(p, "file:///dev/null");
 
-  p->state      = IPP_PRINTER_STOPPED;
-  p->state_time = time(NULL);
-  p->accepting  = 0;
-  p->shared     = DefaultShared;
-  p->filetype   = mimeAddType(MimeDatabase, "printer", name);
+  p->config_time = time(NULL);
+  p->state       = IPP_PRINTER_STOPPED;
+  p->state_time  = time(NULL);
+  p->accepting   = 0;
+  p->shared      = DefaultShared;
+  p->filetype    = mimeAddType(MimeDatabase, "printer", name);
 
   cupsdSetString(&p->job_sheets[0], "none");
   cupsdSetString(&p->job_sheets[1], "none");
@@ -172,6 +172,10 @@ cupsdCreateCommonData(void)
                  "third-shift",
                  "weekend"
                };
+  static const char * const features[] =/* ipp-features-supported values */
+               {
+                 "subscription-object"
+               };
   static const char * const versions[] =/* ipp-versions-supported values */
                {
                  "1.0",
@@ -181,54 +185,53 @@ cupsdCreateCommonData(void)
                };
   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 */
                {
@@ -341,8 +344,11 @@ cupsdCreateCommonData(void)
                };
   static const char * const printer_settable[] =
                {                       /* printer-settable-attributes-supported */
+                 "printer-geo-location",
                  "printer-info",
-                 "printer-location"
+                 "printer-location",
+                 "printer-organization",
+                 "printer-organizational-unit"
                };
   static const char * const which_jobs[] =
                {                       /* which-jobs-supported values */
@@ -422,6 +428,9 @@ cupsdCreateCommonData(void)
   ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE,
                "generated-natural-language-supported", NULL, DefaultLanguage);
 
+  /* ipp-features-supported */
+  ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "ipp-features-supported", sizeof(features) / sizeof(features[0]), NULL, features);
+
   /* ipp-versions-supported */
   ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY,
                 "ipp-versions-supported", sizeof(versions) / sizeof(versions[0]),
@@ -535,6 +544,9 @@ cupsdCreateCommonData(void)
   ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
                 "multiple-operation-time-out", MultipleOperationTimeout);
 
+  /* multiple-operation-time-out-action */
+  ippAddString(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "multiple-operation-time-out-action", NULL, "process-job");
+
   /* natural-language-configured (no IPP_TAG_COPY) */
   ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE,
                "natural-language-configured", NULL, DefaultLanguage);
@@ -620,6 +632,9 @@ cupsdCreateCommonData(void)
   ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY,
                "pdl-override-supported", NULL, "attempted");
 
+  /* printer-get-attributes-supported */
+  ippAddString(CommonData, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "printer-get-attributes-supported", NULL, "document-format");
+
   /* printer-op-policy-supported */
   attr = ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME | IPP_TAG_COPY,
                        "printer-op-policy-supported", cupsArrayCount(Policies),
@@ -753,6 +768,7 @@ cupsdDeletePrinter(
   cupsdClearString(&p->hostname);
   cupsdClearString(&p->name);
   cupsdClearString(&p->location);
+  cupsdClearString(&p->geo_location);
   cupsdClearString(&p->make_model);
   cupsdClearString(&p->info);
   cupsdClearString(&p->job_sheets[0]);
@@ -886,7 +902,7 @@ cupsdLoadAllPrinters(void)
         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)
       {
@@ -962,6 +978,21 @@ cupsdLoadAllPrinters(void)
       if (value)
        cupsdSetString(&p->location, value);
     }
+    else if (!_cups_strcasecmp(line, "GeoLocation"))
+    {
+      if (value)
+        cupsdSetString(&p->geo_location, value);
+    }
+    else if (!_cups_strcasecmp(line, "Organization"))
+    {
+      if (value)
+       cupsdSetString(&p->organization, value);
+    }
+    else if (!_cups_strcasecmp(line, "OrganizationalUnit"))
+    {
+      if (value)
+       cupsdSetString(&p->organizational_unit, value);
+    }
     else if (!_cups_strcasecmp(line, "DeviceURI"))
     {
       if (value)
@@ -1066,6 +1097,15 @@ cupsdLoadAllPrinters(void)
       if (value)
         p->state_time = atoi(value);
     }
+    else if (!_cups_strcasecmp(line, "ConfigTime"))
+    {
+     /*
+      * Set the config time...
+      */
+
+      if (value)
+        p->config_time = atoi(value);
+    }
     else if (!_cups_strcasecmp(line, "Accepting"))
     {
      /*
@@ -1089,7 +1129,7 @@ cupsdLoadAllPrinters(void)
     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);
@@ -1216,10 +1256,17 @@ cupsdLoadAllPrinters(void)
     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)
     {
@@ -1415,9 +1462,18 @@ cupsdSaveAllPrinters(void)
     if (printer->location)
       cupsFilePutConf(fp, "Location", printer->location);
 
+    if (printer->geo_location)
+      cupsFilePutConf(fp, "GeoLocation", printer->geo_location);
+
     if (printer->make_model)
       cupsFilePutConf(fp, "MakeModel", printer->make_model);
 
+    if (printer->organization)
+      cupsFilePutConf(fp, "Organization", printer->organization);
+
+    if (printer->organizational_unit)
+      cupsFilePutConf(fp, "OrganizationalUnit", printer->organizational_unit);
+
     cupsFilePutConf(fp, "DeviceURI", printer->device_uri);
 
     if (printer->port_monitor)
@@ -1427,13 +1483,14 @@ cupsdSaveAllPrinters(void)
     {
       cupsFilePuts(fp, "State Stopped\n");
 
-      if (printer->state_message)
+      if (printer->state_message[0])
         cupsFilePutConf(fp, "StateMessage", printer->state_message);
     }
     else
       cupsFilePuts(fp, "State Idle\n");
 
     cupsFilePrintf(fp, "StateTime %d\n", (int)printer->state_time);
+    cupsFilePrintf(fp, "ConfigTime %d\n", (int)printer->config_time);
 
     for (i = 0; i < printer->num_reasons; i ++)
       if (strcmp(printer->reasons[i], "connecting-to-device") &&
@@ -1491,8 +1548,7 @@ cupsdSaveAllPrinters(void)
         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);
       }
 
@@ -1551,8 +1607,7 @@ cupsdSaveAllPrinters(void)
         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);
       }
 
@@ -1572,8 +1627,7 @@ cupsdSaveAllPrinters(void)
         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);
       }
 
@@ -1585,7 +1639,10 @@ cupsdSaveAllPrinters(void)
       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);
@@ -1688,7 +1745,7 @@ cupsdSetAuthInfoRequired(
         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);
   }
@@ -1910,6 +1967,7 @@ cupsdSetPrinterAttr(
 
     if (!attr)
     {
+      free(temp);
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Unable to allocate memory for printer attribute "
                      "(%d values)", count);
@@ -1960,6 +2018,7 @@ cupsdSetPrinterAttr(
 
     if (!attr)
     {
+      free(temp);
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Unable to allocate memory for printer attribute "
                      "(%d values)", count);
@@ -1997,6 +2056,77 @@ cupsdSetPrinterAttr(
   }
 
   free(temp);
+
+ /*
+  * Update the printer-supply and printer-supply-description, as needed...
+  */
+
+  if (!strcmp(name, "marker-names"))
+  {
+    ipp_attribute_t *supply_desc = ippFindAttribute(p->attrs, "printer-supply-description", IPP_TAG_TEXT);
+                                       /* printer-supply-description attribute */
+
+    if (supply_desc != NULL)
+      ippDeleteAttribute(p->attrs, supply_desc);
+
+    supply_desc = ippCopyAttribute(p->attrs, attr, 0);
+    ippSetName(p->attrs, &supply_desc, "printer-supply-description");
+    ippSetValueTag(p->attrs, &supply_desc, IPP_TAG_TEXT);
+  }
+  else if (!strcmp(name, "marker-colors") || !strcmp(name, "marker-levels") || !strcmp(name, "marker-types"))
+  {
+    char       buffer[256],            /* printer-supply values */
+               pstype[64],             /* printer-supply type value */
+               *psptr;                 /* Pointer into type */
+    const char *color,                 /* marker-colors value */
+               *type;                  /* marker-types value */
+    int                level;                  /* marker-levels value */
+    ipp_attribute_t *colors = ippFindAttribute(p->attrs, "marker-colors", IPP_TAG_NAME);
+                                       /* marker-colors attribute */
+    ipp_attribute_t *levels = ippFindAttribute(p->attrs, "marker-levels", IPP_TAG_INTEGER);
+                                       /* marker-levels attribute */
+    ipp_attribute_t *types = ippFindAttribute(p->attrs, "marker-types", IPP_TAG_KEYWORD);
+                                       /* marker-types attribute */
+    ipp_attribute_t *supply = ippFindAttribute(p->attrs, "printer-supply", IPP_TAG_STRING);
+                                       /* printer-supply attribute */
+
+    if (supply != NULL)
+    {
+      ippDeleteAttribute(p->attrs, supply);
+      supply = NULL;
+    }
+
+    if (!colors || !levels || !types)
+      return;
+
+    count = ippGetCount(colors);
+    if (count != ippGetCount(levels) || count != ippGetCount(types))
+      return;
+
+    for (i = 0; i < count; i ++)
+    {
+      color = ippGetString(colors, i, NULL);
+      level = ippGetInteger(levels, i);
+      type  = ippGetString(types, i, NULL);
+
+      for (psptr = pstype; *type && psptr < (pstype + sizeof(pstype) - 1); type ++)
+        if (*type == '-')
+       {
+         type ++;
+         *psptr++ = (char)toupper(*type & 255);
+       }
+       else
+         *psptr++ = *type;
+      *psptr = '\0';
+
+      snprintf(buffer, sizeof(buffer), "index=%d;class=%s;type=%s;unit=percent;maxcapacity=100;level=%d;colorantname=%s;", i + 1, strncmp(pstype, "waste", 5) ? "supplyThatIsConsumed" : "receptacleThatIsFilled", pstype, level, color);
+
+      if (!i)
+        supply = ippAddOctetString(p->attrs, IPP_TAG_PRINTER, "printer-supply", buffer, (int)strlen(buffer));
+      else
+        ippSetOctetString(p->attrs, &supply, i, buffer, (int)strlen(buffer));
+    }
+  }
 }
 
 
@@ -2056,10 +2186,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
     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";
@@ -2068,10 +2196,10 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
     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...
@@ -2088,10 +2216,15 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
                p->name);
   ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-location",
                NULL, p->location ? p->location : "");
+  if (p->geo_location)
+    ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-geo-location", NULL, p->geo_location);
+  else
+    ippAddOutOfBand(p->attrs, IPP_TAG_PRINTER, IPP_TAG_UNKNOWN, "printer-geo-location");
   ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info",
                NULL, p->info ? p->info : "");
-  ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uuid", NULL,
-              p->uuid);
+  ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-organization", NULL, p->organization ? p->organization : "");
+  ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-organizational-unit", NULL, p->organizational_unit ? p->organizational_unit : "");
+  ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uuid", NULL, p->uuid);
 
   if (cupsArrayCount(p->users) > 0)
   {
@@ -2150,7 +2283,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
   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...
@@ -2176,7 +2309,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
        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;
       }
     }
   }
@@ -2465,8 +2598,7 @@ cupsdSetPrinterReasons(
          _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);
@@ -2492,10 +2624,6 @@ cupsdSetPrinterReasons(
 
       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,
@@ -3304,7 +3432,7 @@ add_printer_filter(
   {
     char       *ptr;                   /* Pointer into maxsize(nnnn) program */
 
-    maxsize = strtoll(program + 8, &ptr, 10);
+    maxsize = (size_t)strtoll(program + 8, &ptr, 10);
 
     if (*ptr != ')')
     {
@@ -3492,8 +3620,7 @@ add_printer_formats(cupsd_printer_t *p)   /* I - Printer */
         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;
     }
 
@@ -3715,7 +3842,9 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
 
   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;
@@ -3747,8 +3876,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
       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,
@@ -3767,7 +3895,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
       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)
@@ -3791,6 +3919,9 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
                      "pages-per-minute-color", 1);
     }
 
+    if ((ppd_attr = ppdFindAttr(ppd, "1284DeviceId", NULL)) != NULL)
+      ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, ppd_attr->value);
+
     num_qualities = 0;
 
     if ((output_mode = ppdFindOption(ppd, "OutputMode")) != NULL)
@@ -4617,22 +4748,16 @@ load_ppd(cupsd_printer_t *p)            /* I - Printer */
       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;
 
@@ -4736,14 +4861,12 @@ load_ppd(cupsd_printer_t *p)            /* I - Printer */
 
     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.",
@@ -4864,83 +4987,6 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
 }
 
 
-/*
- * '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.
  */
@@ -5004,7 +5050,7 @@ write_xml_string(cups_file_t *fp, /* I - File to write to */
     if (*s == '&')
     {
       if (s > start)
-        cupsFileWrite(fp, start, s - start);
+        cupsFileWrite(fp, start, (size_t)(s - start));
 
       cupsFilePuts(fp, "&amp;");
       start = s + 1;
@@ -5012,7 +5058,7 @@ write_xml_string(cups_file_t *fp, /* I - File to write to */
     else if (*s == '<')
     {
       if (s > start)
-        cupsFileWrite(fp, start, s - start);
+        cupsFileWrite(fp, start, (size_t)(s - start));
 
       cupsFilePuts(fp, "&lt;");
       start = s + 1;