/*
- * "$Id: ipp-support.c 5138 2006-02-21 10:49:06Z mike $"
+ * "$Id: ipp-support.c 7847 2008-08-19 04:22:14Z 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-2009 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.
*
* ippOpValue() - Return an operation id for the given name.
* ippPort() - Return the default IPP port number.
* ippSetPort() - Set the default port number.
+ * ippTagString() - Return the tag name corresponding to a tag value.
+ * ippTagValue() - Return the tag value corresponding to a tag name.
*/
/*
{
"CUPS-Get-Default",
"CUPS-Get-Printers",
- "CUPS-Add-Printer",
+ "CUPS-Add-Modify-Printer",
"CUPS-Delete-Printer",
"CUPS-Get-Classes",
- "CUPS-Add-Class",
+ "CUPS-Add-Modify-Class",
"CUPS-Delete-Class",
"CUPS-Accept-Jobs",
"CUPS-Reject-Jobs",
"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"
+ },
+ * const ipp_tag_names[] =
+ { /* Value/group tag names */
+ "zero", /* 0x00 */
+ "operation-attributes-tag",
+ /* 0x01 */
+ "job-attributes-tag", /* 0x02 */
+ "end-of-attributes-tag",
+ /* 0x03 */
+ "printer-attributes-tag",
+ /* 0x04 */
+ "unsupported-attributes-tag",
+ /* 0x05 */
+ "subscription-attributes-tag",
+ /* 0x06 */
+ "event-notification-attributes-tag",
+ /* 0x07 */
+ "unknown-08", /* 0x08 */
+ "unknown-09", /* 0x09 */
+ "unknown-0a", /* 0x0a */
+ "unknown-0b", /* 0x0b */
+ "unknown-0c", /* 0x0c */
+ "unknown-0d", /* 0x0d */
+ "unknown-0e", /* 0x0e */
+ "unknown-0f", /* 0x0f */
+ "unsupported", /* 0x10 */
+ "default", /* 0x11 */
+ "unknown", /* 0x12 */
+ "no-value", /* 0x13 */
+ "unknown-14", /* 0x14 */
+ "not-settable", /* 0x15 */
+ "delete-attribute", /* 0x16 */
+ "admin-define", /* 0x17 */
+ "unknown-18", /* 0x18 */
+ "unknown-19", /* 0x19 */
+ "unknown-1a", /* 0x1a */
+ "unknown-1b", /* 0x1b */
+ "unknown-1c", /* 0x1c */
+ "unknown-1d", /* 0x1d */
+ "unknown-1e", /* 0x1e */
+ "unknown-1f", /* 0x1f */
+ "unknown-20", /* 0x20 */
+ "integer", /* 0x21 */
+ "boolean", /* 0x22 */
+ "enum", /* 0x23 */
+ "unknown-24", /* 0x24 */
+ "unknown-25", /* 0x25 */
+ "unknown-26", /* 0x26 */
+ "unknown-27", /* 0x27 */
+ "unknown-28", /* 0x28 */
+ "unknown-29", /* 0x29 */
+ "unknown-2a", /* 0x2a */
+ "unknown-2b", /* 0x2b */
+ "unknown-2c", /* 0x2c */
+ "unknown-2d", /* 0x2d */
+ "unknown-2e", /* 0x2e */
+ "unknown-2f", /* 0x2f */
+ "octetString", /* 0x30 */
+ "dateTime", /* 0x31 */
+ "resolution", /* 0x32 */
+ "rangeOfInteger", /* 0x33 */
+ "begCollection", /* 0x34 */
+ "textWithLanguage", /* 0x35 */
+ "nameWithLanguage", /* 0x36 */
+ "endCollection", /* 0x37 */
+ "unknown-38", /* 0x38 */
+ "unknown-39", /* 0x39 */
+ "unknown-3a", /* 0x3a */
+ "unknown-3b", /* 0x3b */
+ "unknown-3c", /* 0x3c */
+ "unknown-3d", /* 0x3d */
+ "unknown-3e", /* 0x3e */
+ "unknown-3f", /* 0x3f */
+ "unknown-40", /* 0x40 */
+ "textWithoutLanguage",/* 0x41 */
+ "nameWithoutLanguage",/* 0x42 */
+ "unknown-43", /* 0x43 */
+ "keyword", /* 0x44 */
+ "uri", /* 0x45 */
+ "uriScheme", /* 0x46 */
+ "charset", /* 0x47 */
+ "naturalLanguage", /* 0x48 */
+ "mimeMediaType", /* 0x49 */
+ "memberAttrName" /* 0x4a */
};
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)
/*
* 'ippErrorValue()' - Return a status code for the given name.
*
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
*/
ipp_status_t /* O - IPP status code */
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));
/*
* 'ippOpString()' - Return a name for the given operation id.
*
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
*/
const char * /* O - Name */
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...
/*
* 'ippOpValue()' - Return an operation id for the given name.
*
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
*/
ipp_op_t /* O - Operation ID */
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);
+
+ if (!strcasecmp(name, "CUPS-Add-Printer"))
+ return (CUPS_ADD_MODIFY_PRINTER);
+
return ((ipp_op_t)-1);
}
int /* O - Port number */
ippPort(void)
{
- const char *ipp_port; /* IPP_PORT environment variable */
- struct servent *port; /* Port number info */
- int portnum; /* Port number */
_cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
+ DEBUG_puts("ippPort()");
+
if (!cg->ipp_port)
- {
- if ((ipp_port = getenv("IPP_PORT")) != NULL)
- portnum = atoi(ipp_port);
- else if ((port = getservbyname("ipp", NULL)) == NULL)
- portnum = CUPS_DEFAULT_IPP_PORT;
- else
- portnum = ntohs(port->s_port);
-
- if (portnum > 0)
- cg->ipp_port = portnum;
- }
+ _cupsSetDefaults();
+
+ DEBUG_printf(("1ippPort: Returning %d...", cg->ipp_port));
return (cg->ipp_port);
}
void
ippSetPort(int p) /* I - Port number to use */
{
+ DEBUG_printf(("ippSetPort(p=%d)", p));
+
_cupsGlobals()->ipp_port = p;
}
/*
- * End of "$Id: ipp-support.c 5138 2006-02-21 10:49:06Z mike $".
+ * 'ippTagString()' - Return the tag name corresponding to a tag value.
+ *
+ * The returned names are defined in RFC 2911 and 3382.
+ *
+ * @since CUPS 1.4/Mac OS X 10.6@
+ */
+
+const char * /* O - Tag name */
+ippTagString(ipp_tag_t tag) /* I - Tag value */
+{
+ tag &= IPP_TAG_MASK;
+
+ if (tag < (ipp_tag_t)(sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])))
+ return (ipp_tag_names[tag]);
+ else
+ return ("UNKNOWN");
+}
+
+
+/*
+ * 'ippTagValue()' - Return the tag value corresponding to a tag name.
+ *
+ * The tag names are defined in RFC 2911 and 3382.
+ *
+ * @since CUPS 1.4/Mac OS X 10.6@
+ */
+
+ipp_tag_t /* O - Tag value */
+ippTagValue(const char *name) /* I - Tag name */
+{
+ int i; /* Looping var */
+
+
+ for (i = 0; i < (sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])); i ++)
+ if (!strcasecmp(name, ipp_tag_names[i]))
+ return ((ipp_tag_t)i);
+
+ if (!strcasecmp(name, "operation"))
+ return (IPP_TAG_OPERATION);
+ else if (!strcasecmp(name, "job"))
+ return (IPP_TAG_JOB);
+ else if (!strcasecmp(name, "printer"))
+ return (IPP_TAG_PRINTER);
+ else if (!strcasecmp(name, "subscription"))
+ return (IPP_TAG_SUBSCRIPTION);
+ else if (!strcasecmp(name, "language"))
+ return (IPP_TAG_LANGUAGE);
+ else if (!strcasecmp(name, "mimetype"))
+ return (IPP_TAG_MIMETYPE);
+ else if (!strcasecmp(name, "name"))
+ return (IPP_TAG_NAME);
+ else if (!strcasecmp(name, "text"))
+ return (IPP_TAG_TEXT);
+ else
+ return (IPP_TAG_ZERO);
+}
+
+
+/*
+ * End of "$Id: ipp-support.c 7847 2008-08-19 04:22:14Z mike $".
*/