/*
- * "$Id: http-private.h 7850 2008-08-20 00:07:25Z mike $"
+ * "$Id$"
*
- * Private HTTP definitions for CUPS.
+ * Private HTTP definitions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * 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/".
+ * These coded instructions, statements, and computer programs are the
+ * 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.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_HTTP_PRIVATE_H_
*/
# include "config.h"
+# include <cups/language.h>
# include <stddef.h>
# include <stdlib.h>
# ifdef WIN32
# include <io.h>
# include <winsock2.h>
+# define CUPS_SOCAST (const char *)
# else
# include <unistd.h>
# include <fcntl.h>
# include <sys/socket.h>
-# define closesocket(f) close(f)
+# define CUPS_SOCAST
# endif /* WIN32 */
# ifdef HAVE_GSSAPI
# ifdef HAVE_GSS_GSSAPI_H
# include <GSS/gssapi.h>
-# ifdef HAVE_GSSAPI_GENERIC_H
-# include <GSS/gssapi_generic.h>
-# endif /* HAVE_GSSAPI_GENERIC_H */
-# ifdef HAVE_GSSAPI_KRB5_H
-# include <GSS/gssapi_krb5.h>
-# endif /* HAVE_GSSAPI_KRB5_H */
# elif defined(HAVE_GSSAPI_GSSAPI_H)
# include <gssapi/gssapi.h>
-# ifdef HAVE_GSSAPI_GENERIC_H
-# include <gssapi/gssapi_generic.h>
-# endif /* HAVE_GSSAPI_GENERIC_H */
-# ifdef HAVE_GSSAPI_KRB5_H
-# include <gssapi/gssapi_krb5.h>
-# endif /* HAVE_GSSAPI_KRB5_H */
# elif defined(HAVE_GSSAPI_H)
# include <gssapi.h>
# endif /* HAVE_GSS_GSSAPI_H */
# ifndef HAVE_GSS_C_NT_HOSTBASED_SERVICE
# define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
# endif /* !HAVE_GSS_C_NT_HOSTBASED_SERVICE */
-# ifdef HAVE_KRB5_H
-# include <krb5.h>
-# endif /* HAVE_KRB5_H */
# endif /* HAVE_GSSAPI */
# ifdef HAVE_AUTHORIZATION_H
# include <Security/Authorization.h>
# endif /* HAVE_AUTHORIZATION_H */
-# if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
+# if defined(__APPLE__) && !defined(_SOCKLEN_T)
/*
- * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
+ * MacOS X 10.2.x does not define socklen_t, and in fact uses an int instead of
* unsigned type for length values...
*/
typedef int socklen_t;
-# endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
+# endif /* __APPLE__ && !_SOCKLEN_T */
# include <cups/http.h>
# include "md5-private.h"
# endif /* HAVE_GETIFADDRS */
# endif /* !WIN32 */
+# ifdef HAVE_LIBZ
+# include <zlib.h>
+# endif /* HAVE_LIBZ */
+
/*
* C++ magic...
typedef SSL *http_tls_t;
typedef void *http_tls_credentials_t;
-extern BIO_METHOD *_httpBIOMethods(void);
+//extern BIO_METHOD *_httpBIOMethods(void);
# elif defined HAVE_GNUTLS
/*
typedef gnutls_session http_tls_t;
typedef void *http_tls_credentials_t;
-extern ssize_t _httpReadGNUTLS(gnutls_transport_ptr ptr, void *data,
- size_t length);
-extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data,
- size_t length);
+//extern ssize_t _httpReadGNUTLS(gnutls_transport_ptr ptr, void *data,
+// size_t length);
+//extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data,
+// size_t length);
# elif defined(HAVE_CDSASSL)
/*
typedef SSLContextRef http_tls_t;
typedef CFArrayRef http_tls_credentials_t;
-extern OSStatus _httpReadCDSA(SSLConnectionRef connection, void *data,
- size_t *dataLength);
-extern OSStatus _httpWriteCDSA(SSLConnectionRef connection, const void *data,
- size_t *dataLength);
-
# elif defined(HAVE_SSPISSL)
/*
* Windows' SSPI library gets a CUPS wrapper...
typedef void *http_tls_credentials_t;
# endif /* HAVE_LIBSSL */
-struct _http_s /**** HTTP connection structure. ****/
+typedef enum _http_coding_e /**** HTTP content coding enumeration ****/
+{
+ _HTTP_CODING_IDENTITY, /* No content coding */
+ _HTTP_CODING_GZIP, /* LZ77+gzip decompression */
+ _HTTP_CODING_DEFLATE, /* LZ77+zlib compression */
+ _HTTP_CODING_GUNZIP, /* LZ77+gzip decompression */
+ _HTTP_CODING_INFLATE /* LZ77+zlib decompression */
+} _http_coding_t;
+
+typedef enum _http_mode_e /**** HTTP mode enumeration ****/
+{
+ _HTTP_MODE_CLIENT, /* Client connected to server */
+ _HTTP_MODE_SERVER /* Server connected (accepted) from client */
+} _http_mode_t;
+
+# ifndef _HTTP_NO_PRIVATE
+struct _http_s /**** HTTP connection structure ****/
{
int fd; /* File descriptor for this socket */
int blocking; /* To block or not to block */
struct sockaddr_in _hostaddr; /* Address of connected host (deprecated) */
char hostname[HTTP_MAX_HOST],
/* Name of connected host */
- fields[HTTP_FIELD_MAX][HTTP_MAX_VALUE];
- /* Field values */
+ fields[HTTP_FIELD_ACCEPT_ENCODING][HTTP_MAX_VALUE];
+ /* Field values up to Accept-Encoding */
char *data; /* Pointer to data buffer */
http_encoding_t data_encoding; /* Chunked or not */
int _data_remaining;/* Number of bytes left (deprecated) */
int used; /* Number of bytes used in buffer */
char buffer[HTTP_MAX_BUFFER];
/* Buffer for incoming data */
- int auth_type; /* Authentication in use */
+ int _auth_type; /* Authentication in use (deprecated) */
_cups_md5_state_t md5_state; /* MD5 state */
char nonce[HTTP_MAX_VALUE];
/* Nonce value */
int nonce_count; /* Nonce count */
http_tls_t tls; /* TLS state information */
http_encryption_t encryption; /* Encryption requirements */
+
/**** New in CUPS 1.1.19 ****/
fd_set *input_set; /* select() set for httpWait() (deprecated) */
http_status_t expect; /* Expect: header */
char *cookie; /* Cookie value(s) */
+
/**** New in CUPS 1.1.20 ****/
char _authstring[HTTP_MAX_VALUE],
- /* Current Authentication value (deprecated) */
+ /* Current Authorization value (deprecated) */
userpass[HTTP_MAX_VALUE];
/* Username:password string */
int digest_tries; /* Number of tries for digest auth */
+
/**** New in CUPS 1.2 ****/
off_t data_remaining; /* Number of bytes left */
http_addr_t *hostaddr; /* Current host address and port */
char wbuffer[HTTP_MAX_BUFFER];
/* Buffer for outgoing data */
int wused; /* Write buffer bytes used */
+
/**** New in CUPS 1.3 ****/
char *field_authorization;
/* Authorization field */
- char *authstring; /* Current authorization field */
+ char *authstring; /* Current Authorization field */
# ifdef HAVE_GSSAPI
gss_OID gssmech; /* Authentication mechanism */
gss_ctx_id_t gssctx; /* Authentication context */
# ifdef HAVE_AUTHORIZATION_H
AuthorizationRef auth_ref; /* Authorization ref */
# endif /* HAVE_AUTHORIZATION_H */
+
/**** New in CUPS 1.5 ****/
http_tls_credentials_t tls_credentials;
/* TLS credentials */
# ifdef HAVE_GSSAPI
char gsshost[256]; /* Hostname for Kerberos */
# endif /* HAVE_GSSAPI */
+
+ /**** New in CUPS 1.7 ****/
+ int tls_upgrade; /* Non-zero if we are doing an upgrade */
+ _http_mode_t mode; /* _HTTP_MODE_CLIENT or _HTTP_MODE_SERVER */
+ char *accept_encoding,
+ /* Accept-Encoding field */
+ *allow, /* Allow field */
+ *server, /* Server field */
+ *default_accept_encoding,
+ *default_server,
+ *default_user_agent;
+ /* Default field values */
+# ifdef HAVE_LIBZ
+ _http_coding_t coding; /* _HTTP_CODING_xxx */
+ z_stream stream; /* (De)compression stream */
+ Bytef *dbuffer; /* Decompression buffer */
+# endif /* HAVE_LIBZ */
};
+# endif /* !_HTTP_NO_PRIVATE */
/*
* Prototypes...
*/
-#define _httpAddrFamily(addrp) (addrp)->addr.sa_family
-extern int _httpAddrPort(http_addr_t *addr);
extern void _httpAddrSetPort(http_addr_t *addr, int port);
-extern char *_httpAssembleUUID(const char *server, int port,
- const char *name, int number,
- char *buffer, size_t bufsize);
-extern http_t *_httpCreate(const char *host, int port,
- http_addrlist_t *addrlist,
- http_encryption_t encryption,
- int family);
extern http_tls_credentials_t
_httpCreateCredentials(cups_array_t *credentials);
extern char *_httpDecodeURI(char *dst, const char *src,
extern char *_httpEncodeURI(char *dst, const char *src,
size_t dstsize);
extern void _httpFreeCredentials(http_tls_credentials_t credentials);
-extern ssize_t _httpPeek(http_t *http, char *buffer, size_t length);
extern const char *_httpResolveURI(const char *uri, char *resolved_uri,
size_t resolved_size, int options,
int (*cb)(void *context),
void *context);
+extern const char *_httpStatus(cups_lang_t *lang, http_status_t status);
extern int _httpUpdate(http_t *http, http_status_t *status);
extern int _httpWait(http_t *http, int msec, int usessl);
#endif /* !_CUPS_HTTP_PRIVATE_H_ */
/*
- * End of "$Id: http-private.h 7850 2008-08-20 00:07:25Z mike $".
+ * End of "$Id$".
*/