]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Save work on improved IPP backend - still need to finish up.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 9 May 2011 22:53:31 +0000 (22:53 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 9 May 2011 22:53:31 +0000 (22:53 +0000)
Add new _cupsArrayAddStrings and _cupsArrayNewStrings private APIs we'll use.

Add some basic conformance checking to the IPP backend to catch issues that
will prevent printing from working.

Remove execute bits from files that don't need them.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9755 7a7537e8-13f0-0310-91df-b6672ffda945

154 files changed:
backend/ipp.c
cups/Makefile
cups/array-private.h [new file with mode: 0644]
cups/array.c
cups/sspi-private.h [changed mode: 0755->0644]
cups/sspi.c [changed mode: 0755->0644]
cups/thread-private.h [changed mode: 0755->0644]
cups/thread.c [changed mode: 0755->0644]
doc/es/index.html.in [changed mode: 0755->0644]
doc/it/index.html.in [changed mode: 0755->0644]
scheduler/cups.sh.in [changed mode: 0755->0644]
scheduler/job.c
scheduler/util.c
scheduler/util.h
templates/es/add-class.tmpl [changed mode: 0755->0644]
templates/es/add-printer.tmpl [changed mode: 0755->0644]
templates/es/add-rss-subscription.tmpl [changed mode: 0755->0644]
templates/es/admin.tmpl [changed mode: 0755->0644]
templates/es/choose-device.tmpl [changed mode: 0755->0644]
templates/es/choose-make.tmpl [changed mode: 0755->0644]
templates/es/choose-model.tmpl [changed mode: 0755->0644]
templates/es/choose-serial.tmpl [changed mode: 0755->0644]
templates/es/choose-uri.tmpl [changed mode: 0755->0644]
templates/es/class-added.tmpl [changed mode: 0755->0644]
templates/es/class-confirm.tmpl [changed mode: 0755->0644]
templates/es/class-deleted.tmpl [changed mode: 0755->0644]
templates/es/class-jobs-header.tmpl [changed mode: 0755->0644]
templates/es/class-modified.tmpl [changed mode: 0755->0644]
templates/es/class.tmpl [changed mode: 0755->0644]
templates/es/classes-header.tmpl [changed mode: 0755->0644]
templates/es/classes.tmpl [changed mode: 0755->0644]
templates/es/command.tmpl [changed mode: 0755->0644]
templates/es/edit-config.tmpl [changed mode: 0755->0644]
templates/es/error-op.tmpl [changed mode: 0755->0644]
templates/es/error.tmpl [changed mode: 0755->0644]
templates/es/header.tmpl.in [changed mode: 0755->0644]
templates/es/help-header.tmpl [changed mode: 0755->0644]
templates/es/help-printable.tmpl [changed mode: 0755->0644]
templates/es/help-trailer.tmpl [changed mode: 0755->0644]
templates/es/job-cancel.tmpl [changed mode: 0755->0644]
templates/es/job-hold.tmpl [changed mode: 0755->0644]
templates/es/job-move.tmpl [changed mode: 0755->0644]
templates/es/job-moved.tmpl [changed mode: 0755->0644]
templates/es/job-release.tmpl [changed mode: 0755->0644]
templates/es/job-restart.tmpl [changed mode: 0755->0644]
templates/es/jobs-header.tmpl [changed mode: 0755->0644]
templates/es/jobs.tmpl [changed mode: 0755->0644]
templates/es/list-available-printers.tmpl [changed mode: 0755->0644]
templates/es/modify-class.tmpl [changed mode: 0755->0644]
templates/es/modify-printer.tmpl [changed mode: 0755->0644]
templates/es/norestart.tmpl [changed mode: 0755->0644]
templates/es/option-boolean.tmpl [changed mode: 0755->0644]
templates/es/option-conflict.tmpl [changed mode: 0755->0644]
templates/es/option-header.tmpl [changed mode: 0755->0644]
templates/es/option-pickmany.tmpl [changed mode: 0755->0644]
templates/es/option-pickone.tmpl [changed mode: 0755->0644]
templates/es/option-trailer.tmpl [changed mode: 0755->0644]
templates/es/pager.tmpl [changed mode: 0755->0644]
templates/es/printer-accept.tmpl [changed mode: 0755->0644]
templates/es/printer-added.tmpl [changed mode: 0755->0644]
templates/es/printer-configured.tmpl [changed mode: 0755->0644]
templates/es/printer-confirm.tmpl [changed mode: 0755->0644]
templates/es/printer-default.tmpl [changed mode: 0755->0644]
templates/es/printer-deleted.tmpl [changed mode: 0755->0644]
templates/es/printer-jobs-header.tmpl [changed mode: 0755->0644]
templates/es/printer-modified.tmpl [changed mode: 0755->0644]
templates/es/printer-purge.tmpl [changed mode: 0755->0644]
templates/es/printer-reject.tmpl [changed mode: 0755->0644]
templates/es/printer-start.tmpl [changed mode: 0755->0644]
templates/es/printer-stop.tmpl [changed mode: 0755->0644]
templates/es/printer.tmpl [changed mode: 0755->0644]
templates/es/printers-header.tmpl [changed mode: 0755->0644]
templates/es/printers.tmpl [changed mode: 0755->0644]
templates/es/restart.tmpl [changed mode: 0755->0644]
templates/es/samba-export.tmpl [changed mode: 0755->0644]
templates/es/samba-exported.tmpl [changed mode: 0755->0644]
templates/es/search.tmpl [changed mode: 0755->0644]
templates/es/set-printer-options-header.tmpl [changed mode: 0755->0644]
templates/es/set-printer-options-trailer.tmpl [changed mode: 0755->0644]
templates/es/subscription-added.tmpl [changed mode: 0755->0644]
templates/es/subscription-canceled.tmpl [changed mode: 0755->0644]
templates/es/test-page.tmpl [changed mode: 0755->0644]
templates/es/trailer.tmpl [changed mode: 0755->0644]
templates/es/users.tmpl [changed mode: 0755->0644]
templates/it/add-class.tmpl [changed mode: 0755->0644]
templates/it/add-printer.tmpl [changed mode: 0755->0644]
templates/it/add-rss-subscription.tmpl [changed mode: 0755->0644]
templates/it/admin.tmpl [changed mode: 0755->0644]
templates/it/choose-device.tmpl [changed mode: 0755->0644]
templates/it/choose-make.tmpl [changed mode: 0755->0644]
templates/it/choose-model.tmpl [changed mode: 0755->0644]
templates/it/choose-serial.tmpl [changed mode: 0755->0644]
templates/it/choose-uri.tmpl [changed mode: 0755->0644]
templates/it/class-added.tmpl [changed mode: 0755->0644]
templates/it/class-confirm.tmpl [changed mode: 0755->0644]
templates/it/class-deleted.tmpl [changed mode: 0755->0644]
templates/it/class-jobs-header.tmpl [changed mode: 0755->0644]
templates/it/class-modified.tmpl [changed mode: 0755->0644]
templates/it/class.tmpl [changed mode: 0755->0644]
templates/it/classes-header.tmpl [changed mode: 0755->0644]
templates/it/classes.tmpl [changed mode: 0755->0644]
templates/it/command.tmpl [changed mode: 0755->0644]
templates/it/edit-config.tmpl [changed mode: 0755->0644]
templates/it/error-op.tmpl [changed mode: 0755->0644]
templates/it/error.tmpl [changed mode: 0755->0644]
templates/it/help-header.tmpl [changed mode: 0755->0644]
templates/it/help-printable.tmpl [changed mode: 0755->0644]
templates/it/help-trailer.tmpl [changed mode: 0755->0644]
templates/it/job-cancel.tmpl [changed mode: 0755->0644]
templates/it/job-hold.tmpl [changed mode: 0755->0644]
templates/it/job-move.tmpl [changed mode: 0755->0644]
templates/it/job-moved.tmpl [changed mode: 0755->0644]
templates/it/job-release.tmpl [changed mode: 0755->0644]
templates/it/job-restart.tmpl [changed mode: 0755->0644]
templates/it/jobs-header.tmpl [changed mode: 0755->0644]
templates/it/jobs.tmpl [changed mode: 0755->0644]
templates/it/list-available-printers.tmpl [changed mode: 0755->0644]
templates/it/modify-class.tmpl [changed mode: 0755->0644]
templates/it/modify-printer.tmpl [changed mode: 0755->0644]
templates/it/norestart.tmpl [changed mode: 0755->0644]
templates/it/option-boolean.tmpl [changed mode: 0755->0644]
templates/it/option-conflict.tmpl [changed mode: 0755->0644]
templates/it/option-header.tmpl [changed mode: 0755->0644]
templates/it/option-pickmany.tmpl [changed mode: 0755->0644]
templates/it/option-pickone.tmpl [changed mode: 0755->0644]
templates/it/option-trailer.tmpl [changed mode: 0755->0644]
templates/it/pager.tmpl [changed mode: 0755->0644]
templates/it/printer-accept.tmpl [changed mode: 0755->0644]
templates/it/printer-added.tmpl [changed mode: 0755->0644]
templates/it/printer-configured.tmpl [changed mode: 0755->0644]
templates/it/printer-confirm.tmpl [changed mode: 0755->0644]
templates/it/printer-default.tmpl [changed mode: 0755->0644]
templates/it/printer-deleted.tmpl [changed mode: 0755->0644]
templates/it/printer-jobs-header.tmpl [changed mode: 0755->0644]
templates/it/printer-modified.tmpl [changed mode: 0755->0644]
templates/it/printer-purge.tmpl [changed mode: 0755->0644]
templates/it/printer-reject.tmpl [changed mode: 0755->0644]
templates/it/printer-start.tmpl [changed mode: 0755->0644]
templates/it/printer-stop.tmpl [changed mode: 0755->0644]
templates/it/printer.tmpl [changed mode: 0755->0644]
templates/it/printers-header.tmpl [changed mode: 0755->0644]
templates/it/printers.tmpl [changed mode: 0755->0644]
templates/it/restart.tmpl [changed mode: 0755->0644]
templates/it/samba-export.tmpl [changed mode: 0755->0644]
templates/it/samba-exported.tmpl [changed mode: 0755->0644]
templates/it/search.tmpl [changed mode: 0755->0644]
templates/it/set-printer-options-header.tmpl [changed mode: 0755->0644]
templates/it/set-printer-options-trailer.tmpl [changed mode: 0755->0644]
templates/it/subscription-added.tmpl [changed mode: 0755->0644]
templates/it/subscription-canceled.tmpl [changed mode: 0755->0644]
templates/it/test-page.tmpl [changed mode: 0755->0644]
templates/it/trailer.tmpl [changed mode: 0755->0644]
templates/it/users.tmpl [changed mode: 0755->0644]
xcode/CUPS.xcodeproj/project.pbxproj

index 27538ef9e98f0fa65e5f07a828ab7c4602506bd4..1616409377172156aab1591a512f71a3ff8bc07a 100644 (file)
@@ -804,7 +804,8 @@ main(int  argc,                             /* I - Number of command-line args */
     {
       fprintf(stderr, "DEBUG: Printer responded with HTTP version %d.%d.\n",
               http->version / 100, http->version % 100);
-      fputs("STATE: +cups-ipp-conformance-failure-report\n", stderr);
+      fputs("STATE: +cups-ipp-conformance-failure-report,"
+            "cups-ipp-wrong-http-version\n", stderr);
     }
 
     supported  = cupsDoRequest(http, request, resource);
@@ -905,12 +906,17 @@ main(int  argc,                           /* I - Number of command-line args */
                                                IPP_TAG_BOOLEAN)) != NULL &&
          !printer_accepting->values[0].boolean)
         busy = 1;
-      else if ((printer_state = ippFindAttribute(supported,
-                                                 "printer-state-reasons",
-                                                IPP_TAG_KEYWORD)) != NULL)
+      else if (!printer_accepting)
+        fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-printer-is-accepting-jobs\n", stderr);
+        
+      if ((printer_state = ippFindAttribute(supported,
+                                           "printer-state-reasons",
+                                           IPP_TAG_KEYWORD)) != NULL && !busy)
       {
        for (i = 0; i < printer_state->num_values; i ++)
-         if (!strcmp(printer_state->values[0].string.text, "spool-area-full") ||
+         if (!strcmp(printer_state->values[0].string.text,
+                     "spool-area-full") ||
              !strncmp(printer_state->values[0].string.text, "spool-area-full-",
                       16))
          {
@@ -919,11 +925,8 @@ main(int  argc,                            /* I - Number of command-line args */
          }
       }
       else
-      {
-       fputs("DEBUG: printer-state-reasons not returned in "
-             "Get-Printer-Attributes response.\n", stderr);
-        fputs("STATE: +cups-ipp-conformance-failure-report\n", stderr);
-      }
+        fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-printer-state-reasons\n", stderr);
 
       if (busy)
       {
@@ -986,6 +989,38 @@ main(int  argc,                            /* I - Number of command-line args */
     if ((operations_sup = ippFindAttribute(supported, "operations-supported",
                                           IPP_TAG_ENUM)) != NULL)
     {
+      for (i = 0; i < operations_sup->num_values; i ++)
+        if (operations_sup->values[i].integer == IPP_PRINT_JOB)
+         break;
+
+      if (i >= operations_sup->num_values)
+       fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-print-job\n", stderr);
+
+      for (i = 0; i < operations_sup->num_values; i ++)
+        if (operations_sup->values[i].integer == IPP_CANCEL_JOB)
+         break;
+
+      if (i >= operations_sup->num_values)
+       fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-cancel-job\n", stderr);
+
+      for (i = 0; i < operations_sup->num_values; i ++)
+        if (operations_sup->values[i].integer == IPP_GET_JOB_ATTRIBUTES)
+         break;
+
+      if (i >= operations_sup->num_values)
+       fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-get-job-attributes\n", stderr);
+
+      for (i = 0; i < operations_sup->num_values; i ++)
+        if (operations_sup->values[i].integer == IPP_GET_PRINTER_ATTRIBUTES)
+         break;
+
+      if (i >= operations_sup->num_values)
+       fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-get-printer-attributes\n", stderr);
+
       for (i = 0; i < operations_sup->num_values; i ++)
         if (operations_sup->values[i].integer == IPP_VALIDATE_JOB)
        {
@@ -994,18 +1029,12 @@ main(int  argc,                          /* I - Number of command-line args */
        }
 
       if (!validate_job)
-      {
-        fputs("DEBUG: operations-supported does not list Validate-Job.\n",
-             stderr);
-       fputs("STATE: +cups-ipp-conformance-failure-report\n", stderr);
-      }
+       fputs("STATE: +cups-ipp-conformance-failure-report,"
+              "cups-ipp-missing-validate-job\n", stderr);
     }
     else
-    {
-      fputs("DEBUG: operations-supported not returned in "
-            "Get-Printer-Attributes response.\n", stderr);
-      fputs("STATE: +cups-ipp-conformance-failure-report\n", stderr);
-    }
+      fputs("STATE: +cups-ipp-conformance-failure-report,"
+           "cups-ipp-missing-operations-supported\n", stderr);
 
     doc_handling_sup = ippFindAttribute(supported,
                                        "multiple-document-handling-supported",
@@ -1228,9 +1257,8 @@ main(int  argc,                           /* I - Number of command-line args */
       * This is all too common...
       */
 
-      fputs("DEBUG: This printer does not implement the REQUIRED Validate-Job "
-            "operation.\n", stderr);
-      fputs("STATE: +cups-ipp-conformance-failure-report\n", stderr);
+      fputs("STATE: +cups-ipp-conformance-failure-report,"
+           "cups-ipp-missing-validate-job\n", stderr);
       break;
     }
     else if (ipp_status < IPP_REDIRECTION_OTHER_SITE)
@@ -1403,6 +1431,8 @@ main(int  argc,                           /* I - Number of command-line args */
     {
       _cupsLangPrintFilter(stderr, "INFO",
                           _("Print file accepted - job ID unknown."));
+      fputs("STATE: +cups-ipp-conformance-failure-report,"
+            "cups-ipp-missing-job-id\n", stderr);
       job_id = 0;
     }
     else
@@ -1554,6 +1584,8 @@ main(int  argc,                           /* I - Number of command-line args */
         * Job has gone away and/or the server has no job history...
        */
 
+       fputs("STATE: +cups-ipp-conformance-failure-report,"
+             "cups-ipp-missing-job-history\n", stderr);
         ippDelete(response);
 
        ipp_status = IPP_OK;
@@ -1634,9 +1666,8 @@ main(int  argc,                           /* I - Number of command-line args */
          * the job...
          */
 
-          fputs("DEBUG: job-state not returned in Get-Job-Attributes reponse - "
-               "stopping queue.\n", stderr);
-         fputs("STATE: +cups-ipp-conformance-failure-report\n", stderr);
+         fputs("STATE: +cups-ipp-conformance-failure-report,"
+               "cups-ipp-missing-job-state\n", stderr);
          ipp_status = IPP_INTERNAL_ERROR;
          break;
        }
@@ -2452,7 +2483,9 @@ report_printer_state(ipp_t *ipp,  /* I - IPP response */
   {
     reason = reasons->values[i].string.text;
 
-    if (strcmp(reason, "paused") &&
+    if (strcmp(reason, "none") &&
+       strcmp(reason, "none-report") &&
+       strcmp(reason, "paused") &&
        strcmp(reason, "com.apple.print.recoverable-warning"))
     {
       strlcpy(valptr, prefix, sizeof(value) - (valptr - value) - 1);
index 1727bfdb8a9d90aa5d613dfb2066402cb3b5fba4..85985c2dbda2b4ddbd3e309533e8cbba34e299ab 100644 (file)
@@ -110,6 +110,7 @@ HEADERS     =       \
                versioning.h
 
 HEADERSPRIV =  \
+               array-private.h \
                cups-private.h \
                debug-private.h \
                file-private.h \
diff --git a/cups/array-private.h b/cups/array-private.h
new file mode 100644 (file)
index 0000000..f6b24e3
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * "$Id$"
+ *
+ *   Private array definitions for CUPS.
+ *
+ *   Copyright 2011 by Apple Inc.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ */
+
+#ifndef _CUPS_ARRAY_PRIVATE_H_
+#  define _CUPS_ARRAY_PRIVATE_H_
+
+/*
+ * Include necessary headers...
+ */
+
+#  include "array.h"
+
+
+/*
+ * C++ magic...
+ */
+
+#  ifdef __cplusplus
+extern "C" {
+#  endif /* __cplusplus */
+
+
+/*
+ * Functions...
+ */
+
+extern int             _cupsArrayAddStrings(cups_array_t *a, const char *s)
+                                            _CUPS_API_1_5;
+extern cups_array_t    *_cupsArrayNewStrings(const char *s) _CUPS_API_1_5;
+
+#  ifdef __cplusplus
+}
+#  endif /* __cplusplus */
+#endif /* !_CUPS_ARRAY_PRIVATE_H_ */
+
+/*
+ * End of "$Id$".
+ */
index d51b8f8186c7a3dad914950b0d34f13a09d17611..1ffe14236ab2bd0284b47283862af4f40691e793 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Sorted array routines for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  *
  * Contents:
  *
- *   cupsArrayAdd()       - Add an element to the array.
- *   cupsArrayClear()     - Clear the array.
- *   cupsArrayCount()     - Get the number of elements in the array.
- *   cupsArrayCurrent()   - Return the current element in the array.
- *   cupsArrayDelete()    - Free all memory used by the array.
- *   cupsArrayDup()       - Duplicate the array.
- *   cupsArrayFind()      - Find an element in the array.
- *   cupsArrayFirst()     - Get the first element in the array.
- *   cupsArrayGetIndex()  - Get the index of the current element.
- *   cupsArrayGetInsert() - Get the index of the last inserted element.
- *   cupsArrayIndex()     - Get the N-th element in the array.
- *   cupsArrayInsert()    - Insert an element in the array.
- *   cupsArrayLast()      - Get the last element in the array.
- *   cupsArrayNew()       - Create a new array.
- *   cupsArrayNew2()      - Create a new array with hash.
- *   cupsArrayNew3()      - Create a new array with hash and/or free function.
- *   cupsArrayNext()      - Get the next element in the array.
- *   cupsArrayPrev()      - Get the previous element in the array.
- *   cupsArrayRemove()    - Remove an element from the array.
- *   cupsArrayRestore()   - Reset the current element to the last @link
- *                          cupsArraySave@.
- *   cupsArraySave()      - Mark the current element for a later @link
- *                          cupsArrayRestore@.
- *   cupsArrayUserData()  - Return the user data for an array.
- *   cups_array_add()     - Insert or append an element to the array...
- *   cups_array_find()    - Find an element in the array...
+ *   cupsArrayAdd()         - Add an element to the array.
+ *   _cupsArrayAddStrings() - Add zero or more comma-delimited strings to an
+ *                            array.
+ *   cupsArrayClear()       - Clear the array.
+ *   cupsArrayCount()       - Get the number of elements in the array.
+ *   cupsArrayCurrent()     - Return the current element in the array.
+ *   cupsArrayDelete()      - Free all memory used by the array.
+ *   cupsArrayDup()         - Duplicate the array.
+ *   cupsArrayFind()        - Find an element in the array.
+ *   cupsArrayFirst()       - Get the first element in the array.
+ *   cupsArrayGetIndex()    - Get the index of the current element.
+ *   cupsArrayGetInsert()   - Get the index of the last inserted element.
+ *   cupsArrayIndex()       - Get the N-th element in the array.
+ *   cupsArrayInsert()      - Insert an element in the array.
+ *   cupsArrayLast()        - Get the last element in the array.
+ *   cupsArrayNew()         - Create a new array.
+ *   cupsArrayNew2()        - Create a new array with hash.
+ *   cupsArrayNew3()        - Create a new array with hash and/or free function.
+ *   _cupsArrayNewStrings() - Create a new array of comma-delimited strings.
+ *   cupsArrayNext()        - Get the next element in the array.
+ *   cupsArrayPrev()        - Get the previous element in the array.
+ *   cupsArrayRemove()      - Remove an element from the array.
+ *   cupsArrayRestore()     - Reset the current element to the last @link
+ *                            cupsArraySave@.
+ *   cupsArraySave()        - Mark the current element for a later @link
+ *                            cupsArrayRestore@.
+ *   cupsArrayUserData()    - Return the user data for an array.
+ *   cups_array_add()       - Insert or append an element to the array.
+ *   cups_array_find()      - Find an element in the array.
  */
 
 /*
@@ -50,7 +53,7 @@
 
 #include "string-private.h"
 #include "debug-private.h"
-#include "array.h"
+#include "array-private.h"
 
 
 /*
@@ -134,6 +137,64 @@ cupsArrayAdd(cups_array_t *a,              /* I - Array */
 }
 
 
+/*
+ * '_cupsArrayAddStrings()' - Add zero or more comma-delimited strings to an
+ *                            array.
+ *
+ * Note: The array MUST be created using the @link _cupsArrayNewStrings@
+ * function. Duplicate strings are NOT added. If the string pointer "s" is NULL
+ * or the empty string, no strings are added to the array.
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+_cupsArrayAddStrings(cups_array_t *a,  /* I - Array */
+                     const char   *s)  /* I - Comma-delimited strings or NULL */
+{
+  char         *buffer,                /* Copy of string */
+               *start,                 /* Start of string */
+               *end;                   /* End of string */
+  int          status = 1;             /* Status of add */
+
+
+  if (!a || !s || !*s)
+    return (0);
+
+  if (!strchr(s, ','))
+  {
+   /*
+    * String doesn't contain a comma, so add it as a single value...
+    */
+
+    if (!cupsArrayFind(a, (void *)s))
+      status = cupsArrayAdd(a, (void *)s);
+  }
+  else if ((buffer = strdup(s)) == NULL)
+    status = 0;
+  else
+  {
+    for (start = end = buffer; *end; start = end)
+    {
+     /*
+      * Find the end of the current delimited string and see if we need to add
+      * it...
+      */
+
+      if ((end = strchr(start, ',')) != NULL)
+        *end++ = '\0';
+      else
+        end = start + strlen(start);
+
+      if (!cupsArrayFind(a, start))
+        status &= cupsArrayAdd(a, start);
+    }
+
+    free(buffer);
+  }
+
+  return (status);
+}
+
+
 /*
  * 'cupsArrayClear()' - Clear the array.
  *
@@ -712,6 +773,29 @@ cupsArrayNew3(cups_array_func_t  f,        /* I - Comparison function or @code NULL@ fo
 }
 
 
+/*
+ * '_cupsArrayNewStrings()' - Create a new array of comma-delimited strings.
+ *
+ * Note: The array automatically manages copies of the strings passed. If the
+ * string pointer "s" is NULL or the empty string, no strings are added to the
+ * newly created array.
+ */
+
+cups_array_t *                         /* O - Array */
+_cupsArrayNewStrings(const char *s)    /* I - Comma-delimited strings or NULL */
+{
+  cups_array_t *a;                     /* Array */
+
+
+  if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0,
+                         (cups_acopy_func_t)_cupsStrAlloc,
+                        (cups_afree_func_t)_cupsStrFree)) != NULL)
+    _cupsArrayAddStrings(a, s);
+
+  return (a);
+}
+
+
 /*
  * 'cupsArrayNext()' - Get the next element in the array.
  *
@@ -919,7 +1003,7 @@ cupsArrayUserData(cups_array_t *a) /* I - Array */
 
 
 /*
- * 'cups_array_add()' - Insert or append an element to the array...
+ * 'cups_array_add()' - Insert or append an element to the array.
  *
  * @since CUPS 1.2/Mac OS X 10.5@
  */
@@ -1100,7 +1184,7 @@ cups_array_add(cups_array_t *a,           /* I - Array */
 
 
 /*
- * 'cups_array_find()' - Find an element in the array...
+ * 'cups_array_find()' - Find an element in the array.
  */
 
 static int                             /* O - Index of match */
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index b211e0e411b08819d58eaf31f652d05dba5f675e..148ea9f2e4ad2b7e521fc35981cc1b496404e658 100644 (file)
@@ -479,7 +479,7 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
                                        /* Job title string */
                        copies[255],    /* # copies string */
                        *options,       /* Options string */
-                       *envp[MAX_ENV + 20],
+                       *envp[MAX_ENV + 21],
                                        /* Environment variables */
                        charset[255],   /* CHARSET env variable */
                        class_name[255],/* CLASS env variable */
@@ -505,6 +505,8 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
                                        /* PRINTER_LOCATION env variable */
                        printer_name[255],
                                        /* PRINTER env variable */
+                       *printer_state_reasons = NULL,
+                                       /* PRINTER_STATE_REASONS env var */
                        rip_max_cache[255];
                                        /* RIP_MAX_CACHE env variable */
 
@@ -878,6 +880,32 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
   snprintf(printer_location, sizeof(printer_name), "PRINTER_LOCATION=%s",
            job->printer->location ? job->printer->location : "");
   snprintf(printer_name, sizeof(printer_name), "PRINTER=%s", job->printer->name);
+  if (job->printer->num_reasons > 0)
+  {
+    char       *psrptr;                /* Pointer into PRINTER_STATE_REASONS */
+    size_t     psrlen;                 /* Size of PRINTER_STATE_REASONS */
+
+    for (psrlen = 22, i = 0; i < job->printer->num_reasons; i ++)
+      psrlen += strlen(job->printer->reasons[i]) + 1;
+
+    if ((printer_state_reasons = malloc(psrlen)) != NULL)
+    {
+     /*
+      * All of these strcpy's are safe because we allocated the psr string...
+      */
+
+      strcpy(printer_state_reasons, "PRINTER_STATE_REASONS=");
+      for (psrptr = printer_state_reasons + 22, i = 0;
+           i < job->printer->num_reasons;
+          i ++)
+      {
+        if (i)
+         *psrptr++ = ',';
+       strcpy(psrptr, job->printer->reasons[i]);
+       psrptr += strlen(psrptr);
+      }
+    }
+  }
   snprintf(rip_max_cache, sizeof(rip_max_cache), "RIP_MAX_CACHE=%s", RIPCache);
 
   if (job->printer->num_auth_info_required == 1)
@@ -920,6 +948,8 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
   envp[envc ++] = printer_info;
   envp[envc ++] = printer_location;
   envp[envc ++] = printer_name;
+  envp[envc ++] = printer_state_reasons ? printer_state_reasons :
+                                          "PRINTER_STATE_REASONS=none";
   envp[envc ++] = banner_page ? "CUPS_FILETYPE=job-sheet" :
                                 "CUPS_FILETYPE=document";
 
@@ -1187,6 +1217,8 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
   }
 
   free(argv);
+  if (printer_state_reasons)
+    free(printer_state_reasons);
 
   cupsdAddSelect(job->status_buffer->fd, (cupsd_selfunc_t)update_job, NULL,
                  job);
@@ -1223,6 +1255,9 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
     free(argv);
   }
 
+  if (printer_state_reasons)
+    free(printer_state_reasons);
+
   cupsdClosePipe(job->print_pipes);
   cupsdClosePipe(job->back_pipes);
   cupsdClosePipe(job->side_pipes);
index a08de399a233d787e31da07235c9ba5f86f92798..c107caaf2a7c7978908b4a8485c735768b736318 100644 (file)
@@ -160,51 +160,10 @@ cupsdCompareNames(const char *s,  /* I - First string */
 cups_array_t *                         /* O - CUPS array */
 cupsdCreateStringsArray(const char *s) /* I - Comma-delimited strings */
 {
-  cups_array_t *a;                     /* CUPS array */
-  const char   *start,                 /* Start of string */
-               *end;                   /* End of string */
-  char         buffer[8192];           /* New string */
-
-
-  if (!s)
+  if (!s || !*s)
     return (NULL);
-
-  if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL,
-                         (cups_ahash_func_t)NULL, 0,
-                        (cups_acopy_func_t)_cupsStrAlloc,
-                        (cups_afree_func_t)_cupsStrFree)) != NULL)
-  {
-    for (start = end = s; *end; start = end + 1)
-    {
-     /*
-      * Find the end of the current delimited string...
-      */
-
-      if ((end = strchr(start, ',')) == NULL)
-      {
-       /*
-        * Last delimited string...
-       */
-
-        cupsArrayAdd(a, (char *)start);
-       break;
-      }
-
-     /*
-      * Copy the string and add it to the array...
-      */
-
-      if ((end - start + 1) > sizeof(buffer))
-        break;
-
-      memcpy(buffer, start, end - start);
-      buffer[end - start] = '\0';
-
-      cupsArrayAdd(a, buffer);
-    }
-  }
-
-  return (a);
+  else
+    return (_cupsArrayNewStrings(s));
 }
 
 
index b58fd96e99289156ccb02c1aaefb1327e8b3344e..6c2a05acea55a6367e4f4f8e2718aac22bfe3cff 100644 (file)
@@ -20,6 +20,7 @@
  * Include necessary headers...
  */
 
+#  include <cups/array-private.h>
 #  include <cups/file-private.h>
 #  include <signal.h>
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4d7eee0024fe499ed9a6ce2dcbd0ce8c6704f9e1..c0373020830e1ea760a1990daa1f325733e740ba 100644 (file)
                72220FB913330BCE00FCA411 /* type.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220FB513330BCE00FCA411 /* type.c */; };
                72220FBA13330BEE00FCA411 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
                72220FBF13330C1000FCA411 /* libcupsmime.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220FAC13330B2200FCA411 /* libcupsmime.dylib */; };
+               7234F4201378A16F00D3E9C9 /* array-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7234F41F1378A16F00D3E9C9 /* array-private.h */; };
                724379081333E4A5009631B9 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
                7243790D1333E4E3009631B9 /* ipp.c in Sources */ = {isa = PBXBuildFile; fileRef = 7243790A1333E4E3009631B9 /* ipp.c */; };
                7243790E1333E4E3009631B9 /* network.c in Sources */ = {isa = PBXBuildFile; fileRef = 7243790B1333E4E3009631B9 /* network.c */; };
                72220FB313330BCE00FCA411 /* mime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mime.c; path = ../scheduler/mime.c; sourceTree = "<group>"; };
                72220FB413330BCE00FCA411 /* mime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mime.h; path = ../scheduler/mime.h; sourceTree = "<group>"; };
                72220FB513330BCE00FCA411 /* type.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = type.c; path = ../scheduler/type.c; sourceTree = "<group>"; };
+               7234F41F1378A16F00D3E9C9 /* array-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "array-private.h"; path = "../cups/array-private.h"; sourceTree = "<group>"; };
                724378FD1333E43E009631B9 /* ipp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ipp; sourceTree = BUILT_PRODUCTS_DIR; };
                724379091333E4E3009631B9 /* backend-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "backend-private.h"; path = "../backend/backend-private.h"; sourceTree = "<group>"; };
                7243790A1333E4E3009631B9 /* ipp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ipp.c; path = ../backend/ipp.c; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                72220F471333063D00FCA411 /* config.h */,
+                               7234F41F1378A16F00D3E9C9 /* array-private.h */,
                                72220EC01333056300FCA411 /* cups-private.h */,
                                72220EC31333056300FCA411 /* debug-private.h */,
                                72220ED7133305BB00FCA411 /* file-private.h */,
                                72220F3B133305BB00FCA411 /* string-private.h in Headers */,
                                72220F3E133305BB00FCA411 /* thread-private.h in Headers */,
                                72220F481333063D00FCA411 /* config.h in Headers */,
+                               7234F4201378A16F00D3E9C9 /* array-private.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };