]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/ipp-support.c
Import CUPS 1.4svn r7023 into easysw/current.
[thirdparty/cups.git] / cups / ipp-support.c
index e6111757710a27ed2572c6d0980cb830906f2fc7..eaf48500239a148b6ca55dcf65cfe90bda3ef722 100644 (file)
@@ -1,26 +1,17 @@
 /*
- * "$Id$"
+ * "$Id: ipp-support.c 6879 2007-08-29 20:26:50Z mike $"
  *
  *   Internet Printing Protocol support functions for the Common UNIX
  *   Printing System (CUPS).
  *
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ *   Copyright 2007 by Apple Inc.
+ *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   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.
  *
@@ -157,7 +148,12 @@ static char        * const ipp_std_ops[] =
                  "CUPS-Get-Devices",
                  "CUPS-Get-PPDs",
                  "CUPS-Move-Job",
-                 "CUPS-Authenticate-Job"
+                 "CUPS-Authenticate-Job",
+                 "CUPS-Get-PPD"
+               },
+               * const ipp_cups_ops2[] =
+               {
+                 "CUPS-Get-Document"
                };
 
 
@@ -179,6 +175,8 @@ ippErrorString(ipp_status_t error)  /* I - Error status */
     return (ipp_status_oks[error]);
   else if (error == IPP_REDIRECTION_OTHER_SITE)
     return ("redirection-other-site");
+  else if (error == CUPS_SEE_OTHER)
+    return ("cups-see-other");
   else if (error >= IPP_BAD_REQUEST && error <= IPP_PRINT_SUPPORT_FILE_NOT_FOUND)
     return (ipp_status_400s[error - IPP_BAD_REQUEST]);
   else if (error >= IPP_INTERNAL_ERROR && error <= IPP_PRINTER_IS_DEACTIVATED)
@@ -213,6 +211,9 @@ ippErrorValue(const char *name)             /* I - Name */
   if (!strcasecmp(name, "redirection-other-site"))
     return (IPP_REDIRECTION_OTHER_SITE);
 
+  if (!strcasecmp(name, "cups-see-other"))
+    return (CUPS_SEE_OTHER);
+
   for (i = 0; i < (sizeof(ipp_status_400s) / sizeof(ipp_status_400s[0])); i ++)
     if (!strcasecmp(name, ipp_status_400s[i]))
       return ((ipp_status_t)(i + 0x400));
@@ -245,8 +246,10 @@ ippOpString(ipp_op_t op)           /* I - Operation ID */
     return (ipp_std_ops[op]);
   else if (op == IPP_PRIVATE)
     return ("windows-ext");
-  else if (op >= CUPS_GET_DEFAULT && op <= CUPS_AUTHENTICATE_JOB)
+  else if (op >= CUPS_GET_DEFAULT && op <= CUPS_GET_PPD)
     return (ipp_cups_ops[op - CUPS_GET_DEFAULT]);
+  else if (op == CUPS_GET_DOCUMENT)
+    return (ipp_cups_ops2[0]);
 
  /*
   * No, build an "unknown-xxxx" operation string...
@@ -281,6 +284,10 @@ ippOpValue(const char *name)               /* I - Textual name */
     if (!strcasecmp(name, ipp_cups_ops[i]))
       return ((ipp_op_t)(i + 0x4001));
 
+  for (i = 0; i < (sizeof(ipp_cups_ops2) / sizeof(ipp_cups_ops2[0])); i ++)
+    if (!strcasecmp(name, ipp_cups_ops2[i]))
+      return ((ipp_op_t)(i + 0x4027));
+
   if (!strcasecmp(name, "CUPS-Add-Class"))
     return (CUPS_ADD_MODIFY_CLASS);
 
@@ -304,19 +311,48 @@ ippPort(void)
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
+  DEBUG_puts("ippPort()");
+
+  if (!cg->ipp_port)
+  {
+   /*
+    * See if the server definition includes the port number...
+    */
+
+    DEBUG_puts("ippPort: Not initialized...");
+
+    cupsServer();
+
+#ifdef DEBUG
+    if (cg->ipp_port)
+      puts("ippPort: Set via cupsServer()...");
+#endif /* DEBUG */
+  }
+
   if (!cg->ipp_port)
   {
     if ((ipp_port = getenv("IPP_PORT")) != NULL)
+    {
+      DEBUG_puts("ippPort: Set via IPP_PORT...");
       portnum = atoi(ipp_port);
+    }
     else if ((port = getservbyname("ipp", NULL)) == NULL)
+    {
+      DEBUG_puts("ippPort: Set via CUPS_DEFAULT_IPP_PORT...");
       portnum = CUPS_DEFAULT_IPP_PORT;
+    }
     else
+    {
+      DEBUG_puts("ippPort: Set via ipp service entry...");
       portnum = ntohs(port->s_port);
+    }
 
     if (portnum > 0)
       cg->ipp_port = portnum;
   }
 
+  DEBUG_printf(("ippPort: Returning %d...\n", cg->ipp_port));
+
   return (cg->ipp_port);
 }
 
@@ -328,10 +364,12 @@ ippPort(void)
 void
 ippSetPort(int p)                      /* I - Port number to use */
 {
+  DEBUG_printf(("ippSetPort(p=%d)\n", p));
+
   _cupsGlobals()->ipp_port = p;
 }
 
 
 /*
- * End of "$Id$".
+ * End of "$Id: ipp-support.c 6879 2007-08-29 20:26:50Z mike $".
  */