]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
d09495fa | 2 | * "$Id: http.h 5889 2006-08-24 21:44:35Z mike $" |
ef416fc2 | 3 | * |
4 | * Hyper-Text Transport Protocol definitions for the Common UNIX Printing | |
5 | * System (CUPS). | |
6 | * | |
7 | * Copyright 1997-2006 by Easy Software Products, all rights reserved. | |
8 | * | |
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 | |
14 | * at: | |
15 | * | |
16 | * Attn: CUPS Licensing Information | |
17 | * Easy Software Products | |
18 | * 44141 Airport View Drive, Suite 204 | |
19 | * Hollywood, Maryland 20636 USA | |
20 | * | |
21 | * Voice: (301) 373-9600 | |
22 | * EMail: cups-info@cups.org | |
23 | * WWW: http://www.cups.org | |
24 | * | |
25 | * This file is subject to the Apple OS-Developed Software exception. | |
26 | */ | |
27 | ||
28 | #ifndef _CUPS_HTTP_H_ | |
29 | # define _CUPS_HTTP_H_ | |
30 | ||
31 | /* | |
32 | * Include necessary headers... | |
33 | */ | |
34 | ||
35 | # include <string.h> | |
36 | # include <time.h> | |
37 | # include <sys/types.h> | |
38 | # ifdef WIN32 | |
39 | # include <winsock2.h> | |
40 | # include <ws2tcpip.h> | |
41 | # else | |
d09495fa | 42 | # ifdef __sgi |
43 | # define INET6 /* IRIX IPv6 support... */ | |
e1d6a774 | 44 | # endif /* __sgi */ |
ef416fc2 | 45 | # include <unistd.h> |
46 | # include <sys/time.h> | |
47 | # include <sys/socket.h> | |
48 | # include <netdb.h> | |
49 | # include <netinet/in.h> | |
50 | # include <arpa/inet.h> | |
51 | # include <netinet/in_systm.h> | |
52 | # include <netinet/ip.h> | |
53 | # if !defined(__APPLE__) || !defined(TCP_NODELAY) | |
54 | # include <netinet/tcp.h> | |
55 | # endif /* !__APPLE__ || !TCP_NODELAY */ | |
d09495fa | 56 | # if defined(AF_UNIX) && !defined(AF_LOCAL) |
57 | # define AF_LOCAL AF_UNIX /* Older UNIX's have old names... */ | |
58 | # endif /* AF_UNIX && !AF_LOCAL */ | |
ef416fc2 | 59 | # ifdef AF_LOCAL |
60 | # include <sys/un.h> | |
61 | # endif /* AF_LOCAL */ | |
62 | # endif /* WIN32 */ | |
63 | ||
64 | # include "md5.h" | |
65 | ||
66 | /* | |
67 | * With GCC 3.0 and higher, we can mark old APIs "deprecated" so you get | |
fa73b229 | 68 | * a warning at compile-time. |
ef416fc2 | 69 | */ |
70 | ||
71 | # if defined(__GNUC__) && __GNUC__ > 2 | |
72 | # define _HTTP_DEPRECATED __attribute__ ((__deprecated__)) | |
73 | # else | |
74 | # define _HTTP_DEPRECATED | |
75 | # endif /* __GNUC__ && __GNUC__ > 2 */ | |
76 | ||
77 | ||
78 | /* | |
79 | * C++ magic... | |
80 | */ | |
81 | ||
82 | # ifdef __cplusplus | |
83 | extern "C" { | |
84 | # endif /* __cplusplus */ | |
85 | ||
86 | ||
87 | /* | |
88 | * Oh, the wonderful world of IPv6 compatibility. Apparently some | |
89 | * implementations expose the (more logical) 32-bit address parts | |
90 | * to everyone, while others only expose it to kernel code... To | |
91 | * make supporting IPv6 even easier, each vendor chose different | |
92 | * core structure and union names, so the same defines or code | |
93 | * can't be used on all platforms. | |
94 | * | |
95 | * The following will likely need tweaking on new platforms that | |
96 | * support IPv6 - the "s6_addr32" define maps to the 32-bit integer | |
97 | * array in the in6_addr union, which is named differently on various | |
98 | * platforms. | |
99 | */ | |
100 | ||
101 | #if defined(AF_INET6) && !defined(s6_addr32) | |
102 | # if defined(__sun) | |
103 | # define s6_addr32 _S6_un._S6_u32 | |
8ca02f3c | 104 | # elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) |
ef416fc2 | 105 | # define s6_addr32 __u6_addr.__u6_addr32 |
e1d6a774 | 106 | # elif defined(__osf__) |
107 | # define s6_addr32 s6_un.sa6_laddr | |
ef416fc2 | 108 | # elif defined(WIN32) |
109 | /* | |
110 | * Windows only defines byte and 16-bit word members of the union and | |
111 | * requires special casing of all raw address code... | |
112 | */ | |
113 | # define s6_addr32 error_need_win32_specific_code | |
114 | # endif /* __sun */ | |
115 | #endif /* AF_INET6 && !s6_addr32 */ | |
116 | ||
117 | ||
118 | /* | |
119 | * Limits... | |
120 | */ | |
121 | ||
122 | # define HTTP_MAX_URI 1024 /* Max length of URI string */ | |
123 | # define HTTP_MAX_HOST 256 /* Max length of hostname string */ | |
fa73b229 | 124 | # define HTTP_MAX_BUFFER 2048 /* Max length of data buffer */ |
ef416fc2 | 125 | # define HTTP_MAX_VALUE 256 /* Max header field value length */ |
126 | ||
127 | ||
128 | /* | |
129 | * Types and structures... | |
130 | */ | |
131 | ||
132 | typedef enum http_auth_e /**** HTTP authentication types ****/ | |
133 | { | |
134 | HTTP_AUTH_NONE, /* No authentication in use */ | |
135 | HTTP_AUTH_BASIC, /* Basic authentication in use */ | |
136 | HTTP_AUTH_MD5, /* Digest authentication in use */ | |
137 | HTTP_AUTH_MD5_SESS, /* MD5-session authentication in use */ | |
138 | HTTP_AUTH_MD5_INT, /* Digest authentication in use for body */ | |
139 | HTTP_AUTH_MD5_SESS_INT /* MD5-session authentication in use for body */ | |
140 | } http_auth_t; | |
141 | ||
142 | typedef enum http_encoding_e /**** HTTP transfer encoding values ****/ | |
143 | { | |
144 | HTTP_ENCODE_LENGTH, /* Data is sent with Content-Length */ | |
d09495fa | 145 | HTTP_ENCODE_CHUNKED, /* Data is chunked */ |
146 | HTTP_ENCODE_FIELDS /* Sending HTTP fields */ | |
ef416fc2 | 147 | } http_encoding_t; |
148 | ||
149 | typedef enum http_encryption_e /**** HTTP encryption values ****/ | |
150 | { | |
151 | HTTP_ENCRYPT_IF_REQUESTED, /* Encrypt if requested (TLS upgrade) */ | |
152 | HTTP_ENCRYPT_NEVER, /* Never encrypt */ | |
153 | HTTP_ENCRYPT_REQUIRED, /* Encryption is required (TLS upgrade) */ | |
154 | HTTP_ENCRYPT_ALWAYS /* Always encrypt (SSL) */ | |
155 | } http_encryption_t; | |
156 | ||
157 | typedef enum http_field_e /**** HTTP field names ****/ | |
158 | { | |
159 | HTTP_FIELD_UNKNOWN = -1, /* Unknown field */ | |
160 | HTTP_FIELD_ACCEPT_LANGUAGE, /* Accept-Language field */ | |
161 | HTTP_FIELD_ACCEPT_RANGES, /* Accept-Ranges field */ | |
162 | HTTP_FIELD_AUTHORIZATION, /* Authorization field */ | |
163 | HTTP_FIELD_CONNECTION, /* Connection field */ | |
164 | HTTP_FIELD_CONTENT_ENCODING, /* Content-Encoding field */ | |
165 | HTTP_FIELD_CONTENT_LANGUAGE, /* Content-Language field */ | |
166 | HTTP_FIELD_CONTENT_LENGTH, /* Content-Length field */ | |
167 | HTTP_FIELD_CONTENT_LOCATION, /* Content-Location field */ | |
168 | HTTP_FIELD_CONTENT_MD5, /* Content-MD5 field */ | |
169 | HTTP_FIELD_CONTENT_RANGE, /* Content-Range field */ | |
170 | HTTP_FIELD_CONTENT_TYPE, /* Content-Type field */ | |
171 | HTTP_FIELD_CONTENT_VERSION, /* Content-Version field */ | |
172 | HTTP_FIELD_DATE, /* Date field */ | |
173 | HTTP_FIELD_HOST, /* Host field */ | |
174 | HTTP_FIELD_IF_MODIFIED_SINCE, /* If-Modified-Since field */ | |
175 | HTTP_FIELD_IF_UNMODIFIED_SINCE, /* If-Unmodified-Since field */ | |
176 | HTTP_FIELD_KEEP_ALIVE, /* Keep-Alive field */ | |
177 | HTTP_FIELD_LAST_MODIFIED, /* Last-Modified field */ | |
178 | HTTP_FIELD_LINK, /* Link field */ | |
179 | HTTP_FIELD_LOCATION, /* Location field */ | |
180 | HTTP_FIELD_RANGE, /* Range field */ | |
181 | HTTP_FIELD_REFERER, /* Referer field */ | |
182 | HTTP_FIELD_RETRY_AFTER, /* Retry-After field */ | |
183 | HTTP_FIELD_TRANSFER_ENCODING, /* Transfer-Encoding field */ | |
184 | HTTP_FIELD_UPGRADE, /* Upgrade field */ | |
185 | HTTP_FIELD_USER_AGENT, /* User-Agent field */ | |
186 | HTTP_FIELD_WWW_AUTHENTICATE, /* WWW-Authenticate field */ | |
187 | HTTP_FIELD_MAX /* Maximum field index */ | |
188 | } http_field_t; | |
189 | ||
190 | typedef enum http_keepalive_e /**** HTTP keep-alive values ****/ | |
191 | { | |
192 | HTTP_KEEPALIVE_OFF = 0, /* No keep alive support */ | |
193 | HTTP_KEEPALIVE_ON /* Use keep alive */ | |
194 | } http_keepalive_t; | |
195 | ||
196 | typedef enum http_state_e /**** HTTP state values; states | |
197 | **** are server-oriented... | |
198 | ****/ | |
199 | { | |
200 | HTTP_WAITING, /* Waiting for command */ | |
201 | HTTP_OPTIONS, /* OPTIONS command, waiting for blank line */ | |
202 | HTTP_GET, /* GET command, waiting for blank line */ | |
203 | HTTP_GET_SEND, /* GET command, sending data */ | |
204 | HTTP_HEAD, /* HEAD command, waiting for blank line */ | |
205 | HTTP_POST, /* POST command, waiting for blank line */ | |
206 | HTTP_POST_RECV, /* POST command, receiving data */ | |
207 | HTTP_POST_SEND, /* POST command, sending data */ | |
208 | HTTP_PUT, /* PUT command, waiting for blank line */ | |
209 | HTTP_PUT_RECV, /* PUT command, receiving data */ | |
210 | HTTP_DELETE, /* DELETE command, waiting for blank line */ | |
211 | HTTP_TRACE, /* TRACE command, waiting for blank line */ | |
212 | HTTP_CLOSE, /* CLOSE command, waiting for blank line */ | |
213 | HTTP_STATUS /* Command complete, sending status */ | |
214 | } http_state_t; | |
215 | ||
216 | typedef enum http_status_e /**** HTTP status codes ****/ | |
217 | { | |
218 | HTTP_ERROR = -1, /* An error response from httpXxxx() */ | |
219 | ||
220 | HTTP_CONTINUE = 100, /* Everything OK, keep going... */ | |
221 | HTTP_SWITCHING_PROTOCOLS, /* HTTP upgrade to TLS/SSL */ | |
222 | ||
223 | HTTP_OK = 200, /* OPTIONS/GET/HEAD/POST/TRACE command was successful */ | |
224 | HTTP_CREATED, /* PUT command was successful */ | |
225 | HTTP_ACCEPTED, /* DELETE command was successful */ | |
226 | HTTP_NOT_AUTHORITATIVE, /* Information isn't authoritative */ | |
227 | HTTP_NO_CONTENT, /* Successful command, no new data */ | |
228 | HTTP_RESET_CONTENT, /* Content was reset/recreated */ | |
229 | HTTP_PARTIAL_CONTENT, /* Only a partial file was recieved/sent */ | |
230 | ||
231 | HTTP_MULTIPLE_CHOICES = 300, /* Multiple files match request */ | |
232 | HTTP_MOVED_PERMANENTLY, /* Document has moved permanently */ | |
233 | HTTP_MOVED_TEMPORARILY, /* Document has moved temporarily */ | |
234 | HTTP_SEE_OTHER, /* See this other link... */ | |
235 | HTTP_NOT_MODIFIED, /* File not modified */ | |
236 | HTTP_USE_PROXY, /* Must use a proxy to access this URI */ | |
237 | ||
238 | HTTP_BAD_REQUEST = 400, /* Bad request */ | |
239 | HTTP_UNAUTHORIZED, /* Unauthorized to access host */ | |
240 | HTTP_PAYMENT_REQUIRED, /* Payment required */ | |
241 | HTTP_FORBIDDEN, /* Forbidden to access this URI */ | |
242 | HTTP_NOT_FOUND, /* URI was not found */ | |
243 | HTTP_METHOD_NOT_ALLOWED, /* Method is not allowed */ | |
244 | HTTP_NOT_ACCEPTABLE, /* Not Acceptable */ | |
245 | HTTP_PROXY_AUTHENTICATION, /* Proxy Authentication is Required */ | |
246 | HTTP_REQUEST_TIMEOUT, /* Request timed out */ | |
247 | HTTP_CONFLICT, /* Request is self-conflicting */ | |
248 | HTTP_GONE, /* Server has gone away */ | |
249 | HTTP_LENGTH_REQUIRED, /* A content length or encoding is required */ | |
250 | HTTP_PRECONDITION, /* Precondition failed */ | |
251 | HTTP_REQUEST_TOO_LARGE, /* Request entity too large */ | |
252 | HTTP_URI_TOO_LONG, /* URI too long */ | |
253 | HTTP_UNSUPPORTED_MEDIATYPE, /* The requested media type is unsupported */ | |
b423cd4c | 254 | HTTP_REQUESTED_RANGE, /* The requested range is not satisfiable */ |
255 | HTTP_EXPECTATION_FAILED, /* The expectation given in an Expect header field was not met */ | |
ef416fc2 | 256 | HTTP_UPGRADE_REQUIRED = 426, /* Upgrade to SSL/TLS required */ |
257 | ||
258 | HTTP_SERVER_ERROR = 500, /* Internal server error */ | |
259 | HTTP_NOT_IMPLEMENTED, /* Feature not implemented */ | |
260 | HTTP_BAD_GATEWAY, /* Bad gateway */ | |
261 | HTTP_SERVICE_UNAVAILABLE, /* Service is unavailable */ | |
262 | HTTP_GATEWAY_TIMEOUT, /* Gateway connection timed out */ | |
263 | HTTP_NOT_SUPPORTED /* HTTP version not supported */ | |
264 | } http_status_t; | |
265 | ||
266 | typedef enum http_uri_status_e /**** URI separation status @since CUPS1.2@ ****/ | |
267 | { | |
268 | HTTP_URI_OVERFLOW = -8, /* URI buffer for httpAssembleURI is too small */ | |
269 | HTTP_URI_BAD_ARGUMENTS = -7, /* Bad arguments to function (error) */ | |
270 | HTTP_URI_BAD_RESOURCE = -6, /* Bad resource in URI (error) */ | |
271 | HTTP_URI_BAD_PORT = -5, /* Bad port number in URI (error) */ | |
272 | HTTP_URI_BAD_HOSTNAME = -4, /* Bad hostname in URI (error) */ | |
273 | HTTP_URI_BAD_USERNAME = -3, /* Bad username in URI (error) */ | |
274 | HTTP_URI_BAD_SCHEME = -2, /* Bad scheme in URI (error) */ | |
275 | HTTP_URI_BAD_URI = -1, /* Bad/empty URI (error) */ | |
276 | HTTP_URI_OK = 0, /* URI decoded OK */ | |
277 | HTTP_URI_MISSING_SCHEME, /* Missing scheme in URI (warning) */ | |
278 | HTTP_URI_UNKNOWN_SCHEME, /* Unknown scheme in URI (warning) */ | |
279 | HTTP_URI_MISSING_RESOURCE /* Missing resource in URI (warning) */ | |
280 | } http_uri_status_t; | |
281 | ||
a4d04587 | 282 | typedef enum http_uri_coding_e /**** URI en/decode flags ****/ |
283 | { | |
284 | HTTP_URI_CODING_NONE = 0, /* Don't en/decode anything */ | |
285 | HTTP_URI_CODING_USERNAME = 1, /* En/decode the username portion */ | |
286 | HTTP_URI_CODING_HOSTNAME = 2, /* En/decode the hostname portion */ | |
287 | HTTP_URI_CODING_RESOURCE = 4, /* En/decode the resource portion */ | |
288 | HTTP_URI_CODING_MOST = 7, /* En/decode all but the query */ | |
289 | HTTP_URI_CODING_QUERY = 8, /* En/decode the query portion */ | |
290 | HTTP_URI_CODING_ALL = 15 /* En/decode everything */ | |
291 | } http_uri_coding_t; | |
292 | ||
ef416fc2 | 293 | typedef enum http_version_e /**** HTTP version numbers ****/ |
294 | { | |
295 | HTTP_0_9 = 9, /* HTTP/0.9 */ | |
296 | HTTP_1_0 = 100, /* HTTP/1.0 */ | |
297 | HTTP_1_1 = 101 /* HTTP/1.1 */ | |
298 | } http_version_t; | |
299 | ||
ecdc0628 | 300 | typedef union _http_addr_u /**** Socket address union, which |
ef416fc2 | 301 | **** makes using IPv6 and other |
302 | **** address types easier and | |
303 | **** more portable. @since CUPS 1.2@ | |
304 | ****/ | |
305 | { | |
306 | struct sockaddr addr; /* Base structure for family value */ | |
307 | struct sockaddr_in ipv4; /* IPv4 address */ | |
308 | #ifdef AF_INET6 | |
309 | struct sockaddr_in6 ipv6; /* IPv6 address */ | |
310 | #endif /* AF_INET6 */ | |
311 | #ifdef AF_LOCAL | |
312 | struct sockaddr_un un; /* Domain socket file */ | |
313 | #endif /* AF_LOCAL */ | |
314 | char pad[256]; /* Padding to ensure binary compatibility */ | |
315 | } http_addr_t; | |
316 | ||
317 | typedef struct http_addrlist_s /**** Socket address list, which is | |
318 | **** used to enumerate all of the | |
319 | **** addresses that are associated | |
320 | **** with a hostname. @since CUPS 1.2@ | |
321 | ****/ | |
322 | { | |
323 | struct http_addrlist_s *next; /* Pointer to next address in list */ | |
324 | http_addr_t addr; /* Address */ | |
325 | } http_addrlist_t; | |
326 | ||
f7faf1f5 | 327 | typedef struct _http_s /**** HTTP connection structure. ****/ |
328 | { | |
329 | /* | |
330 | * DO NOT ACCESS MEMBERS OF THIS STRUCTURE DIRECTLY; INSTEAD, USE THE | |
331 | * PROVIDED APIS FOR ACCESSING THE VALUES INSTEAD. | |
332 | * | |
333 | * This structure definition will be removed from the public headers in | |
334 | * CUPS 1.3. | |
335 | */ | |
336 | ||
337 | int fd; /* File descriptor for this socket */ | |
338 | int blocking; /* To block or not to block */ | |
339 | int error; /* Last error on read */ | |
340 | time_t activity; /* Time since last read/write */ | |
341 | http_state_t state; /* State of client */ | |
342 | http_status_t status; /* Status of last request */ | |
343 | http_version_t version; /* Protocol version */ | |
344 | http_keepalive_t keep_alive; /* Keep-alive supported? */ | |
345 | struct sockaddr_in _hostaddr; /* Address of connected host @deprecated@ */ | |
346 | char hostname[HTTP_MAX_HOST], | |
347 | /* Name of connected host */ | |
348 | fields[HTTP_FIELD_MAX][HTTP_MAX_VALUE]; | |
349 | /* Field values */ | |
350 | char *data; /* Pointer to data buffer */ | |
351 | http_encoding_t data_encoding; /* Chunked or not */ | |
352 | int _data_remaining;/* Number of bytes left @deprecated@ */ | |
353 | int used; /* Number of bytes used in buffer */ | |
354 | char buffer[HTTP_MAX_BUFFER]; | |
355 | /* Buffer for incoming data */ | |
356 | int auth_type; /* Authentication in use */ | |
357 | _cups_md5_state_t md5_state; /* MD5 state */ | |
358 | char nonce[HTTP_MAX_VALUE]; | |
359 | /* Nonce value */ | |
360 | int nonce_count; /* Nonce count */ | |
361 | void *tls; /* TLS state information */ | |
362 | http_encryption_t encryption; /* Encryption requirements */ | |
363 | /**** New in CUPS 1.1.19 ****/ | |
364 | fd_set *input_set; /* select() set for httpWait() @since CUPS 1.1.19@ */ | |
365 | http_status_t expect; /* Expect: header @since CUPS 1.1.19@ */ | |
366 | char *cookie; /* Cookie value(s) @since CUPS 1.1.19@ */ | |
367 | /**** New in CUPS 1.1.20 ****/ | |
368 | char authstring[HTTP_MAX_VALUE], | |
369 | /* Current Authentication value @since CUPS 1.1.20@ */ | |
370 | userpass[HTTP_MAX_VALUE]; | |
371 | /* Username:password string @since CUPS 1.1.20@ */ | |
372 | int digest_tries; /* Number of tries for digest auth @since CUPS 1.1.20@ */ | |
373 | /**** New in CUPS 1.2 ****/ | |
374 | off_t data_remaining; /* Number of bytes left @since CUPS 1.2@ */ | |
375 | http_addr_t *hostaddr; /* Current host address and port @since CUPS 1.2@ */ | |
376 | http_addrlist_t *addrlist; /* List of valid addresses @since CUPS 1.2@ */ | |
377 | char wbuffer[HTTP_MAX_BUFFER]; | |
378 | /* Buffer for outgoing data */ | |
379 | int wused; /* Write buffer bytes used @since CUPS 1.2@ */ | |
380 | } http_t; | |
ef416fc2 | 381 | |
382 | ||
383 | /* | |
384 | * Prototypes... | |
385 | */ | |
386 | ||
ecdc0628 | 387 | extern void httpBlocking(http_t *http, int b); |
ef416fc2 | 388 | extern int httpCheck(http_t *http); |
ecdc0628 | 389 | extern void httpClearFields(http_t *http); |
ef416fc2 | 390 | extern void httpClose(http_t *http); |
391 | extern http_t *httpConnect(const char *host, int port); | |
392 | extern http_t *httpConnectEncrypt(const char *host, int port, | |
393 | http_encryption_t encryption); | |
394 | extern int httpDelete(http_t *http, const char *uri); | |
395 | extern int httpEncryption(http_t *http, http_encryption_t e); | |
ecdc0628 | 396 | extern int httpError(http_t *http); |
ef416fc2 | 397 | extern void httpFlush(http_t *http); |
398 | extern int httpGet(http_t *http, const char *uri); | |
399 | extern char *httpGets(char *line, int length, http_t *http); | |
400 | extern const char *httpGetDateString(time_t t); | |
401 | extern time_t httpGetDateTime(const char *s); | |
ecdc0628 | 402 | extern const char *httpGetField(http_t *http, http_field_t field); |
ef416fc2 | 403 | extern struct hostent *httpGetHostByName(const char *name); |
404 | extern char *httpGetSubField(http_t *http, http_field_t field, | |
405 | const char *name, char *value); | |
406 | extern int httpHead(http_t *http, const char *uri); | |
407 | extern void httpInitialize(void); | |
408 | extern int httpOptions(http_t *http, const char *uri); | |
409 | extern int httpPost(http_t *http, const char *uri); | |
410 | extern int httpPrintf(http_t *http, const char *format, ...) | |
411 | # ifdef __GNUC__ | |
412 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
413 | # endif /* __GNUC__ */ | |
414 | ; | |
415 | extern int httpPut(http_t *http, const char *uri); | |
a4d04587 | 416 | extern int httpRead(http_t *http, char *buffer, int length) _HTTP_DEPRECATED; |
ef416fc2 | 417 | extern int httpReconnect(http_t *http); |
418 | extern void httpSeparate(const char *uri, char *method, | |
419 | char *username, char *host, int *port, | |
420 | char *resource) _HTTP_DEPRECATED; | |
421 | extern void httpSetField(http_t *http, http_field_t field, | |
422 | const char *value); | |
423 | extern const char *httpStatus(http_status_t status); | |
424 | extern int httpTrace(http_t *http, const char *uri); | |
425 | extern http_status_t httpUpdate(http_t *http); | |
a4d04587 | 426 | extern int httpWrite(http_t *http, const char *buffer, int length) _HTTP_DEPRECATED; |
ef416fc2 | 427 | extern char *httpEncode64(char *out, const char *in) _HTTP_DEPRECATED; |
428 | extern char *httpDecode64(char *out, const char *in) _HTTP_DEPRECATED; | |
429 | extern int httpGetLength(http_t *http) _HTTP_DEPRECATED; | |
430 | extern char *httpMD5(const char *, const char *, const char *, | |
431 | char [33]); | |
432 | extern char *httpMD5Final(const char *, const char *, const char *, | |
433 | char [33]); | |
434 | extern char *httpMD5String(const unsigned char *, char [33]); | |
435 | ||
436 | /**** New in CUPS 1.1.19 ****/ | |
437 | extern void httpClearCookie(http_t *http); | |
ecdc0628 | 438 | extern const char *httpGetCookie(http_t *http); |
ef416fc2 | 439 | extern void httpSetCookie(http_t *http, const char *cookie); |
440 | extern int httpWait(http_t *http, int msec); | |
441 | ||
442 | /**** New in CUPS 1.1.21 ****/ | |
443 | extern char *httpDecode64_2(char *out, int *outlen, const char *in); | |
444 | extern char *httpEncode64_2(char *out, int outlen, const char *in, | |
445 | int inlen); | |
446 | extern void httpSeparate2(const char *uri, | |
447 | char *method, int methodlen, | |
448 | char *username, int usernamelen, | |
449 | char *host, int hostlen, int *port, | |
450 | char *resource, int resourcelen) _HTTP_DEPRECATED; | |
451 | ||
452 | /**** New in CUPS 1.2 ****/ | |
453 | extern int httpAddrAny(const http_addr_t *addr); | |
454 | extern http_addrlist_t *httpAddrConnect(http_addrlist_t *addrlist, int *sock); | |
455 | extern int httpAddrEqual(const http_addr_t *addr1, | |
456 | const http_addr_t *addr2); | |
457 | extern void httpAddrFreeList(http_addrlist_t *addrlist); | |
458 | extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, | |
459 | const char *service); | |
460 | extern int httpAddrLength(const http_addr_t *addr); | |
461 | extern int httpAddrLocalhost(const http_addr_t *addr); | |
462 | extern char *httpAddrLookup(const http_addr_t *addr, | |
463 | char *name, int namelen); | |
464 | extern char *httpAddrString(const http_addr_t *addr, | |
465 | char *s, int slen); | |
a4d04587 | 466 | extern http_uri_status_t httpAssembleURI(http_uri_coding_t encoding, |
467 | char *uri, int urilen, | |
ef416fc2 | 468 | const char *scheme, |
469 | const char *username, | |
470 | const char *host, int port, | |
471 | const char *resource); | |
a4d04587 | 472 | extern http_uri_status_t httpAssembleURIf(http_uri_coding_t encoding, |
473 | char *uri, int urilen, | |
ef416fc2 | 474 | const char *scheme, |
475 | const char *username, | |
476 | const char *host, int port, | |
477 | const char *resourcef, ...); | |
478 | extern int httpFlushWrite(http_t *http); | |
ecdc0628 | 479 | extern int httpGetBlocking(http_t *http); |
ef416fc2 | 480 | extern const char *httpGetDateString2(time_t t, char *s, int slen); |
ecdc0628 | 481 | extern int httpGetFd(http_t *http); |
757d2cad | 482 | extern const char *httpGetHostname(http_t *http, char *s, int slen); |
ef416fc2 | 483 | extern off_t httpGetLength2(http_t *http); |
ecdc0628 | 484 | extern http_status_t httpGetStatus(http_t *http); |
ef416fc2 | 485 | extern char *httpGetSubField2(http_t *http, http_field_t field, |
486 | const char *name, char *value, | |
487 | int valuelen); | |
a4d04587 | 488 | extern ssize_t httpRead2(http_t *http, char *buffer, size_t length); |
489 | extern http_uri_status_t httpSeparateURI(http_uri_coding_t decoding, | |
490 | const char *uri, | |
ef416fc2 | 491 | char *scheme, int schemelen, |
492 | char *username, int usernamelen, | |
493 | char *host, int hostlen, int *port, | |
494 | char *resource, int resourcelen); | |
b423cd4c | 495 | extern void httpSetExpect(http_t *http, http_status_t expect); |
ef416fc2 | 496 | extern void httpSetLength(http_t *http, size_t length); |
a4d04587 | 497 | extern ssize_t httpWrite2(http_t *http, const char *buffer, |
498 | size_t length); | |
ef416fc2 | 499 | |
500 | ||
501 | /* | |
502 | * C++ magic... | |
503 | */ | |
504 | ||
505 | # ifdef __cplusplus | |
506 | } | |
507 | # endif /* __cplusplus */ | |
508 | #endif /* !_CUPS_HTTP_H_ */ | |
509 | ||
510 | /* | |
d09495fa | 511 | * End of "$Id: http.h 5889 2006-08-24 21:44:35Z mike $". |
ef416fc2 | 512 | */ |