]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/encode.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / encode.c
index 47a6e50ddc9700b151dc7fe63fbd1936719a53f4..c1835980109cee7b1c7fcd3d6bb31484211d15a1 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id$"
+ * "$Id: encode.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   Option encoding routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2006 by Easy Software Products.
+ *   Copyright 2007 by Apple Inc.
+ *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   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.
  *
@@ -28,6 +19,7 @@
  *   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 LIST MUST BE SORTED ****
  */
 
-typedef struct
-{
-  const char   *name;
-  ipp_tag_t    value_tag;
-  ipp_tag_t    group_tag;
-} _ipp_option_t;
-
 static const _ipp_option_t ipp_options[] =
 {
+  { "auth-info",               IPP_TAG_TEXT,           IPP_TAG_JOB },
+  { "auth-info-required",      IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { "blackplot",               IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
   { "blackplot-default",       IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
   { "brightness",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
@@ -90,10 +77,11 @@ static const _ipp_option_t ipp_options[] =
   { "notify-charset",          IPP_TAG_CHARSET,        IPP_TAG_SUBSCRIPTION },
   { "notify-events",           IPP_TAG_KEYWORD,        IPP_TAG_SUBSCRIPTION },
   { "notify-events-default",   IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
-  { "notify-lease-time",       IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
+  { "notify-lease-duration",   IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
+  { "notify-lease-duration-default", IPP_TAG_INTEGER,  IPP_TAG_PRINTER },
   { "notify-natural-language", IPP_TAG_LANGUAGE,       IPP_TAG_SUBSCRIPTION },
   { "notify-pull-method",      IPP_TAG_KEYWORD,        IPP_TAG_SUBSCRIPTION },
-  { "notify-recipient",                IPP_TAG_URI,            IPP_TAG_SUBSCRIPTION },
+  { "notify-recipient-uri",    IPP_TAG_URI,            IPP_TAG_SUBSCRIPTION },
   { "notify-time-interval",    IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
   { "notify-user-data",                IPP_TAG_STRING,         IPP_TAG_SUBSCRIPTION },
   { "number-up",               IPP_TAG_INTEGER,        IPP_TAG_JOB },
@@ -116,10 +104,13 @@ static const _ipp_option_t ipp_options[] =
   { "ppi-default",             IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { "prettyprint",             IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
   { "prettyprint-default",     IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { "print-quality",           IPP_TAG_ENUM,           IPP_TAG_JOB },
+  { "print-quality-default",   IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { "printer-error-policy",    IPP_TAG_NAME,           IPP_TAG_PRINTER },
   { "printer-info",            IPP_TAG_TEXT,           IPP_TAG_PRINTER },
   { "printer-is-accepting-jobs",IPP_TAG_BOOLEAN,       IPP_TAG_PRINTER },
   { "printer-is-shared",       IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { "printer-location",                IPP_TAG_TEXT,           IPP_TAG_PRINTER },
   { "printer-make-and-model",  IPP_TAG_TEXT,           IPP_TAG_PRINTER },
   { "printer-more-info",       IPP_TAG_URI,            IPP_TAG_PRINTER },
   { "printer-op-policy",       IPP_TAG_NAME,           IPP_TAG_PRINTER },
@@ -129,14 +120,12 @@ static const _ipp_option_t ipp_options[] =
   { "printer-state-reasons",   IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { "printer-type",            IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { "printer-uri",             IPP_TAG_URI,            IPP_TAG_OPERATION },
-  { "print-quality",           IPP_TAG_ENUM,           IPP_TAG_JOB },
-  { "print-quality-default",   IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { "queued-job-count",                IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { "raw",                     IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
-  { "resolution",              IPP_TAG_RESOLUTION,     IPP_TAG_JOB },
-  { "resolution-default",      IPP_TAG_RESOLUTION,     IPP_TAG_PRINTER },
   { "requesting-user-name-allowed",    IPP_TAG_NAME,   IPP_TAG_PRINTER },
   { "requesting-user-name-denied",     IPP_TAG_NAME,   IPP_TAG_PRINTER },
+  { "resolution",              IPP_TAG_RESOLUTION,     IPP_TAG_JOB },
+  { "resolution-default",      IPP_TAG_RESOLUTION,     IPP_TAG_PRINTER },
   { "saturation",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { "saturation-default",      IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { "scaling",                 IPP_TAG_INTEGER,        IPP_TAG_JOB },
@@ -245,8 +234,7 @@ cupsEncodeOptions2(
 
   for (i = num_options, option = options; i > 0; i --, option ++)
   {
-    _ipp_option_t      key,            /* Search key */
-                       *match;         /* Matching attribute */
+    _ipp_option_t      *match;         /* Matching attribute */
 
 
    /*
@@ -262,16 +250,7 @@ cupsEncodeOptions2(
     * Figure out the proper value and group tags for this option...
     */
 
-    key.name = option->name;
-    match    = (_ipp_option_t *)bsearch(&key, ipp_options,
-                                        sizeof(ipp_options) /
-                                           sizeof(ipp_options[0]),
-                                       sizeof(ipp_options[0]),
-                                       (int (*)(const void *,
-                                                const void *))
-                                           compare_ipp_options);
-
-    if (match)
+    if ((match = _ippFindOption(option->name)) != NULL)
     {
       if (match->group_tag != group_tag)
         continue;
@@ -283,7 +262,7 @@ cupsEncodeOptions2(
       int      namelen;                /* Length of name */
 
 
-      namelen = strlen(option->name);
+      namelen = (int)strlen(option->name);
 
       if (namelen < 9 || strcmp(option->name + namelen - 8, "-default"))
       {
@@ -518,7 +497,7 @@ cupsEncodeOptions2(
            * octet-string
            */
 
-            attr->values[j].unknown.length = strlen(val);
+            attr->values[j].unknown.length = (int)strlen(val);
            attr->values[j].unknown.data   = _cupsStrAlloc(val);
 
             DEBUG_printf(("cupsEncodeOptions2: Added octet-string value \"%s\"...\n",
@@ -548,6 +527,30 @@ cupsEncodeOptions2(
 }
 
 
+/*
+ * '_ippFindOption()' - Find the attribute information for an option.
+ */
+
+_ipp_option_t *                                /* O - Attribute information */
+_ippFindOption(const char *name)       /* I - Option/attribute name */
+{
+  _ipp_option_t        key;                    /* Search key */
+
+
+ /*
+  * Lookup the proper value and group tags for this option...
+  */
+
+  key.name = name;
+
+  return ((_ipp_option_t *)bsearch(&key, ipp_options,
+                                   sizeof(ipp_options) / sizeof(ipp_options[0]),
+                                  sizeof(ipp_options[0]),
+                                  (int (*)(const void *, const void *))
+                                      compare_ipp_options));
+}
+
+
 /*
  * 'compare_ipp_options()' - Compare two IPP options.
  */
@@ -561,5 +564,5 @@ compare_ipp_options(_ipp_option_t *a,       /* I - First option */
 
 
 /*
- * End of "$Id$".
+ * End of "$Id: encode.c 6649 2007-07-11 21:46:42Z mike $".
  */