2 * "$Id: ipp-support.c,v 1.2.2.3 2003/01/24 20:45:12 mike Exp $"
4 * Internet Printing Protocol support functions for the Common UNIX
5 * Printing System (CUPS).
7 * Copyright 1997-2003 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Easy Software Products and are protected by Federal
11 * copyright law. Distribution and use rights are outlined in the file
12 * "LICENSE.txt" which should have been included with this file. If this
13 * file is missing or damaged please contact Easy Software Products
16 * Attn: CUPS Licensing Information
17 * Easy Software Products
18 * 44141 Airport View Drive, Suite 204
19 * Hollywood, Maryland 20636-3111 USA
21 * Voice: (301) 373-9603
22 * EMail: cups-info@cups.org
23 * WWW: http://www.cups.org
25 * This file is subject to the Apple OS-Developed Software exception.
29 * ippErrorString() - Return a textual message for the given error
31 * ippPort() - Return the default IPP port number.
32 * ippSetPort() - Set the default port number.
36 * Include necessary headers...
53 static int ipp_port
= 0;
57 * 'ippErrorString()' - Return a textual message for the given error message.
60 const char * /* O - Text string */
61 ippErrorString(ipp_status_t error
) /* I - Error status */
63 static char unknown
[255]; /* Unknown error statuses */
64 static const char * const status_oks
[] = /* "OK" status codes */
67 "successful-ok-ignored-or-substituted-attributes",
68 "successful-ok-conflicting-attributes",
69 "successful-ok-ignored-subscriptions",
70 "successful-ok-ignored-notifications",
71 "successful-ok-too-many-events",
72 "successful-ok-but-cancel-subscription"
74 * const status_400s
[] = /* Client errors */
76 "client-error-bad-request",
77 "client-error-forbidden",
78 "client-error-not-authenticated",
79 "client-error-not-authorized",
80 "client-error-not-possible",
81 "client-error-timeout",
82 "client-error-not-found",
84 "client-error-request-entity-too-large",
85 "client-error-request-value-too-long",
86 "client-error-document-format-not-supported",
87 "client-error-attributes-or-values-not-supported",
88 "client-error-uri-scheme-not-supported",
89 "client-error-charset-not-supported",
90 "client-error-conflicting-attributes",
91 "client-error-compression-not-supported",
92 "client-error-compression-error",
93 "client-error-document-format-error",
94 "client-error-document-access-error",
95 "client-error-attributes-not-settable",
96 "client-error-ignored-all-subscriptions",
97 "client-error-too-many-subscriptions",
98 "client-error-ignored-all-notifications",
99 "client-error-print-support-file-not-found"
101 * const status_500s
[] = /* Server errors */
103 "server-error-internal-error",
104 "server-error-operation-not-supported",
105 "server-error-service-unavailable",
106 "server-error-version-not-supported",
107 "server-error-device-error",
108 "server-error-temporary-error",
109 "server-error-not-accepting-jobs",
111 "server-error-job-canceled",
112 "server-error-multiple-document-jobs-not-supported",
113 "server-error-printer-is-deactivated"
118 * See if the error code is a known value...
121 if (error
>= IPP_OK
&& error
<= IPP_OK_BUT_CANCEL_SUBSCRIPTION
)
122 return (status_oks
[error
]);
123 else if (error
== IPP_REDIRECTION_OTHER_SITE
)
124 return ("redirection-other-site");
125 else if (error
>= IPP_BAD_REQUEST
&& error
<= IPP_PRINT_SUPPORT_FILE_NOT_FOUND
)
126 return (status_400s
[error
- IPP_BAD_REQUEST
]);
127 else if (error
>= IPP_INTERNAL_ERROR
&& error
<= IPP_PRINTER_IS_DEACTIVATED
)
128 return (status_500s
[error
- IPP_INTERNAL_ERROR
]);
131 * No, build an "unknown-xxxx" error string...
134 sprintf(unknown
, "unknown-%04x", error
);
141 * 'ippPort()' - Return the default IPP port number.
144 int /* O - Port number */
147 const char *server_port
; /* SERVER_PORT environment variable */
148 struct servent
*port
; /* Port number info */
153 else if ((server_port
= getenv("IPP_PORT")) != NULL
)
154 return (ipp_port
= atoi(server_port
));
155 else if ((port
= getservbyname("ipp", NULL
)) == NULL
)
156 return (ipp_port
= CUPS_DEFAULT_IPP_PORT
);
158 return (ipp_port
= ntohs(port
->s_port
));
163 * 'ippSetPort()' - Set the default port number.
167 ippSetPort(int p
) /* I - Port number to use */
174 * End of "$Id: ipp-support.c,v 1.2.2.3 2003/01/24 20:45:12 mike Exp $".