diff options
Diffstat (limited to 'cups')
97 files changed, 1115 insertions, 185 deletions
diff --git a/cups/Makefile b/cups/Makefile index 473328b51..e0778a1a9 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -1,5 +1,5 @@ # -# "$Id$" +# "$Id: Makefile 13138 2016-03-15 14:59:54Z msweet $" # # API library Makefile for CUPS. # @@ -52,6 +52,7 @@ LIBOBJS = \ http-addr.o \ http-addrlist.o \ http-support.o \ + huffman.o \ ipp.o \ ipp-support.o \ langprintf.o \ @@ -91,6 +92,7 @@ TESTOBJS = \ testdest.o \ testfile.o \ testhttp.o \ + testhuffman.o \ testi18n.o \ testipp.o \ testoptions.o \ @@ -131,6 +133,7 @@ HEADERSPRIV = \ debug-private.h \ file-private.h \ http-private.h \ + huffman-private.h \ ipp-private.h \ language-private.h \ md5-private.h \ @@ -159,6 +162,7 @@ UNITTARGETS = \ testdest \ testfile \ testhttp \ + testhuffman \ testi18n \ testipp \ testlang \ @@ -464,6 +468,18 @@ testhttp: testhttp.o $(LIBCUPSSTATIC) # +# testhuffman (dependency on static CUPS library is intentional) +# + +testhuffman: testhuffman.o $(LIBCUPSSTATIC) + echo Linking $@... + $(CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testhuffman.o $(LIBCUPSSTATIC) \ + $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ) + echo Running HTTP/2 Huffman tests... + ./testhuffman + + +# # testipp (dependency on static CUPS library is intentional) # @@ -679,5 +695,5 @@ tls.o: tls-darwin.c tls-gnutls.c tls-sspi.c # -# End of "$Id$". +# End of "$Id: Makefile 13138 2016-03-15 14:59:54Z msweet $". # diff --git a/cups/adminutil.c b/cups/adminutil.c index 7b487b378..e3d4178e4 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: adminutil.c 13138 2016-03-15 14:59:54Z msweet $" * * Administration utility API definitions for CUPS. * @@ -2370,5 +2370,5 @@ write_option(cups_file_t *dstfp, /* I - PPD file */ /* - * End of "$Id$". + * End of "$Id: adminutil.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/adminutil.h b/cups/adminutil.h index 52dfe9260..f03d2facb 100644 --- a/cups/adminutil.h +++ b/cups/adminutil.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: adminutil.h 10996 2013-05-29 11:51:34Z msweet $" * * Administration utility API definitions for CUPS. * @@ -77,5 +77,5 @@ extern int cupsAdminSetServerSettings(http_t *http, #endif /* !_CUPS_ADMINUTIL_H_ */ /* - * End of "$Id$". + * End of "$Id: adminutil.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/array-private.h b/cups/array-private.h index 4d3c29734..74b0c9bf0 100644 --- a/cups/array-private.h +++ b/cups/array-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: array-private.h 3933 2012-10-01 03:01:10Z msweet $" * * Private array definitions for CUPS. * @@ -48,5 +48,5 @@ extern cups_array_t *_cupsArrayNewStrings(const char *s, char delim) #endif /* !_CUPS_ARRAY_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: array-private.h 3933 2012-10-01 03:01:10Z msweet $". */ diff --git a/cups/array.c b/cups/array.c index 855706994..cd067c882 100644 --- a/cups/array.c +++ b/cups/array.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: array.c 13138 2016-03-15 14:59:54Z msweet $" * * Sorted array routines for CUPS. * @@ -1330,5 +1330,5 @@ cups_array_find(cups_array_t *a, /* I - Array */ /* - * End of "$Id$". + * End of "$Id: array.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/array.h b/cups/array.h index 385b7dffc..7a5fc584d 100644 --- a/cups/array.h +++ b/cups/array.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: array.h 10996 2013-05-29 11:51:34Z msweet $" * * Sorted array definitions for CUPS. * @@ -88,5 +88,5 @@ extern void *cupsArrayUserData(cups_array_t *a) _CUPS_API_1_2; #endif /* !_CUPS_ARRAY_H_ */ /* - * End of "$Id$". + * End of "$Id: array.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/auth.c b/cups/auth.c index ce9fce694..18bd55c3c 100644 --- a/cups/auth.c +++ b/cups/auth.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: auth.c 13138 2016-03-15 14:59:54Z msweet $" * * Authentication functions for CUPS. * @@ -876,5 +876,5 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */ /* - * End of "$Id$". + * End of "$Id: auth.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/backchannel.c b/cups/backchannel.c index 06a6d2308..86ba409b4 100644 --- a/cups/backchannel.c +++ b/cups/backchannel.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: backchannel.c 11984 2014-07-02 13:16:59Z msweet $" * * Backchannel functions for CUPS. * @@ -189,5 +189,5 @@ cups_setup(fd_set *set, /* I - Set for select() */ /* - * End of "$Id$". + * End of "$Id: backchannel.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/backend.c b/cups/backend.c index 6e12c0f35..4f417b894 100644 --- a/cups/backend.c +++ b/cups/backend.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: backend.c 13138 2016-03-15 14:59:54Z msweet $" * * Backend functions for CUPS. * @@ -145,5 +145,5 @@ quote_string(const char *s) /* I - String to write */ /* - * End of "$Id$". + * End of "$Id: backend.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/backend.h b/cups/backend.h index 85941c71a..127c02790 100644 --- a/cups/backend.h +++ b/cups/backend.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: backend.h 10996 2013-05-29 11:51:34Z msweet $" * * Backend definitions for CUPS. * @@ -74,5 +74,5 @@ extern void cupsBackendReport(const char *device_scheme, #endif /* !_CUPS_BACKEND_H_ */ /* - * End of "$Id$". + * End of "$Id: backend.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/cups-private.h b/cups/cups-private.h index c36fde6ee..b9d15a1ab 100644 --- a/cups/cups-private.h +++ b/cups/cups-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: cups-private.h 13138 2016-03-15 14:59:54Z msweet $" * * Private definitions for CUPS. * @@ -274,5 +274,5 @@ extern char *_cupsUserDefault(char *name, size_t namesize); #endif /* !_CUPS_CUPS_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: cups-private.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/cups.h b/cups/cups.h index 0e374b450..02d91685a 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: cups.h 13138 2016-03-15 14:59:54Z msweet $" * * API definitions for CUPS. * @@ -623,5 +623,5 @@ extern ssize_t cupsHashData(const char *algorithm, const void *data, size_t dat #endif /* !_CUPS_CUPS_H_ */ /* - * End of "$Id$". + * End of "$Id: cups.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/debug-private.h b/cups/debug-private.h index 26c75a379..8968aebfe 100644 --- a/cups/debug-private.h +++ b/cups/debug-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: debug-private.h 10996 2013-05-29 11:51:34Z msweet $" * * Private debugging macros for CUPS. * @@ -113,5 +113,5 @@ extern int _cups_gettimeofday(struct timeval *tv, void *tz); #endif /* !_CUPS_DEBUG_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: debug-private.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/debug.c b/cups/debug.c index 3ee3a1900..d9f10d889 100644 --- a/cups/debug.c +++ b/cups/debug.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: debug.c 13138 2016-03-15 14:59:54Z msweet $" * * Debugging functions for CUPS. * @@ -645,5 +645,5 @@ _cups_safe_vsnprintf( /* - * End of "$Id$". + * End of "$Id: debug.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/dest-localization.c b/cups/dest-localization.c index 5174953b5..fd69799b1 100644 --- a/cups/dest-localization.c +++ b/cups/dest-localization.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: dest-localization.c 13138 2016-03-15 14:59:54Z msweet $" * * Destination localization support for CUPS. * @@ -535,5 +535,5 @@ cups_scan_strings(char *buffer) /* I - Start of string */ /* - * End of "$Id$". + * End of "$Id: dest-localization.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/dest-options.c b/cups/dest-options.c index 43d231b2b..5063e13c4 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -2267,5 +2267,5 @@ cups_update_ready(http_t *http, /* I - Connection to destination */ /* - * End of "$Id$". + * End of "$Id: dest-options.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/dir.c b/cups/dir.c index d30009ecf..1bae123e2 100644 --- a/cups/dir.c +++ b/cups/dir.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: dir.c 10996 2013-05-29 11:51:34Z msweet $" * * Directory routines for CUPS. * @@ -468,5 +468,5 @@ cupsDirRewind(cups_dir_t *dp) /* I - Directory pointer */ #endif /* WIN32 */ /* - * End of "$Id$". + * End of "$Id: dir.c 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/dir.h b/cups/dir.h index 75e5b1e61..ad8278c45 100644 --- a/cups/dir.h +++ b/cups/dir.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: dir.h 10996 2013-05-29 11:51:34Z msweet $" * * Public directory definitions for CUPS. * @@ -65,5 +65,5 @@ extern void cupsDirRewind(cups_dir_t *dp) _CUPS_API_1_2; #endif /* !_CUPS_DIR_H_ */ /* - * End of "$Id$". + * End of "$Id: dir.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/encode.c b/cups/encode.c index 44fe31ea2..a576509c7 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: encode.c 13138 2016-03-15 14:59:54Z msweet $" * * Option encoding routines for CUPS. * @@ -854,5 +854,5 @@ compare_ipp_options(_ipp_option_t *a, /* I - First option */ /* - * End of "$Id$". + * End of "$Id: encode.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/file-private.h b/cups/file-private.h index 219480fdb..41d2c8a33 100644 --- a/cups/file-private.h +++ b/cups/file-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: file-private.h 11984 2014-07-02 13:16:59Z msweet $" * * Private file definitions for CUPS. * @@ -135,5 +135,5 @@ extern void _cupsFileCheckFilter(void *context, #endif /* !_CUPS_FILE_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: file-private.h 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/file.c b/cups/file.c index 3b951aa6c..df57a1fd4 100644 --- a/cups/file.c +++ b/cups/file.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: file.c 13138 2016-03-15 14:59:54Z msweet $" * * File functions for CUPS. * @@ -2752,5 +2752,5 @@ cups_write(cups_file_t *fp, /* I - CUPS file */ /* - * End of "$Id$". + * End of "$Id: file.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/file.h b/cups/file.h index 6e73fea1b..723bdff0e 100644 --- a/cups/file.h +++ b/cups/file.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: file.h 11984 2014-07-02 13:16:59Z msweet $" * * Public file definitions for CUPS. * @@ -114,5 +114,5 @@ extern ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, #endif /* !_CUPS_FILE_H_ */ /* - * End of "$Id$". + * End of "$Id: file.h 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/getdevices.c b/cups/getdevices.c index 0d5397858..ea862a7ea 100644 --- a/cups/getdevices.c +++ b/cups/getdevices.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: getdevices.c 4216 2013-03-11 13:57:36Z msweet $" * * cupsGetDevices implementation for CUPS. * @@ -280,5 +280,5 @@ cupsGetDevices( /* - * End of "$Id$". + * End of "$Id: getdevices.c 4216 2013-03-11 13:57:36Z msweet $". */ diff --git a/cups/getifaddrs.c b/cups/getifaddrs.c index 8111e224d..02903a799 100644 --- a/cups/getifaddrs.c +++ b/cups/getifaddrs.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: getifaddrs.c 10996 2013-05-29 11:51:34Z msweet $" * * Network interface functions for CUPS. * @@ -262,5 +262,5 @@ _cups_freeifaddrs(struct ifaddrs *addrs)/* I - Interface list to free */ /* - * End of "$Id$". + * End of "$Id: getifaddrs.c 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/getputfile.c b/cups/getputfile.c index 443e0c4f1..ea3b1b16b 100644 --- a/cups/getputfile.c +++ b/cups/getputfile.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: getputfile.c 11984 2014-07-02 13:16:59Z msweet $" * * Get/put file functions for CUPS. * @@ -511,5 +511,5 @@ cupsPutFile(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DE /* - * End of "$Id$". + * End of "$Id: getputfile.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/globals.c b/cups/globals.c index fa0feb4c5..7e17f8a6c 100644 --- a/cups/globals.c +++ b/cups/globals.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: globals.c 13138 2016-03-15 14:59:54Z msweet $" * * Global variable access routines for CUPS. * @@ -382,5 +382,5 @@ cups_globals_init(void) /* - * End of "$Id$". + * End of "$Id: globals.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/hash.c b/cups/hash.c index e20590f26..d45f1d393 100644 --- a/cups/hash.c +++ b/cups/hash.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: hash.c 13138 2016-03-15 14:59:54Z msweet $" * * Hashing function for CUPS. * @@ -248,5 +248,5 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */ /* - * End of "$Id$". + * End of "$Id: hash.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/http-addr.c b/cups/http-addr.c index 9ad2ea307..cba7b96af 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: http-addr.c 13138 2016-03-15 14:59:54Z msweet $" * * HTTP address routines for CUPS. * @@ -924,5 +924,5 @@ httpResolveHostname(http_t *http, /* I - HTTP connection */ /* - * End of "$Id$". + * End of "$Id: http-addr.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index 8a17f6fa6..91374ebe9 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: http-addrlist.c 13138 2016-03-15 14:59:54Z msweet $" * * HTTP address list routines for CUPS. * @@ -892,5 +892,5 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p /* - * End of "$Id$". + * End of "$Id: http-addrlist.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/http-private.h b/cups/http-private.h index 39337dbcc..5598cdd11 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: http-private.h 13138 2016-03-15 14:59:54Z msweet $" * * Private HTTP definitions for CUPS. * @@ -442,5 +442,5 @@ extern int _httpWait(http_t *http, int msec, int usessl); #endif /* !_CUPS_HTTP_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: http-private.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/http.c b/cups/http.c index de0ee46b8..c8c41110d 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: http.c 13138 2016-03-15 14:59:54Z msweet $" * * HTTP routines for CUPS. * @@ -4849,5 +4849,5 @@ http_write_chunk(http_t *http, /* I - HTTP connection */ /* - * End of "$Id$". + * End of "$Id: http.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/http.h b/cups/http.h index 4f72c678c..991ed794f 100644 --- a/cups/http.h +++ b/cups/http.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: http.h 13138 2016-03-15 14:59:54Z msweet $" * * Hyper-Text Transport Protocol definitions for CUPS. * @@ -656,5 +656,5 @@ extern const char *httpURIStatusString(http_uri_status_t status) _CUPS_API_2_0; #endif /* !_CUPS_HTTP_H_ */ /* - * End of "$Id$". + * End of "$Id: http.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/huffman-private.h b/cups/huffman-private.h new file mode 100644 index 000000000..95590fefe --- /dev/null +++ b/cups/huffman-private.h @@ -0,0 +1,56 @@ +/* + * "$Id: huffman-private.h 11985 2014-07-02 15:41:16Z msweet $" + * + * HTTP/2 Huffman compression/decompression definitions for CUPS. + * + * Copyright 2014 by Apple Inc. + * + * 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. + */ + +#ifndef _CUPS_HUFFMAN_PRIVATE_H_ +# define _CUPS_HUFFMAN_PRIVATE_H_ + +/* + * Include necessary headers... + */ + +# include "versioning.h" +# include <stdlib.h> + + +/* + * C++ magic... + */ + +# ifdef __cplusplus +extern "C" { +# endif /* __cplusplus */ + + +/* + * Functions... + */ + +extern size_t _http2HuffmanDecode(char *dst, size_t dstsize, const unsigned char *src, size_t srclen); +extern size_t _http2HuffmanEncode(unsigned char *dst, size_t dstsize, const char *src); + + +/* + * C++ magic... + */ + +# ifdef __cplusplus +} +# endif /* __cplusplus */ +#endif /* !_CUPS_HUFFMAN_PRIVATE_H_ */ + +/* + * End of "$Id: huffman-private.h 11985 2014-07-02 15:41:16Z msweet $". + */ diff --git a/cups/huffman.c b/cups/huffman.c new file mode 100644 index 000000000..5859d5d86 --- /dev/null +++ b/cups/huffman.c @@ -0,0 +1,651 @@ +/* + * "$Id: huffman.c 11990 2014-07-02 21:13:22Z msweet $" + * + * HTTP/2 Huffman compression/decompression routines for CUPS. + * + * Copyright 2014 by Apple Inc. + * + * 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. + */ + +/* + * Include necessary headers... + */ + +#include "debug-private.h" +#include "huffman-private.h" +#include "thread-private.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + + +/* + * Constants... + */ + +#define _HTTP2_HUFFMAN_MAX 30 /* Max Huffman bits in table */ + + +/* + * Huffman table from HPACK-08 draft. + */ + +typedef struct _http2_huffman_s /**** Huffman code table ****/ +{ + int code; /* Code */ + short len; /* Length in bits */ + short ch; /* Character */ +} _http2_huffman_t; + +static _http2_huffman_t http2_decode[256]; + /* Decoder values */ +static int http2_decode_max[_HTTP2_HUFFMAN_MAX + 1]; +static const _http2_huffman_t *http2_decode_next[_HTTP2_HUFFMAN_MAX + 1]; +static int http2_decode_init = 0; +static _cups_mutex_t http2_decode_mutex = _CUPS_MUTEX_INITIALIZER; +static const _http2_huffman_t http2_encode[256] = +{ /* Encoder values */ + { 0x1ff8, 13, 0x00 }, + { 0x7fffd8, 23, 0x01 }, + { 0xfffffe2, 28, 0x02 }, + { 0xfffffe3, 28, 0x03 }, + { 0xfffffe4, 28, 0x04 }, + { 0xfffffe5, 28, 0x05 }, + { 0xfffffe6, 28, 0x06 }, + { 0xfffffe7, 28, 0x07 }, + { 0xfffffe8, 28, 0x08 }, + { 0xffffea, 24, 0x09 }, + { 0xffffffc, 30, 0x0a }, + { 0xfffffe9, 28, 0x0b }, + { 0xfffffea, 28, 0x0c }, + { 0xffffffd, 30, 0x0d }, + { 0xfffffeb, 28, 0x0e }, + { 0xfffffec, 28, 0x0f }, + { 0xfffffed, 28, 0x10 }, + { 0xfffffee, 28, 0x11 }, + { 0xfffffef, 28, 0x12 }, + { 0xffffff0, 28, 0x13 }, + { 0xffffff1, 28, 0x14 }, + { 0xffffff2, 28, 0x15 }, + { 0xffffffe, 30, 0x16 }, + { 0xffffff3, 28, 0x17 }, + { 0xffffff4, 28, 0x18 }, + { 0xffffff5, 28, 0x19 }, + { 0xffffff6, 28, 0x1a }, + { 0xffffff7, 28, 0x1b }, + { 0xffffff8, 28, 0x1c }, + { 0xffffff9, 28, 0x1d }, + { 0xffffffa, 28, 0x1e }, + { 0xffffffb, 28, 0x1f }, + { 0x14, 6, 0x20 }, + { 0x3f8, 10, 0x21 }, + { 0x3f9, 10, 0x22 }, + { 0xffa, 12, 0x23 }, + { 0x1ff9, 13, 0x24 }, + { 0x15, 6, 0x25 }, + { 0xf8, 8, 0x26 }, + { 0x7fa, 11, 0x27 }, + { 0x3fa, 10, 0x28 }, + { 0x3fb, 10, 0x29 }, + { 0xf9, 8, 0x2a }, + { 0x7fb, 11, 0x2b }, + { 0xfa, 8, 0x2c }, + { 0x16, 6, 0x2d }, + { 0x17, 6, 0x2e }, + { 0x18, 6, 0x2f }, + { 0x0, 5, 0x30 }, + { 0x1, 5, 0x31 }, + { 0x2, 5, 0x32 }, + { 0x19, 6, 0x33 }, + { 0x1a, 6, 0x34 }, + { 0x1b, 6, 0x35 }, + { 0x1c, 6, 0x36 }, + { 0x1d, 6, 0x37 }, + { 0x1e, 6, 0x38 }, + { 0x1f, 6, 0x39 }, + { 0x5c, 7, 0x3a }, + { 0xfb, 8, 0x3b }, + { 0x7ffc, 15, 0x3c }, + { 0x20, 6, 0x3d }, + { 0xffb, 12, 0x3e }, + { 0x3fc, 10, 0x3f }, + { 0x1ffa, 13, 0x40 }, + { 0x21, 6, 0x41 }, + { 0x5d, 7, 0x42 }, + { 0x5e, 7, 0x43 }, + { 0x5f, 7, 0x44 }, + { 0x60, 7, 0x45 }, + { 0x61, 7, 0x46 }, + { 0x62, 7, 0x47 }, + { 0x63, 7, 0x48 }, + { 0x64, 7, 0x49 }, + { 0x65, 7, 0x4a }, + { 0x66, 7, 0x4b }, + { 0x67, 7, 0x4c }, + { 0x68, 7, 0x4d }, + { 0x69, 7, 0x4e }, + { 0x6a, 7, 0x4f }, + { 0x6b, 7, 0x50 }, + { 0x6c, 7, 0x51 }, + { 0x6d, 7, 0x52 }, + { 0x6e, 7, 0x53 }, + { 0x6f, 7, 0x54 }, + { 0x70, 7, 0x55 }, + { 0x71, 7, 0x56 }, + { 0x72, 7, 0x57 }, + { 0xfc, 8, 0x58 }, + { 0x73, 7, 0x59 }, + { 0xfd, 8, 0x5a }, + { 0x1ffb, 13, 0x5b }, + { 0x7fff0, 19, 0x5c }, + { 0x1ffc, 13, 0x5d }, + { 0x3ffc, 14, 0x5e }, + { 0x22, 6, 0x5f }, + { 0x7ffd, 15, 0x60 }, + { 0x3, 5, 0x61 }, + { 0x23, 6, 0x62 }, + { 0x4, 5, 0x63 }, + { 0x24, 6, 0x64 }, + { 0x5, 5, 0x65 }, + { 0x25, 6, 0x66 }, + { 0x26, 6, 0x67 }, + { 0x27, 6, 0x68 }, + { 0x6, 5, 0x69 }, + { 0x74, 7, 0x6a }, + { 0x75, 7, 0x6b }, + { 0x28, 6, 0x6c }, + { 0x29, 6, 0x6d }, + { 0x2a, 6, 0x6e }, + { 0x7, 5, 0x6f }, + { 0x2b, 6, 0x70 }, + { 0x76, 7, 0x71 }, + { 0x2c, 6, 0x72 }, + { 0x8, 5, 0x73 }, + { 0x9, 5, 0x74 }, + { 0x2d, 6, 0x75 }, + { 0x77, 7, 0x76 }, + { 0x78, 7, 0x77 }, + { 0x79, 7, 0x78 }, + { 0x7a, 7, 0x79 }, + { 0x7b, 7, 0x7a }, + { 0x7ffe, 15, 0x7b }, + { 0x7fc, 11, 0x7c }, + { 0x3ffd, 14, 0x7d }, + { 0x1ffd, 13, 0x7e }, + { 0xffffffc, 28, 0x7f }, + { 0xfffe6, 20, 0x80 }, + { 0x3fffd2, 22, 0x81 }, + { 0xfffe7, 20, 0x82 }, + { 0xfffe8, 20, 0x83 }, + { 0x3fffd3, 22, 0x84 }, + { 0x3fffd4, 22, 0x85 }, + { 0x3fffd5, 22, 0x86 }, + { 0x7fffd9, 23, 0x87 }, + { 0x3fffd6, 22, 0x88 }, + { 0x7fffda, 23, 0x89 }, + { 0x7fffdb, 23, 0x8a }, + { 0x7fffdc, 23, 0x8b }, + { 0x7fffdd, 23, 0x8c }, + { 0x7fffde, 23, 0x8d }, + { 0xffffeb, 24, 0x8e }, + { 0x7fffdf, 23, 0x8f }, + { 0xffffec, 24, 0x90 }, + { 0xffffed, 24, 0x91 }, + { 0x3fffd7, 22, 0x92 }, + { 0x7fffe0, 23, 0x93 }, + { 0xffffee, 24, 0x94 }, + { 0x7fffe1, 23, 0x95 }, + { 0x7fffe2, 23, 0x96 }, + { 0x7fffe3, 23, 0x97 }, + { 0x7fffe4, 23, 0x98 }, + { 0x1fffdc, 21, 0x99 }, + { 0x3fffd8, 22, 0x9a }, + { 0x7fffe5, 23, 0x9b }, + { 0x3fffd9, 22, 0x9c }, + { 0x7fffe6, 23, 0x9d }, + { 0x7fffe7, 23, 0x9e }, + { 0xffffef, 24, 0x9f }, + { 0x3fffda, 22, 0xa0 }, + { 0x1fffdd, 21, 0xa1 }, + { 0xfffe9, 20, 0xa2 }, + { 0x3fffdb, 22, 0xa3 }, + { 0x3fffdc, 22, 0xa4 }, + { 0x7fffe8, 23, 0xa5 }, + { 0x7fffe9, 23, 0xa6 }, + { 0x1fffde, 21, 0xa7 }, + { 0x7fffea, 23, 0xa8 }, + { 0x3fffdd, 22, 0xa9 }, + { 0x3fffde, 22, 0xaa }, + { 0xfffff0, 24, 0xab }, + { 0x1fffdf, 21, 0xac }, + { 0x3fffdf, 22, 0xad }, + { 0x7fffeb, 23, 0xae }, + { 0x7fffec, 23, 0xaf }, + { 0x1fffe0, 21, 0xb0 }, + { 0x1fffe1, 21, 0xb1 }, + { 0x3fffe0, 22, 0xb2 }, + { 0x1fffe2, 21, 0xb3 }, + { 0x7fffed, 23, 0xb4 }, + { 0x3fffe1, 22, 0xb5 }, + { 0x7fffee, 23, 0xb6 }, + { 0x7fffef, 23, 0xb7 }, + { 0xfffea, 20, 0xb8 }, + { 0x3fffe2, 22, 0xb9 }, + { 0x3fffe3, 22, 0xba }, + { 0x3fffe4, 22, 0xbb }, + { 0x7ffff0, 23, 0xbc }, + { 0x3fffe5, 22, 0xbd }, + { 0x3fffe6, 22, 0xbe }, + { 0x7ffff1, 23, 0xbf }, + { 0x3ffffe0, 26, 0xc0 }, + { 0x3ffffe1, 26, 0xc1 }, + { 0xfffeb, 20, 0xc2 }, + { 0x7fff1, 19, 0xc3 }, + { 0x3fffe7, 22, 0xc4 }, + { 0x7ffff2, 23, 0xc5 }, + { 0x3fffe8, 22, 0xc6 }, + { 0x1ffffec, 25, 0xc7 }, + { 0x3ffffe2, 26, 0xc8 }, + { 0x3ffffe3, 26, 0xc9 }, + { 0x3ffffe4, 26, 0xca }, + { 0x7ffffde, 27, 0xcb }, + { 0x7ffffdf, 27, 0xcc }, + { 0x3ffffe5, 26, 0xcd }, + { 0xfffff1, 24, 0xce }, + { 0x1ffffed, 25, 0xcf }, + { 0x7fff2, 19, 0xd0 }, + { 0x1fffe3, 21, 0xd1 }, + { 0x3ffffe6, 26, 0xd2 }, + { 0x7ffffe0, 27, 0xd3 }, + { 0x7ffffe1, 27, 0xd4 }, + { 0x3ffffe7, 26, 0xd5 }, + { 0x7ffffe2, 27, 0xd6 }, + { 0xfffff2, 24, 0xd7 }, + { 0x1fffe4, 21, 0xd8 }, + { 0x1fffe5, 21, 0xd9 }, + { 0x3ffffe8, 26, 0xda }, + { 0x3ffffe9, 26, 0xdb }, + { 0xffffffd, 28, 0xdc }, + { 0x7ffffe3, 27, 0xdd }, + { 0x7ffffe4, 27, 0xde }, + { 0x7ffffe5, 27, 0xdf }, + { 0xfffec, 20, 0xe0 }, + { 0xfffff3, 24, 0xe1 }, + { 0xfffed, 20, 0xe2 }, + { 0x1fffe6, 21, 0xe3 }, + { 0x3fffe9, 22, 0xe4 }, + { 0x1fffe7, 21, 0xe5 }, + { 0x1fffe8, 21, 0xe6 }, + { 0x7ffff3, 23, 0xe7 }, + { 0x3fffea, 22, 0xe8 }, + { 0x3fffeb, 22, 0xe9 }, + { 0x1ffffee, 25, 0xea }, + { 0x1ffffef, 25, 0xeb }, + { 0xfffff4, 24, 0xec }, + { 0xfffff5, 24, 0xed }, + { 0x3ffffea, 26, 0xee }, + { 0x7ffff4, 23, 0xef }, + { 0x3ffffeb, 26, 0xf0 }, + { 0x7ffffe6, 27, 0xf1 }, + { 0x3ffffec, 26, 0xf2 }, + { 0x3ffffed, 26, 0xf3 }, + { 0x7ffffe7, 27, 0xf4 }, + { 0x7ffffe8, 27, 0xf5 }, + { 0x7ffffe9, 27, 0xf6 }, + { 0x7ffffea, 27, 0xf7 }, + { 0x7ffffeb, 27, 0xf8 }, + { 0xffffffe, 28, 0xf9 }, + { 0x7ffffec, 27, 0xfa }, + { 0x7ffffed, 27, 0xfb }, + { 0x7ffffee, 27, 0xfc }, + { 0x7ffffef, 27, 0xfd }, + { 0x7fffff0, 27, 0xfe }, + { 0x3ffffee, 26, 0xff } +}; +static const unsigned char http2_masks[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; + /* Bitmasks */ + + +/* + * Local functions... + */ + +static int http2_compare_decode(const _http2_huffman_t *a, const _http2_huffman_t *b); + + +/* + * '_http2HuffmanDecode()' - Decode (decompress) a HTTP/2 Huffman-encoded string. + * + * The "dst" string is nul-terminated even if the total length of the Huffman- + * encoded string does not fit. The return value contains the actual length + * of the string after decoding. + */ + +size_t /* O - Actual length of string or 0 on error */ +_http2HuffmanDecode( + char *dst, /* I - Destination string buffer */ + size_t dstsize, /* I - Size of string buffer */ + const unsigned char *src, /* I - Incoming Huffman data */ + size_t srclen) /* I - Length of incoming Huffman data */ +{ + char *dstptr, /* Pointer into string buffer */ + *dstend; /* End of string buffer */ + const unsigned char *srcend; /* End of Huffman data */ + unsigned char srcbyte; /* Current source string byte */ + int srcavail, /* How many bits are available in the current byte? */ + code, /* Assembled code */ + len, /* Length of assembled code */ + bits; /* Bits to grab */ + const _http2_huffman_t *dptr, /* Pointer into decoder table */ + *dend; /* End of decoder table */ + + + DEBUG_printf(("4_http2HuffmanDecode(dst=%p, dstsize=" CUPS_LLFMT ", src=%p, srclen=" CUPS_LLFMT ")", dst, CUPS_LLCAST dstsize, src, CUPS_LLCAST srclen)); + + /* + * Initialize the decoder array as needed... + */ + + dend = http2_decode + (sizeof(http2_decode) / sizeof(http2_decode[0])); + + if (!http2_decode_init) + { + _cupsMutexLock(&http2_decode_mutex); + if (!http2_decode_init) + { + http2_decode_init = 1; + memcpy(http2_decode, http2_encode, sizeof(http2_decode)); + qsort(http2_decode, sizeof(http2_decode) / sizeof(http2_decode[0]), sizeof(http2_decode[0]), (int (*)(const void *, const void *))http2_compare_decode); + + for (len = 0, dptr = http2_decode; dptr < dend; dptr ++) + { + if (len != dptr->len) + { + http2_decode_next[len] = dptr; + len = dptr->len; + } + + if ((dptr + 1) < dend && dptr[1].len != len) + http2_decode_max[len] = dptr->code; + } + } + _cupsMutexUnlock(&http2_decode_mutex); + } + + /* + * Decode the string. + * + * Note: Initial implementation that has very little optimization applied. + */ + + dstptr = dst; + dstend = dst + dstsize - 1; + srcavail = 0; + srcbyte = 0; + srcend = src + srclen; + + while (src < srcend || srcavail > 0) + { + /* + * Each Huffman code has a minimum of 5 bits. We do a linear search of the + * decode table, which has been sorted in ascending order for length and + * code. If we don't find the code in the table we return an error. + */ + + code = 0; + len = 0; + dptr = http2_decode; + + DEBUG_printf(("5_http2HuffmanDecode: init srcbyte=%02x, srcavail=%d", srcbyte, srcavail)); + + while (dptr < dend) + { + while (len < dptr->len) + { + /* + * Get N more bits from the input... + */ + + if (srcavail == 0) + { + if (src < srcend) + { + srcbyte = *src++; + srcavail = 8; + + DEBUG_printf(("5_http2HuffmanDecode: cont srcbyte=%02x, srcavail=%d", srcbyte, srcavail)); + } + else if (len < 8 && code == http2_masks[len]) + break; + else + { + DEBUG_puts("5_http2HuffmanDecode: Early end-of-string."); + return (0); + } + } + + if ((bits = dptr->len - len) > srcavail) + bits = srcavail; + + DEBUG_printf(("5_http2HuffmanDecode: Pulling %d bits", bits)); + + if (bits == srcavail) + { + if (len == 0) + { + if (bits == 8) + code = srcbyte; + else + code = srcbyte & http2_masks[bits]; + } + else + code = (code << bits) | (srcbyte & http2_masks[bits]); + + srcavail = 0; + } + else if (len == 0) + { + code = (srcbyte >> (srcavail - bits)) & http2_masks[bits]; + srcavail -= bits; + } + else + { + code = (code << bits) | ((srcbyte >> (srcavail - bits)) & http2_masks[bits]); + srcavail -= bits; + } + + len += bits; + +#ifdef DEBUG + if (len < dptr->len) + DEBUG_printf(("5_http2HuffmanDecode: code=%x, len=%d, srcavail=%d", code, len, srcavail)); +#endif /* DEBUG */ + } + + DEBUG_printf(("5_http2HuffmanDecode: code=%x, len=%d, dptr->len=%d", code, len, dptr->len)); + + if (len < dptr->len) + break; + + if (code > http2_decode_max[len]) + { + dptr = http2_decode_next[len]; + continue; + } + + while (len == dptr->len) + if (dptr->code == code) + break; + else + dptr ++; + + if (dptr->code == code && dptr->len == len) + { + DEBUG_printf(("5_http2HuffmanDecode: code=%x, len=%d, match='%c' (0x%02x)", (unsigned)code, len, dptr->ch, dptr->ch)); + + if (dstptr < dstend) + *dstptr = (char)dptr->ch; + + dstptr ++; + break; + } +#ifdef DEBUG + else + DEBUG_printf(("5_http2HuffmanDecode: code=%x, len=%d, no match", (unsigned)code, len)); +#endif /* DEBUG */ + } + } + + if (dstptr < dstend) + *dstptr = '\0'; + else + *dstend = '\0'; + + return ((size_t)(dstptr - dst)); +} + + +/* + * '_http2HuffmanEncode()' - Encode (compress) a string using HTTP/2 Huffman-coding. + * + * The return value contains the actual length of the string after encoding. + */ + +size_t /* O - Number of bytes used for Huffman */ +_http2HuffmanEncode( + unsigned char *dst, /* I - Output buffer */ + size_t dstsize, /* I - Size of output buffer */ + const char *src) /* I - String to encode */ +{ + unsigned char *dstptr, /* Pointer into buffer */ + *dstend, /* End of buffer */ + dstbyte; /* Current output byte */ + int dstused, /* Current bits used */ + dstremaining; /* Remaining bits */ + int ch; /* Current character */ + int code, /* Huffman code */ + len; /* Length of Huffman code */ + + + /* + * Note: Initial implementation that has very little optimization applied. + */ + + dstptr = dst; + dstend = dst + dstsize; + dstbyte = 0; + dstused = 0; + + while (*src) + { + ch = *src++ & 255; + code = http2_encode[ch].code; + len = http2_encode[ch].len; + + while (len > 0) + { + if (dstused == 0) + { + if (len == 8) + { + dstbyte = (unsigned char)code; + dstused = 8; + } + else if (len > 8) + { + dstbyte = (unsigned char)(code >> (len - 8)); + dstused = 8; + } + else + { + dstbyte = (unsigned char)(code << (8 - len)); + dstused = len; + } + + len -= dstused; + } + else + { + dstremaining = 8 - dstused; + + if (len == dstremaining) + { + dstbyte |= (unsigned char)(code & http2_masks[dstremaining]); + dstused = 8; + len = 0; + } + else if (len > dstremaining) + { + dstbyte |= (unsigned char)((code >> (len - dstremaining)) & http2_masks[dstremaining]); + dstused = 8; + len -= dstremaining; + } + else + { + dstbyte |= (unsigned char)((code << (dstremaining - len)) & http2_masks[dstremaining]); + dstused += len; + len = 0; + } + } + + if (dstused == 8) + { + /* + * "Write" a byte to the output buffer + */ + + if (dstptr < dstend) + *dstptr = dstbyte; + + dstptr ++; + dstused = 0; + } + } + } + + if (dstused) + { + /* + * Pad the output string with 1's as an End-Of-String code... + */ + + dstremaining = 8 - dstused; + dstbyte |= http2_masks[dstremaining]; + if (dstptr < dstend) + *dstptr = dstbyte; + dstptr ++; + } + + return ((size_t)(dstptr - dst)); +} + + +/* + * 'http2_compare_decode()' - Compare two Huffman codes for decoding. + */ + +static int /* O - Result of comparison */ +http2_compare_decode( + const _http2_huffman_t *a, /* I - First code */ + const _http2_huffman_t *b) /* I - Second code */ +{ + int result; /* Result of comparison */ + + + if ((result = a->len - b->len) == 0) + result = a->code - b->code; + + return (result); +} + + +/* + * End of "$Id: huffman.c 11990 2014-07-02 21:13:22Z msweet $". + */ diff --git a/cups/ipp-private.h b/cups/ipp-private.h index 2d8840842..b3435ea3f 100644 --- a/cups/ipp-private.h +++ b/cups/ipp-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ipp-private.h 11984 2014-07-02 13:16:59Z msweet $" * * Private IPP definitions for CUPS. * @@ -77,5 +77,5 @@ extern _ipp_option_t *_ippFindOption(const char *name); #endif /* !_CUPS_IPP_H_ */ /* - * End of "$Id$". + * End of "$Id: ipp-private.h 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/ipp-support.c b/cups/ipp-support.c index 40c01eb60..150cb554b 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ipp-support.c 13138 2016-03-15 14:59:54Z msweet $" * * Internet Printing Protocol support functions for CUPS. * @@ -2289,5 +2289,5 @@ ipp_col_string(ipp_t *col, /* I - Collection attribute */ /* - * End of "$Id$". + * End of "$Id: ipp-support.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ipp.c b/cups/ipp.c index e1a528c70..a0dec3ba1 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ipp.c 13138 2016-03-15 14:59:54Z msweet $" * * Internet Printing Protocol functions for CUPS. * @@ -7062,5 +7062,5 @@ ipp_write_file(int *fd, /* I - File descriptor */ /* - * End of "$Id$". + * End of "$Id: ipp.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ipp.h b/cups/ipp.h index aefdcbfa4..5ee6c35f2 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ipp.h 13138 2016-03-15 14:59:54Z msweet $" * * Internet Printing Protocol definitions for CUPS. * @@ -1036,5 +1036,5 @@ extern const char *ippStateString(ipp_state_t state) _CUPS_API_2_0; #endif /* !_CUPS_IPP_H_ */ /* - * End of "$Id$". + * End of "$Id: ipp.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/langprintf.c b/cups/langprintf.c index f5f92a948..b0e9c34db 100644 --- a/cups/langprintf.c +++ b/cups/langprintf.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: langprintf.c 11984 2014-07-02 13:16:59Z msweet $" * * Localized printf/puts functions for CUPS. * @@ -337,5 +337,5 @@ _cupsSetLocale(char *argv[]) /* IO - Command-line arguments */ /* - * End of "$Id$". + * End of "$Id: langprintf.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/language-private.h b/cups/language-private.h index cf5b482b4..93cdf0831 100644 --- a/cups/language-private.h +++ b/cups/language-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: language-private.h 10996 2013-05-29 11:51:34Z msweet $" * * Private localization support for CUPS. * @@ -82,5 +82,5 @@ extern void _cupsSetLocale(char *argv[]); #endif /* !_CUPS_LANGUAGE_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: language-private.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/language.c b/cups/language.c index 69e391f2a..cb3d22c3d 100644 --- a/cups/language.c +++ b/cups/language.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: language.c 13138 2016-03-15 14:59:54Z msweet $" * * I18N/language support for CUPS. * @@ -1624,5 +1624,5 @@ cups_unquote(char *d, /* O - Unquoted string */ /* - * End of "$Id$". + * End of "$Id: language.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/language.h b/cups/language.h index 0b8acdee4..4fcf9e84f 100644 --- a/cups/language.h +++ b/cups/language.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: language.h 10996 2013-05-29 11:51:34Z msweet $" * * Multi-language support for CUPS. * @@ -111,5 +111,5 @@ extern cups_lang_t *cupsLangGet(const char *language); #endif /* !_CUPS_LANGUAGE_H_ */ /* - * End of "$Id$". + * End of "$Id: language.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/md5-private.h b/cups/md5-private.h index 3667cf0b3..7b9464262 100644 --- a/cups/md5-private.h +++ b/cups/md5-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: md5-private.h 10996 2013-05-29 11:51:34Z msweet $" * * Private MD5 definitions for CUPS. * @@ -75,5 +75,5 @@ void _cupsMD5Finish(_cups_md5_state_t *pms, unsigned char digest[16]); #endif /* !_CUPS_MD5_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: md5-private.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/md5.c b/cups/md5.c index 851715ff1..bedddcf10 100644 --- a/cups/md5.c +++ b/cups/md5.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: md5.c 13138 2016-03-15 14:59:54Z msweet $" * * Private MD5 implementation for CUPS. * @@ -342,5 +342,5 @@ _cupsMD5Finish(_cups_md5_state_t *pms, unsigned char digest[16]) /* - * End of "$Id$". + * End of "$Id: md5.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/md5passwd.c b/cups/md5passwd.c index a0dc2cf5b..135282c50 100644 --- a/cups/md5passwd.c +++ b/cups/md5passwd.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: md5passwd.c 10996 2013-05-29 11:51:34Z msweet $" * * MD5 password support for CUPS. * @@ -138,5 +138,5 @@ httpMD5String(const unsigned char *sum, /* I - MD5 sum data */ /* - * End of "$Id$". + * End of "$Id: md5passwd.c 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/notify.c b/cups/notify.c index 69363aa15..7e5cebb28 100644 --- a/cups/notify.c +++ b/cups/notify.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: notify.c 10996 2013-05-29 11:51:34Z msweet $" * * Notification routines for CUPS. * @@ -198,5 +198,5 @@ cupsNotifyText(cups_lang_t *lang, /* I - Language data */ /* - * End of "$Id$". + * End of "$Id: notify.c 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/options.c b/cups/options.c index 073edaee9..8f05bb8f4 100644 --- a/cups/options.c +++ b/cups/options.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: options.c 11984 2014-07-02 13:16:59Z msweet $" * * Option routines for CUPS. * @@ -694,5 +694,5 @@ cups_find_option( /* - * End of "$Id$". + * End of "$Id: options.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/ppd-attr.c b/cups/ppd-attr.c index c98a36b47..7db8329d0 100644 --- a/cups/ppd-attr.c +++ b/cups/ppd-attr.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-attr.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD model-specific attribute routines for CUPS. * @@ -317,5 +317,5 @@ _ppdNormalizeMakeAndModel( /* - * End of "$Id$". + * End of "$Id: ppd-attr.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index e02d44355..995574f8a 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-cache.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD cache implementation for CUPS. * @@ -3835,5 +3835,5 @@ pwg_unppdize_name(const char *ppd, /* I - PPD keyword */ /* - * End of "$Id$". + * End of "$Id: ppd-cache.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-conflicts.c b/cups/ppd-conflicts.c index 31a82d779..c518670ef 100644 --- a/cups/ppd-conflicts.c +++ b/cups/ppd-conflicts.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-conflicts.c 13138 2016-03-15 14:59:54Z msweet $" * * Option conflict management routines for CUPS. * @@ -1196,5 +1196,5 @@ ppd_test_constraints( /* - * End of "$Id$". + * End of "$Id: ppd-conflicts.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-custom.c b/cups/ppd-custom.c index 5f5272ce3..ba08be20f 100644 --- a/cups/ppd-custom.c +++ b/cups/ppd-custom.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-custom.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD custom option routines for CUPS. * @@ -112,5 +112,5 @@ ppdNextCustomParam(ppd_coption_t *opt) /* I - Custom option */ /* - * End of "$Id$". + * End of "$Id: ppd-custom.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-emit.c b/cups/ppd-emit.c index e750029ef..b4b418a08 100644 --- a/cups/ppd-emit.c +++ b/cups/ppd-emit.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-emit.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD code emission routines for CUPS. * @@ -1203,5 +1203,5 @@ ppd_handle_media(ppd_file_t *ppd) /* I - PPD file */ /* - * End of "$Id$". + * End of "$Id: ppd-emit.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-localize.c b/cups/ppd-localize.c index 9f837b87e..3f853b738 100644 --- a/cups/ppd-localize.c +++ b/cups/ppd-localize.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-localize.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD localization routines for CUPS. * @@ -775,5 +775,5 @@ ppd_ll_CC(char *ll_CC, /* O - Country-specific locale name */ /* - * End of "$Id$". + * End of "$Id: ppd-localize.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-mark.c b/cups/ppd-mark.c index 0fddab5c3..82684d001 100644 --- a/cups/ppd-mark.c +++ b/cups/ppd-mark.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-mark.c 13138 2016-03-15 14:59:54Z msweet $" * * Option marking routines for CUPS. * @@ -1085,5 +1085,5 @@ ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */ /* - * End of "$Id$". + * End of "$Id: ppd-mark.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-page.c b/cups/ppd-page.c index f7eb62b4a..7e86126bf 100644 --- a/cups/ppd-page.c +++ b/cups/ppd-page.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-page.c 13138 2016-03-15 14:59:54Z msweet $" * * Page size functions for CUPS. * @@ -385,5 +385,5 @@ ppdPageLength(ppd_file_t *ppd, /* I - PPD file */ /* - * End of "$Id$". + * End of "$Id: ppd-page.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-private.h b/cups/ppd-private.h index b8254446a..c978054ba 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-private.h 13138 2016-03-15 14:59:54Z msweet $" * * Private PPD definitions for CUPS. * @@ -249,5 +249,5 @@ extern const char *_pwgPageSizeForMedia(pwg_media_t *media, #endif /* !_CUPS_PPD_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: ppd-private.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd-util.c b/cups/ppd-util.c index 918ab78d6..2bfd3f5c6 100644 --- a/cups/ppd-util.c +++ b/cups/ppd-util.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd-util.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD utilities for CUPS. * @@ -719,5 +719,5 @@ cups_get_printer_uri( /* - * End of "$Id$". + * End of "$Id: ppd-util.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd.c b/cups/ppd.c index 21443e6b0..9db8ddcc6 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD file routines for CUPS. * @@ -3456,5 +3456,5 @@ ppd_update_filters(ppd_file_t *ppd, /* I - PPD file */ /* - * End of "$Id$". + * End of "$Id: ppd.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/ppd.h b/cups/ppd.h index c5989835d..e4a30ebfe 100644 --- a/cups/ppd.h +++ b/cups/ppd.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: ppd.h 13138 2016-03-15 14:59:54Z msweet $" * * PostScript Printer Description definitions for CUPS. * @@ -484,5 +484,5 @@ extern int ppdPageSizeLimits(ppd_file_t *ppd, #endif /* !_CUPS_PPD_H_ */ /* - * End of "$Id$". + * End of "$Id: ppd.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/pwg.h b/cups/pwg.h index 505778e15..43e0e1c84 100644 --- a/cups/pwg.h +++ b/cups/pwg.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: pwg.h 4274 2013-04-09 20:10:23Z msweet $" * * PWG media API definitions for CUPS. * @@ -90,5 +90,5 @@ extern pwg_media_t *pwgMediaForSize(int width, int length) _CUPS_API_1_7; #endif /* !_CUPS_PWG_H_ */ /* - * End of "$Id$". + * End of "$Id: pwg.h 4274 2013-04-09 20:10:23Z msweet $". */ diff --git a/cups/raster-private.h b/cups/raster-private.h index 95e54dc02..e506c6482 100644 --- a/cups/raster-private.h +++ b/cups/raster-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: raster-private.h 13138 2016-03-15 14:59:54Z msweet $" * * Private image library definitions for CUPS. * @@ -62,5 +62,5 @@ extern void _cupsRasterClearError(void); #endif /* !_CUPS_RASTER_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: raster-private.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/request.c b/cups/request.c index 881bffd5b..caea4dd38 100644 --- a/cups/request.c +++ b/cups/request.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: request.c 11984 2014-07-02 13:16:59Z msweet $" * * IPP utilities for CUPS. * @@ -1189,5 +1189,5 @@ _cupsSetHTTPError(http_status_t status) /* I - HTTP status code */ /* - * End of "$Id$". + * End of "$Id: request.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/sidechannel.c b/cups/sidechannel.c index 8dc2ce0ff..2214a52c2 100644 --- a/cups/sidechannel.c +++ b/cups/sidechannel.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: sidechannel.c 13138 2016-03-15 14:59:54Z msweet $" * * Side-channel API code for CUPS. * @@ -625,5 +625,5 @@ cupsSideChannelWrite( /* - * End of "$Id$". + * End of "$Id: sidechannel.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/sidechannel.h b/cups/sidechannel.h index 48353d1ee..4694bb974 100644 --- a/cups/sidechannel.h +++ b/cups/sidechannel.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: sidechannel.h 10996 2013-05-29 11:51:34Z msweet $" * * Side-channel API definitions for CUPS. * @@ -143,5 +143,5 @@ extern cups_sc_status_t cupsSideChannelSNMPWalk(const char *oid, double timeout, #endif /* !_CUPS_SIDECHANNEL_H_ */ /* - * End of "$Id$". + * End of "$Id: sidechannel.h 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/snmp-private.h b/cups/snmp-private.h index 604456191..1ca37e9b8 100644 --- a/cups/snmp-private.h +++ b/cups/snmp-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: snmp-private.h 11984 2014-07-02 13:16:59Z msweet $" * * Private SNMP definitions for CUPS. * @@ -142,5 +142,5 @@ extern int _cupsSNMPWrite(int fd, http_addr_t *address, int version, /* - * End of "$Id$". + * End of "$Id: snmp-private.h 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/snmp.c b/cups/snmp.c index 4c62f959f..b8e91d1b7 100644 --- a/cups/snmp.c +++ b/cups/snmp.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: snmp.c 11984 2014-07-02 13:16:59Z msweet $" * * SNMP functions for CUPS. * @@ -1677,5 +1677,5 @@ snmp_set_error(cups_snmp_t *packet, /* I - Packet */ /* - * End of "$Id$". + * End of "$Id: snmp.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/snprintf.c b/cups/snprintf.c index 9af6b90f8..4029d2c1d 100644 --- a/cups/snprintf.c +++ b/cups/snprintf.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: snprintf.c 10996 2013-05-29 11:51:34Z msweet $" * * snprintf functions for CUPS. * @@ -361,6 +361,6 @@ _cups_snprintf(char *buffer, /* O - Output buffer */ /* - * End of "$Id$". + * End of "$Id: snprintf.c 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/string-private.h b/cups/string-private.h index 845bfc9d2..df2398822 100644 --- a/cups/string-private.h +++ b/cups/string-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: string-private.h 13138 2016-03-15 14:59:54Z msweet $" * * Private string definitions for CUPS. * @@ -219,5 +219,5 @@ extern char *_cupsStrDate(char *buf, size_t bufsize, time_t timeval); #endif /* !_CUPS_STRING_H_ */ /* - * End of "$Id$". + * End of "$Id: string-private.h 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/string.c b/cups/string.c index 19d1224f4..e6d193b03 100644 --- a/cups/string.c +++ b/cups/string.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: string.c 11984 2014-07-02 13:16:59Z msweet $" * * String functions for CUPS. * @@ -772,5 +772,5 @@ compare_sp_items(_cups_sp_item_t *a, /* I - First item */ /* - * End of "$Id$". + * End of "$Id: string.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/tempfile.c b/cups/tempfile.c index 495eeb29c..03a50bb2f 100644 --- a/cups/tempfile.c +++ b/cups/tempfile.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: tempfile.c 13138 2016-03-15 14:59:54Z msweet $" * * Temp file utilities for CUPS. * @@ -195,5 +195,5 @@ cupsTempFile2(char *filename, /* I - Pointer to buffer */ /* - * End of "$Id$". + * End of "$Id: tempfile.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testadmin.c b/cups/testadmin.c index 28dafa7f2..04b02f1c9 100644 --- a/cups/testadmin.c +++ b/cups/testadmin.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testadmin.c 10996 2013-05-29 11:51:34Z msweet $" * * Admin function test program for CUPS. * @@ -117,5 +117,5 @@ show_settings( /* - * End of "$Id$". + * End of "$Id: testadmin.c 10996 2013-05-29 11:51:34Z msweet $". */ diff --git a/cups/testarray.c b/cups/testarray.c index dc90951ba..8752b32a0 100644 --- a/cups/testarray.c +++ b/cups/testarray.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testarray.c 11984 2014-07-02 13:16:59Z msweet $" * * Array test program for CUPS. * @@ -551,5 +551,5 @@ load_words(const char *filename, /* I - File to load */ /* - * End of "$Id$". + * End of "$Id: testarray.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/testcache.c b/cups/testcache.c index 2c92dbdc7..221076641 100644 --- a/cups/testcache.c +++ b/cups/testcache.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testcache.c 11984 2014-07-02 13:16:59Z msweet $" * * PPD cache testing program for CUPS. * @@ -94,5 +94,5 @@ main(int argc, /* I - Number of command-line args */ /* - * End of "$Id$". + * End of "$Id: testcache.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/testconflicts.c b/cups/testconflicts.c index 269c53ec3..0ccca8252 100644 --- a/cups/testconflicts.c +++ b/cups/testconflicts.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testconflicts.c 3755 2012-03-30 05:59:14Z msweet $" * * PPD constraint test program for CUPS. * @@ -134,5 +134,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id$". + * End of "$Id: testconflicts.c 3755 2012-03-30 05:59:14Z msweet $". */ diff --git a/cups/testcups.c b/cups/testcups.c index 74d0660bf..91d38c422 100644 --- a/cups/testcups.c +++ b/cups/testcups.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testcups.c 11984 2014-07-02 13:16:59Z msweet $" * * CUPS API test program for CUPS. * @@ -585,5 +585,5 @@ show_diffs(cups_dest_t *a, /* I - First destination */ /* - * End of "$Id$". + * End of "$Id: testcups.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/testdest.c b/cups/testdest.c index 50835eceb..22df1bf77 100644 --- a/cups/testdest.c +++ b/cups/testdest.c @@ -713,5 +713,5 @@ usage(const char *arg) /* I - Argument for usage message */ /* - * End of "$Id$". + * End of "$Id: testdest.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testfile.c b/cups/testfile.c index 9dbd8d549..df80aa218 100644 --- a/cups/testfile.c +++ b/cups/testfile.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testfile.c 13138 2016-03-15 14:59:54Z msweet $" * * File test program for CUPS. * @@ -825,5 +825,5 @@ read_write_tests(int compression) /* I - Use compression? */ /* - * End of "$Id$". + * End of "$Id: testfile.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testhttp.c b/cups/testhttp.c index 1c6bcb2cb..a7f36e9a7 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testhttp.c 13138 2016-03-15 14:59:54Z msweet $" * * HTTP test program for CUPS. * @@ -889,5 +889,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id$". + * End of "$Id: testhttp.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testhuffman.c b/cups/testhuffman.c new file mode 100644 index 000000000..e5a2d2ef7 --- /dev/null +++ b/cups/testhuffman.c @@ -0,0 +1,207 @@ +/* + * "$Id: testhuffman.c 11992 2014-07-03 13:54:10Z msweet $" + * + * HTTP/2 Huffman compression/decompression unit tests for CUPS. + * + * Copyright 2014 by Apple Inc. + * + * 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. + */ + +/* + * Include necessary headers... + */ + +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "http.h" +#include "huffman-private.h" + + +/* + * Test data (from HPACK-08)... + */ + +typedef struct _http2_huffman_test_s +{ + const char *s; /* Literal string */ + unsigned char h[256]; /* Huffman string */ + size_t hlen; /* Length of Huffman string */ +} _http2_huffman_test_t; + +static const _http2_huffman_test_t test_data[] = +{ + { "www.example.com", { 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff }, 12 }, + { "no-cache", { 0xa8, 0xeb, 0x10, 0x64, 0x9c, 0xbf }, 6 }, + { "custom-key", { 0x25, 0xa8, 0x49, 0xe9, 0x5b, 0xa9, 0x7d, 0x7f }, 8 }, + { "custom-value", { 0x25, 0xa8, 0x49, 0xe9, 0x5b, 0xb8, 0xe8, 0xb4, 0xbf }, 9 }, + { "302", { 0x64, 0x02 }, 2 }, + { "private", { 0xae, 0xc3, 0x77, 0x1a, 0x4b }, 5 }, + { "Mon, 21 Oct 2013 20:13:21 GMT", { 0xd0, 0x7a, 0xbe, 0x94, 0x10, 0x54, 0xd4, 0x44, 0xa8, 0x20, 0x05, 0x95, 0x04, 0x0b, 0x81, 0x66, 0xe0, 0x82, 0xa6, 0x2d, 0x1b, 0xff }, 22 }, + { "https://www.example.com", { 0x9d, 0x29, 0xad, 0x17, 0x18, 0x63, 0xc7, 0x8f, 0x0b, 0x97, 0xc8, 0xe9, 0xae, 0x82, 0xae, 0x43, 0xd3 }, 17 }, + { "Mon, 21 Oct 2013 20:13:22 GMT", { 0xd0, 0x7a, 0xbe, 0x94, 0x10, 0x54, 0xd4, 0x44, 0xa8, 0x20, 0x05, 0x95, 0x04, 0x0b, 0x81, 0x66, 0xe0, 0x84, 0xa6, 0x2d, 0x1b, 0xff }, 22 }, + { "gzip", { 0x9b, 0xd9, 0xab }, 3 }, + { "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", { 0x94, 0xe7, 0x82, 0x1d, 0xd7, 0xf2, 0xe6, 0xc7, 0xb3, 0x35, 0xdf, 0xdf, 0xcd, 0x5b, 0x39, 0x60, 0xd5, 0xaf, 0x27, 0x08, 0x7f, 0x36, 0x72, 0xc1, 0xab, 0x27, 0x0f, 0xb5, 0x29, 0x1f, 0x95, 0x87, 0x31, 0x60, 0x65, 0xc0, 0x03, 0xed, 0x4e, 0xe5, 0xb1, 0x06, 0x3d, 0x50, 0x07 }, 45 } +}; + + +/* + * Local functions... + */ + +static void printhex(const unsigned char *data, size_t len); + + +/* + * 'main()' - Run HTTP/2 Huffman tests. + */ + +int /* O - Exit status */ +main(void) +{ + int i, /* Looping var */ + status = 0; /* Status of test */ + char s[131072]; /* Literal string */ + size_t slen; /* Length of literal string */ + unsigned char huffdata[131072]; /* Huffman encoded data */ + size_t hufflen; /* Length of Huffman encoded data */ + unsigned char data[65536]; /* Test data to simulate Kerberos nonsense */ + char base64[131072]; + /* Base64 representation of data + "Negotiate " */ + time_t start, end; /* Timing information for benchmarks */ + + + /* + * Test examples from HPACK-08... + */ + + for (i = 0; i < (int)(sizeof(test_data) / sizeof(test_data[0])); i ++) + { + printf("_http2HuffmanEncode(\"%s\"): ", test_data[i].s); + fflush(stdout); + + hufflen = _http2HuffmanEncode(huffdata, sizeof(huffdata), test_data[i].s); + if (hufflen != test_data[i].hlen || memcmp(huffdata, test_data[i].h, hufflen)) + { + puts("FAIL"); + status = 1; + printf(" Got %d bytes: ", (int)hufflen); + printhex(huffdata, hufflen); + printf(" Expected %d bytes: ", (int)test_data[i].hlen); + printhex(test_data[i].h, test_data[i].hlen); + } + else + puts("PASS"); + + printf("_http2HuffmanDecode(\"%s\"): ", test_data[i].s); + fflush(stdout); + + slen = _http2HuffmanDecode(s, sizeof(s), test_data[i].h, test_data[i].hlen); + if (slen != strlen(test_data[i].s) || strcmp(s, test_data[i].s)) + { + puts("FAIL"); + status = 1; + if (!slen) + slen = strlen(s); + printf(" Got %d bytes: %s\n", (int)slen, s); + } + else + puts("PASS"); + } + + /* + * Test random 64k blob representing a worst-case Kerberos ticket... + */ + + CUPS_SRAND(time(NULL)); + + for (i = 0; i < (int)sizeof(data); i ++) + data[i] = i/* (unsigned char)CUPS_RAND() */; + + strlcpy(base64, "Negotiate ", sizeof(base64)); + httpEncode64_2(base64 + 10, sizeof(base64) - 10, (char *)data, sizeof(data)); + + fputs("_http2HuffmanEncode(kerberos ticket): ", stdout); + fflush(stdout); + + hufflen = _http2HuffmanEncode(huffdata, sizeof(huffdata), base64); + slen = strlen(base64); + printf("PASS (%d bytes, %d%% of original %d bytes)\n", (int)hufflen, (int)(100 * hufflen / slen), (int)slen); + + fputs("_http2HuffmanDecode(kerberos ticket): ", stdout); + fflush(stdout); + + slen = _http2HuffmanDecode(s, sizeof(s), huffdata, hufflen); + if (slen != strlen(base64) || strcmp(s, base64)) + { + const char *sptr, *bptr; + + puts("FAIL"); + status = 1; + + for (sptr = s, bptr = base64; *sptr && *bptr; sptr ++, bptr ++) + if (*sptr != *bptr) + break; + + if (!slen) + slen = strlen(s); + printf(" Got %d bytes, expected %d bytes\n", (int)slen, (int)strlen(base64)); + printf(" Difference starting at offset %d: %s\n", (int)(sptr - s), sptr); + printf(" Expected: %s\n", bptr); + } + else + puts("PASS"); + + puts("\nBenchmarks:\n"); + +#define TESTENCODE 25000 + time(&start); + for (i = 0; i < TESTENCODE; i ++) + hufflen = _http2HuffmanEncode(huffdata, sizeof(huffdata), base64); + time(&end); + + slen = strlen(base64); + printf(" _http2HuffmanEncode: %.1f MB/second\n", (double)slen * TESTENCODE / (end - start) / 1024 / 1024); + +#define TESTDECODE 2500 + time(&start); + for (i = 0; i < TESTDECODE; i ++) + _http2HuffmanDecode(s, sizeof(s), huffdata, hufflen); + time(&end); + + printf(" _http2HuffmanDecode: %.1f MB/second\n", (double)hufflen * TESTDECODE / (end - start) / 1024 / 1024); + + return (status); +} + + +/* + * 'printhex()' - Print a string as hex characters. + */ + +static void +printhex(const unsigned char *data, /* I - String */ + size_t len) /* I - Length */ +{ + while (len > 0) + { + printf("%02X", *data & 255); + data ++; + len --; + } + + putchar('\n'); +} + + +/* + * End of "$Id: testhuffman.c 11992 2014-07-03 13:54:10Z msweet $". + */ diff --git a/cups/testi18n.c b/cups/testi18n.c index e478428bd..cbf9109d8 100644 --- a/cups/testi18n.c +++ b/cups/testi18n.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testi18n.c 11984 2014-07-02 13:16:59Z msweet $" * * Internationalization test for CUPS. * @@ -610,5 +610,5 @@ print_utf8(const char *msg, /* I - Message String */ /* - * End of "$Id$" + * End of "$Id: testi18n.c 11984 2014-07-02 13:16:59Z msweet $" */ diff --git a/cups/testipp.c b/cups/testipp.c index 2540ff482..716072d17 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testipp.c 11984 2014-07-02 13:16:59Z msweet $" * * IPP test program for CUPS. * @@ -1051,5 +1051,5 @@ write_cb(_ippdata_t *data, /* I - Data */ /* - * End of "$Id$". + * End of "$Id: testipp.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/testlang.c b/cups/testlang.c index cc7b4f699..50011d34a 100644 --- a/cups/testlang.c +++ b/cups/testlang.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testlang.c 13138 2016-03-15 14:59:54Z msweet $" * * Localization test program for CUPS. * @@ -153,5 +153,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id$". + * End of "$Id: testlang.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testoptions.c b/cups/testoptions.c index 6c939e8c3..0a8a9b2db 100644 --- a/cups/testoptions.c +++ b/cups/testoptions.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testoptions.c 13138 2016-03-15 14:59:54Z msweet $" * * Option unit test program for CUPS. * @@ -177,5 +177,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id$". + * End of "$Id: testoptions.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testppd.c b/cups/testppd.c index b211d1d75..a0e111143 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testppd.c 13138 2016-03-15 14:59:54Z msweet $" * * PPD test program for CUPS. * @@ -1171,5 +1171,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id$". + * End of "$Id: testppd.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testpwg.c b/cups/testpwg.c index 582c8deb1..2aaea7f9d 100644 --- a/cups/testpwg.c +++ b/cups/testpwg.c @@ -572,5 +572,5 @@ test_ppd_cache(_ppd_cache_t *pc, /* I - PWG mapping data */ /* - * End of "$Id$". + * End of "$Id: testpwg.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/testsnmp.c b/cups/testsnmp.c index 66e2d76ee..8473c0297 100644 --- a/cups/testsnmp.c +++ b/cups/testsnmp.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: testsnmp.c 11984 2014-07-02 13:16:59Z msweet $" * * SNMP test program for CUPS. * @@ -293,5 +293,5 @@ usage(void) /* - * End of "$Id$". + * End of "$Id: testsnmp.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/thread-private.h b/cups/thread-private.h index 67dbe5418..3559c1add 100644 --- a/cups/thread-private.h +++ b/cups/thread-private.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: thread-private.h 11984 2014-07-02 13:16:59Z msweet $" * * Private threading definitions for CUPS. * @@ -96,5 +96,5 @@ extern int _cupsThreadCreate(_cups_thread_func_t func, void *arg); #endif /* !_CUPS_THREAD_PRIVATE_H_ */ /* - * End of "$Id$". + * End of "$Id: thread-private.h 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/thread.c b/cups/thread.c index c9c5cfb49..3f430b65f 100644 --- a/cups/thread.c +++ b/cups/thread.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: thread.c 11984 2014-07-02 13:16:59Z msweet $" * * Threading primitives for CUPS. * @@ -323,5 +323,5 @@ _cupsThreadCreate( /* - * End of "$Id$". + * End of "$Id: thread.c 11984 2014-07-02 13:16:59Z msweet $". */ diff --git a/cups/tls-gnutls.c b/cups/tls-gnutls.c index e29dd3186..474c1c692 100644 --- a/cups/tls-gnutls.c +++ b/cups/tls-gnutls.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: tls-gnutls.c 13138 2016-03-15 14:59:54Z msweet $" * * TLS support code for CUPS using GNU TLS. * @@ -1341,5 +1341,5 @@ _httpTLSWrite(http_t *http, /* I - Connection to server */ /* - * End of "$Id$". + * End of "$Id: tls-gnutls.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/tls-sspi.c b/cups/tls-sspi.c index 25be327d1..f0d2d7cc6 100644 --- a/cups/tls-sspi.c +++ b/cups/tls-sspi.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: tls-sspi.c 13138 2016-03-15 14:59:54Z msweet $" * * TLS support for CUPS on Windows using the Security Support Provider * Interface (SSPI). @@ -2427,5 +2427,5 @@ http_sspi_verify( /* - * End of "$Id$". + * End of "$Id: tls-sspi.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/tls.c b/cups/tls.c index 3f88df2c6..ef106e9a5 100644 --- a/cups/tls.c +++ b/cups/tls.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: tls.c 13138 2016-03-15 14:59:54Z msweet $" * * TLS routines for CUPS. * @@ -108,5 +108,5 @@ httpSaveCredentials(const char *path, cups_array_t *credentials, const char *com /* - * End of "$Id$". + * End of "$Id: tls.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/tlscheck.c b/cups/tlscheck.c index e78bf28c6..70f0729f6 100644 --- a/cups/tlscheck.c +++ b/cups/tlscheck.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: tlscheck.c 13138 2016-03-15 14:59:54Z msweet $" * * TLS check program for CUPS. * @@ -746,5 +746,5 @@ usage(void) /* - * End of "$Id$". + * End of "$Id: tlscheck.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/transcode.c b/cups/transcode.c index 11d4f7f7c..4664e3763 100644 --- a/cups/transcode.c +++ b/cups/transcode.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: transcode.c 13138 2016-03-15 14:59:54Z msweet $" * * Transcoding support for CUPS. * @@ -716,5 +716,5 @@ cupsUTF32ToUTF8( /* - * End of "$Id$" + * End of "$Id: transcode.c 13138 2016-03-15 14:59:54Z msweet $" */ diff --git a/cups/transcode.h b/cups/transcode.h index cafea33c5..da95d0cd6 100644 --- a/cups/transcode.h +++ b/cups/transcode.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: transcode.h 10996 2013-05-29 11:51:34Z msweet $" * * Transcoding definitions for CUPS. * @@ -77,5 +77,5 @@ extern int cupsUTF32ToUTF8(cups_utf8_t *dest, /* - * End of "$Id$" + * End of "$Id: transcode.h 10996 2013-05-29 11:51:34Z msweet $" */ diff --git a/cups/usersys.c b/cups/usersys.c index 9b3c219b7..d8aff235f 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: usersys.c 13138 2016-03-15 14:59:54Z msweet $" * * User, system, and password routines for CUPS. * @@ -1284,5 +1284,5 @@ cups_set_user( /* - * End of "$Id$". + * End of "$Id: usersys.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/util.c b/cups/util.c index 48b5bfa55..fdf8d5cae 100644 --- a/cups/util.c +++ b/cups/util.c @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: util.c 13138 2016-03-15 14:59:54Z msweet $" * * Printing utilities for CUPS. * @@ -966,5 +966,5 @@ cupsStartDocument( /* - * End of "$Id$". + * End of "$Id: util.c 13138 2016-03-15 14:59:54Z msweet $". */ diff --git a/cups/versioning.h b/cups/versioning.h index ff52d6088..83ee24381 100644 --- a/cups/versioning.h +++ b/cups/versioning.h @@ -1,5 +1,5 @@ /* - * "$Id$" + * "$Id: versioning.h 13138 2016-03-15 14:59:54Z msweet $" * * API versioning definitions for CUPS. * @@ -164,5 +164,5 @@ #endif /* !_CUPS_VERSIONING_H_ */ /* - * End of "$Id$". + * End of "$Id: versioning.h 13138 2016-03-15 14:59:54Z msweet $". */ |