From 4febe2382c89f06b68c203ffb3ec5da6cd8bd7d0 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 8 Jan 2013 14:22:22 +0000 Subject: [PATCH] Make httpAssembleURI public API. Some more cleanup for other functions that got promoted and for internal API that should never be called outside CUPS. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10783 7a7537e8-13f0-0310-91df-b6672ffda945 --- backend/ipp.c | 2 +- cups/http-addr.c | 1 - cups/http-private.h | 12 +++++-- cups/http-support.c | 30 +++++++++++----- cups/http.c | 1 - cups/http.h | 4 +++ cups/versioning.h | 85 +++++++++++++++++++++++++++++++++------------ 7 files changed, 97 insertions(+), 38 deletions(-) diff --git a/backend/ipp.c b/backend/ipp.c index c69ec07c9b..4fcedecee5 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -3,7 +3,7 @@ * * IPP backend for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * 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 diff --git a/cups/http-addr.c b/cups/http-addr.c index 7e8318f897..e3dba9e9ab 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -383,7 +383,6 @@ httpAddrPort(http_addr_t *addr) /* I - Address */ } /* For OS X 10.8 and earlier */ -extern int _httpAddrPort(http_addr_t *addr); int _httpAddrPort(http_addr_t *addr) { return (httpAddrPort(addr)); } diff --git a/cups/http-private.h b/cups/http-private.h index 606f5d1043..7e006e59c2 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -3,7 +3,7 @@ * * Private HTTP definitions for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * 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 @@ -393,14 +393,18 @@ extern void _cups_freeifaddrs(struct ifaddrs *addrs); */ #define _httpAddrFamily(addrp) (addrp)->addr.sa_family +extern int _httpAddrPort(http_addr_t *addr) + _CUPS_INTERNAL_MSG("Use httpAddrPort instead."); 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); + char *buffer, size_t bufsize) + _CUPS_INTERNAL_MSG("Use httpAssembleUUID instead."); extern http_t *_httpCreate(const char *host, int port, http_addrlist_t *addrlist, int family, http_encryption_t encryption, - int blocking, _http_mode_t mode); + int blocking, _http_mode_t mode) + _CUPS_INTERNAL_MSG("Use httpConnect2 or httpAccept instead."); extern http_tls_credentials_t _httpCreateCredentials(cups_array_t *credentials); extern char *_httpDecodeURI(char *dst, const char *src, @@ -409,6 +413,8 @@ extern void _httpDisconnect(http_t *http); 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) + _CUPS_INTERNAL_MSG("Use httpPeek instead."); extern const char *_httpResolveURI(const char *uri, char *resolved_uri, size_t resolved_size, int options, int (*cb)(void *context), diff --git a/cups/http-support.c b/cups/http-support.c index 49e082706d..294021f11d 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -3,7 +3,7 @@ * * HTTP support routines for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * 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 @@ -20,7 +20,8 @@ * components. * httpAssembleURIf() - Assemble a uniform resource identifier from its * components with a formatted resource. - * _httpAssembleUUID() - Make a UUID URI conforming to RFC 4122. + * httpAssembleUUID() - Assemble a name-based UUID URN conforming to RFC + * 4122. * httpDecode64() - Base64-decode a string. * httpDecode64_2() - Base64-decode a string. * httpEncode64() - Base64-encode a string. @@ -466,18 +467,22 @@ httpAssembleURIf( /* - * '_httpAssembleUUID()' - Make a UUID URI conforming to RFC 4122. + * 'httpAssembleUUID()' - Assemble a name-based UUID URN conforming to RFC 4122. + * + * This function creates a unique 128-bit identifying number using the server + * name, port number, random data, and optionally an object name and/or object + * number. The result is formatted as a UUID URN as defined in RFC 4122. * * The buffer needs to be at least 46 bytes in size. */ char * /* I - UUID string */ -_httpAssembleUUID(const char *server, /* I - Server name */ - int port, /* I - Port number */ - const char *name, /* I - Object name or NULL */ - int number, /* I - Object number or 0 */ - char *buffer, /* I - String buffer */ - size_t bufsize) /* I - Size of buffer */ +httpAssembleUUID(const char *server, /* I - Server name */ + int port, /* I - Port number */ + const char *name, /* I - Object name or NULL */ + int number, /* I - Object number or 0 */ + char *buffer, /* I - String buffer */ + size_t bufsize) /* I - Size of buffer */ { char data[1024]; /* Source string for MD5 */ _cups_md5_state_t md5state; /* MD5 state */ @@ -514,6 +519,13 @@ _httpAssembleUUID(const char *server, /* I - Server name */ return (buffer); } +/* For OS X 10.8 and earlier */ +char *_httpAssembleUUID(const char *server, int port, const char *name, + int number, char *buffer, size_t bufsize) +{ + return (httpAssembleUUID(server, port, name, number, buffer, bufsize)); +} + /* * 'httpDecode64()' - Base64-decode a string. diff --git a/cups/http.c b/cups/http.c index ab8fd532d5..8b30e4fb2c 100644 --- a/cups/http.c +++ b/cups/http.c @@ -2190,7 +2190,6 @@ httpPeek(http_t *http, /* I - Connection to server */ } /* For OS X 10.8 and earlier */ -extern ssize_t _httpPeek(http_t *http, char *buffer, size_t length); ssize_t _httpPeek(http_t *http, char *buffer, size_t length) { return (httpPeek(http, buffer, length)); } diff --git a/cups/http.h b/cups/http.h index 7ee213eb08..dc9c6671eb 100644 --- a/cups/http.h +++ b/cups/http.h @@ -591,6 +591,10 @@ extern http_addrlist_t *httpAddrCopyList(http_addrlist_t *src) _CUPS_API_1_7; extern int httpAddrListen(http_addr_t *addr, int port) _CUPS_API_1_7; extern int httpAddrPort(http_addr_t *addr) _CUPS_API_1_7; +extern char *httpAssembleUUID(const char *server, int port, + const char *name, int number, + char *buffer, size_t bufsize) + _CUPS_API_1_7; extern http_t *httpConnect2(const char *host, int port, http_addrlist_t *addrlist, int family, http_encryption_t encryption, diff --git a/cups/versioning.h b/cups/versioning.h index 808a10c2eb..a9aab7246e 100644 --- a/cups/versioning.h +++ b/cups/versioning.h @@ -3,7 +3,7 @@ * * API versioning definitions for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -19,10 +19,11 @@ /* * This header defines several constants - _CUPS_DEPRECATED, - * _CUPS_API_1_1, _CUPS_API_1_1_19, _CUPS_API_1_1_20, _CUPS_API_1_1_21, - * _CUPS_API_1_2, _CUPS_API_1_3, _CUPS_API_1_4, _CUPS_API_1_5, _CUPS_API_1_6, - * and _CUPS_API_1_7 - which add compiler-specific attributes that flag - * functions that are deprecated or added in particular releases. + * _CUPS_DEPRECATED_MSG, _CUPS_INTERNAL_MSG, _CUPS_API_1_1, _CUPS_API_1_1_19, + * _CUPS_API_1_1_20, _CUPS_API_1_1_21, _CUPS_API_1_2, _CUPS_API_1_3, + * _CUPS_API_1_4, _CUPS_API_1_5, _CUPS_API_1_6, and _CUPS_API_1_7 - which add + * compiler-specific attributes that flag functions that are deprecated, added + * in particular releases, or internal to CUPS. * * On OS X, the _CUPS_API_* constants are defined based on the values of * the MAC_OS_X_VERSION_MIN_ALLOWED and MAC_OS_X_VERSION_MAX_ALLOWED constants @@ -74,28 +75,66 @@ # endif /* __APPLE__ && !_CUPS_SOURCE */ /* - * With GCC 3.0 and higher, we can mark old APIs "deprecated" so you get - * a warning at compile-time. + * With GCC and Clang we can mark old APIs as "deprecated" or "unavailable" with + * messages so you get warnings/errors are compile-time... */ -# if defined(__GNUC__) && __GNUC__ > 2 -# ifndef __has_extension -# define __has_extension(x) 0 -# endif /* !__has_extension */ -# if __has_extension(attribute_unavailable_with_message) && defined(_CUPS_NO_DEPRECATED) -# define _CUPS_DEPRECATED __attribute__ ((unavailable)) -# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) -# elif !defined(_CUPS_SOURCE) || defined(_CUPS_NO_DEPRECATED) -# define _CUPS_DEPRECATED __attribute__ ((deprecated)) -# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) -# else -# define _CUPS_DEPRECATED -# define _CUPS_DEPRECATED_MSG(m) -# endif /* !_CUPS_SOURCE || _CUPS_NO_DEPRECATED */ -# else +# ifdef __has_extension /* Clang */ +# define _CUPS_HAS_DEPRECATED +# if __has_extension(attribute_deprecated_with_message) +# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE +# endif +# if __has_extension(attribute_unavailable_with_message) +# define _CUPS_HAS_UNAVAILABLE_WITH_MESSAGE +# endif +# elif defined(__GNUC__) /* GCC and compatible */ +# if __GNUC__ >= 3 /* GCC 3.0 or higher */ +# define _CUPS_HAS_DEPRECATED +# endif /* __GNUC__ >= 3 */ +# if __GNUC__ >= 5 /* GCC 5.x */ +# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE +# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 5 + /* GCC 4.5 or higher */ +# define _CUPS_HAS_DEPRECATED_WITH_MESSAGE +# endif /* __GNUC__ >= 5 */ +# endif /* __has_extension */ + +# if !defined(_CUPS_HAS_DEPRECATED) || (defined(_CUPS_SOURCE) && !defined(_CUPS_NO_DEPRECATED)) + /* + * Don't mark functions deprecated if the compiler doesn't support it + * or we are building CUPS source that doesn't care. + */ # define _CUPS_DEPRECATED # define _CUPS_DEPRECATED_MSG(m) -# endif /* __GNUC__ && __GNUC__ > 2 */ +# define _CUPS_INTERNAL_MSG(m) +# elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) && defined(_CUPS_NO_DEPRECATED) + /* + * Compiler supports the unsupported attribute, so use it when the code + * wants to exclude the use of deprecated API. + */ +# define _CUPS_DEPRECATED __attribute__ ((unavailable)) +# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) +# define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m))) +# else + /* + * Compiler supports the deprecated attribute, so use it. + */ +# define _CUPS_DEPRECATED __attribute__ ((deprecated)) +# ifdef _CUPS_HAS_DEPRECATED_WITH_MESSAGE +# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) +# else +# define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated)) +# endif /* _CUPS_HAS_DEPRECATED_WITH_MESSAGE */ +# ifdef _CUPS_SOURCE +# define _CUPS_INTERNAL_MSG(m) +# elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) +# define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m))) +# elif defined(_CUPS_HAS_DEPRECATED_WITH_MESSAGE) +# define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated(m))) +# else +# define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated)) +# endif /* _CUPS_SOURCE */ +# endif /* !_CUPS_HAS_DEPRECATED || (_CUPS_SOURCE && !_CUPS_NO_DEPRECATED) */ # ifndef __GNUC__ # define __attribute__(x) -- 2.47.2