]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/encode.c
Support many new attributes and fix some IPP conformance issues (STR #4630)
[thirdparty/cups.git] / cups / encode.c
index 224221c761226e849aa8c97fd15faebc82691d2e..7640ec1055eb9444b99e6fe6eee4246acb226d63 100644 (file)
@@ -1,26 +1,18 @@
 /*
- * "$Id: encode.c 7696 2008-06-26 00:54:42Z mike $"
+ * "$Id$"
  *
- *   Option encoding routines for CUPS.
+ * Option encoding routines for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2015 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
  *
- *   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/".
+ * 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.
- *
- * Contents:
- *
- *   cupsEncodeOptions()   - Encode printer options into IPP attributes.
- *   cupsEncodeOptions2()  - Encode printer options into IPP attributes for
- *                           a group.
- *   _ippFindOption()      - Find the attribute information for an option.
- *   compare_ipp_options() - Compare two IPP options.
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
 
 static const ipp_op_t ipp_job_creation[] =
 {
-  IPP_PRINT_JOB,
-  IPP_PRINT_URI,
-  IPP_CREATE_JOB,
+  IPP_OP_PRINT_JOB,
+  IPP_OP_PRINT_URI,
+  IPP_OP_VALIDATE_JOB,
+  IPP_OP_CREATE_JOB,
+  IPP_OP_HOLD_JOB,
+  IPP_OP_SET_JOB_ATTRIBUTES,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t ipp_doc_creation[] =
 {
-  IPP_PRINT_JOB,
-  IPP_PRINT_URI,
-  IPP_SEND_DOCUMENT,
-  IPP_SEND_URI,
+  IPP_OP_PRINT_JOB,
+  IPP_OP_PRINT_URI,
+  IPP_OP_SEND_DOCUMENT,
+  IPP_OP_SEND_URI,
+  IPP_OP_SET_JOB_ATTRIBUTES,
+  IPP_OP_SET_DOCUMENT_ATTRIBUTES,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t ipp_sub_creation[] =
 {
-  IPP_PRINT_JOB,
-  IPP_PRINT_URI,
-  IPP_CREATE_JOB,
-  IPP_CREATE_PRINTER_SUBSCRIPTION,
-  IPP_CREATE_JOB_SUBSCRIPTION,
+  IPP_OP_PRINT_JOB,
+  IPP_OP_PRINT_URI,
+  IPP_OP_CREATE_JOB,
+  IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS,
+  IPP_OP_CREATE_JOB_SUBSCRIPTIONS,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t ipp_all_print[] =
 {
-  IPP_PRINT_JOB,
-  IPP_PRINT_URI,
-  IPP_CREATE_JOB,
-  IPP_SEND_DOCUMENT,
-  IPP_SEND_URI,
-  IPP_OP_CUPS_NONE
-};
-
-static const ipp_op_t ipp_all_limit[] =
-{
-  IPP_GET_JOBS,
-  IPP_GET_PRINTER_ATTRIBUTES,
-  CUPS_GET_PRINTERS,
-  CUPS_GET_CLASSES,
-  CUPS_GET_DEVICES,
-  CUPS_GET_PPDS,
+  IPP_OP_PRINT_JOB,
+  IPP_OP_PRINT_URI,
+  IPP_OP_VALIDATE_JOB,
+  IPP_OP_CREATE_JOB,
+  IPP_OP_SEND_DOCUMENT,
+  IPP_OP_SEND_URI,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t ipp_set_printer[] =
 {
-  IPP_SET_PRINTER_ATTRIBUTES,
-  CUPS_ADD_MODIFY_PRINTER,
-  CUPS_ADD_MODIFY_CLASS,
-  IPP_OP_CUPS_NONE
-};
-
-static const ipp_op_t cups_am_class[] =
-{
-  CUPS_ADD_MODIFY_CLASS,
-  IPP_OP_CUPS_NONE
-};
-
-static const ipp_op_t cups_am_printer[] =
-{
-  CUPS_ADD_MODIFY_PRINTER,
+  IPP_OP_SET_PRINTER_ATTRIBUTES,
+  IPP_OP_CUPS_ADD_MODIFY_PRINTER,
+  IPP_OP_CUPS_ADD_MODIFY_CLASS,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t cups_schemes[] =
 {
-  CUPS_GET_DEVICES,
-  CUPS_GET_PPDS,
+  IPP_OP_CUPS_GET_DEVICES,
+  IPP_OP_CUPS_GET_PPDS,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t cups_get_ppds[] =
 {
-  CUPS_GET_PPDS,
+  IPP_OP_CUPS_GET_PPDS,
   IPP_OP_CUPS_NONE
 };
 
 static const ipp_op_t cups_ppd_name[] =
 {
-  CUPS_ADD_MODIFY_PRINTER,
-  CUPS_GET_PPD,
+  IPP_OP_CUPS_ADD_MODIFY_PRINTER,
+  IPP_OP_CUPS_GET_PPD,
   IPP_OP_CUPS_NONE
 };
 
@@ -176,6 +151,8 @@ static const _ipp_option_t ipp_options[] =
   { 0, "job-accounting-user-id", IPP_TAG_NAME,          IPP_TAG_JOB },
   { 0, "job-accounting-user-id-default", IPP_TAG_NAME,  IPP_TAG_PRINTER },
   { 0, "job-authorization-uri",        IPP_TAG_URI,            IPP_TAG_OPERATION },
+  { 0, "job-cancel-after",     IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "job-cancel-after-default", IPP_TAG_INTEGER,    IPP_TAG_PRINTER },
   { 0, "job-hold-until",       IPP_TAG_KEYWORD,        IPP_TAG_JOB },
   { 0, "job-id",               IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
   { 0, "job-impressions",      IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
@@ -297,6 +274,7 @@ static const _ipp_option_t ipp_options[] =
   { 0, "print-quality-default",        IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { 1, "printer-commands",     IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 0, "printer-error-policy", IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 0, "printer-geo-location", IPP_TAG_URI,            IPP_TAG_PRINTER },
   { 0, "printer-info",         IPP_TAG_TEXT,           IPP_TAG_PRINTER },
   { 0, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN,   IPP_TAG_PRINTER },
   { 0, "printer-is-shared",    IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
@@ -423,8 +401,8 @@ cupsEncodeOptions2(
   op = ippGetOperation(ipp);
 
   if (group_tag == IPP_TAG_OPERATION &&
-      (op == IPP_PRINT_JOB || op == IPP_PRINT_URI ||
-       op == IPP_SEND_DOCUMENT || op == IPP_SEND_URI))
+      (op == IPP_OP_PRINT_JOB || op == IPP_OP_PRINT_URI ||
+       op == IPP_OP_SEND_DOCUMENT || op == IPP_OP_SEND_URI))
   {
    /*
     * Handle the document format stuff first...
@@ -534,7 +512,7 @@ cupsEncodeOptions2(
       else
         ops ++;
 
-    if (*ops == IPP_OP_CUPS_NONE)
+    if (*ops == IPP_OP_CUPS_NONE && op != IPP_OP_CUPS_NONE)
     {
       DEBUG_printf(("2cupsEncodeOptions2: Skipping \"%s\".", option->name));
       continue;
@@ -672,7 +650,7 @@ cupsEncodeOptions2(
            * Integer/enumeration value...
            */
 
-            attr->values[j].integer = strtol(val, &s, 10);
+            attr->values[j].integer = (int)strtol(val, &s, 10);
 
             DEBUG_printf(("2cupsEncodeOptions2: Added integer option value "
                          "%d...", attr->values[j].integer));
@@ -714,12 +692,12 @@ cupsEncodeOptions2(
              s = val;
            }
            else
-             attr->values[j].range.lower = strtol(val, &s, 10);
+             attr->values[j].range.lower = (int)strtol(val, &s, 10);
 
            if (*s == '-')
            {
              if (s[1])
-               attr->values[j].range.upper = strtol(s + 1, NULL, 10);
+               attr->values[j].range.upper = (int)strtol(s + 1, NULL, 10);
              else
                attr->values[j].range.upper = 2147483647;
             }
@@ -736,10 +714,10 @@ cupsEncodeOptions2(
            * Resolution...
            */
 
-           attr->values[j].resolution.xres = strtol(val, &s, 10);
+           attr->values[j].resolution.xres = (int)strtol(val, &s, 10);
 
            if (*s == 'x')
-             attr->values[j].resolution.yres = strtol(s + 1, &s, 10);
+             attr->values[j].resolution.yres = (int)strtol(s + 1, &s, 10);
            else
              attr->values[j].resolution.yres = attr->values[j].resolution.xres;
 
@@ -872,5 +850,5 @@ compare_ipp_options(_ipp_option_t *a,       /* I - First option */
 
 
 /*
- * End of "$Id: encode.c 7696 2008-06-26 00:54:42Z mike $".
+ * End of "$Id$".
  */