Revision: 14359 Author: adrian.chadd Date: Wed Nov 4 15:54:09 2009 Log: Revert r14357; I committed too much.
http://code.google.com/p/lusca-cache/source/detail?r=14359 Deleted: /branches/LUSCA_HEAD/include/hex.h /branches/LUSCA_HEAD/lib/hex.c Modified: /branches/LUSCA_HEAD/contrib/build_wrap /branches/LUSCA_HEAD/lib/Makefile.am /branches/LUSCA_HEAD/lib/rfc1738.c /branches/LUSCA_HEAD/src/store_key_md5.c ======================================= --- /branches/LUSCA_HEAD/include/hex.h Wed Nov 4 14:56:03 2009 +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __INCLUDE_HEX_H__ -#define __INCLUDE_HEX_H__ - -extern void hex_from_byte_array(char *dst, const char *src, int srclen); - -#endif ======================================= --- /branches/LUSCA_HEAD/lib/hex.c Wed Nov 4 14:56:03 2009 +++ /dev/null @@ -1,20 +0,0 @@ -#include "../include/config.h" - -/* XXX this should be uhm, a library function! [ahc] */ -static char tohex[] = { '0','1','2','3','4','5','6','7','8','9', 'A', 'B', 'C', 'D', 'E', 'F' }; - -/* - * Create a hex string from the given byte array. - * - * It is up to the caller to ensure that there is at least 2x "srclen" bytes - * available in dst. - */ -void -hex_from_byte_array(char *dst, const char *src, int srclen) -{ - int i; - for (i = 0; i < srclen; i++) { - *(dst++) = tohex[(*src >> 4) & 0x0f]; - *(dst++) = tohex[*(src++) & 0x0f]; - } -} ======================================= --- /branches/LUSCA_HEAD/contrib/build_wrap Wed Nov 4 14:56:03 2009 +++ /branches/LUSCA_HEAD/contrib/build_wrap Wed Nov 4 15:54:09 2009 @@ -1,3 +1,3 @@ #!/bin/sh -gcc -I/usr/local/include -L/usr/local/lib -Wall -fPIC -shared -Wl,-soname,libwrap_printf.so.1.0 -o libwrap_printf.so.1.0 wrap_printf.c -lexecinfo - +gcc -Wall -fPIC -shared -Wl,-soname,libwrap_printf.so.1.0 -ldl -o libwrap_printf.so.1.0 wrap_printf.c + ======================================= --- /branches/LUSCA_HEAD/lib/Makefile.am Wed Nov 4 14:56:03 2009 +++ /branches/LUSCA_HEAD/lib/Makefile.am Wed Nov 4 15:54:09 2009 @@ -40,7 +40,6 @@ getfullhostname.c \ hash.c \ heap.c \ - hex.c \ html_quote.c \ iso3307.c \ md5.c \ ======================================= --- /branches/LUSCA_HEAD/lib/rfc1738.c Wed Nov 4 14:56:03 2009 +++ /branches/LUSCA_HEAD/lib/rfc1738.c Wed Nov 4 15:54:09 2009 @@ -43,50 +43,9 @@ #include "util.h" -static char rfc1738_unsafe_char_map[] = -{ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -}; - -static char rfc1738_reserved_char_map[] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -#if 0 /* * RFC 1738 defines that these characters should be escaped, as well - * any non-US-ASCII character and anything between 0x00 and 0x1F. + * any non-US-ASCII character or anything between 0x00 - 0x1F. */ static char rfc1738_unsafe_chars[] = { @@ -120,7 +79,6 @@ (char) 0x3d, /* = */ (char) 0x26 /* & */ }; -#endif /* * rfc1738_escape - Returns a static buffer contains the RFC 1738 @@ -133,7 +91,7 @@ static size_t bufsize = 0; const char *p; char *q; - unsigned int do_escape; + unsigned int i, do_escape; if (buf == NULL || strlen(url) * 3 > bufsize) { xfree(buf); @@ -143,16 +101,35 @@ for (p = url, q = buf; *p != '\0'; p++, q++) { do_escape = 0; - if (rfc1738_unsafe_char_map[(int) *p] > 0) - do_escape = 1; - + /* RFC 1738 defines these chars as unsafe */ + for (i = 0; i < sizeof(rfc1738_unsafe_chars); i++) { + if (*p == rfc1738_unsafe_chars[i]) { + do_escape = 1; + break; + } + } /* Handle % separately */ if (encode_reserved >= 0 && *p == '%') do_escape = 1; - - if (encode_reserved > 0 && rfc1738_reserved_char_map[ (int) *p ] > 0) + /* RFC 1738 defines these chars as reserved */ + for (i = 0; i < sizeof(rfc1738_reserved_chars) && encode_reserved > 0; i++) { + if (*p == rfc1738_reserved_chars[i]) { do_escape = 1; - + break; + } + } + /* RFC 1738 says any control chars (0x00-0x1F) are encoded */ + if ((unsigned char) *p <= (unsigned char) 0x1F) { + do_escape = 1; + } + /* RFC 1738 says 0x7f is encoded */ + if (*p == (char) 0x7F) { + do_escape = 1; + } + /* RFC 1738 says any non-US-ASCII are encoded */ + if (((unsigned char) *p >= (unsigned char) 0x80)) { + do_escape = 1; + } /* Do the triplet encoding, or just copy the char */ /* note: we do not need snprintf here as q is appropriately * allocated - KA */ ======================================= --- /branches/LUSCA_HEAD/src/store_key_md5.c Wed Nov 4 14:56:03 2009 +++ /branches/LUSCA_HEAD/src/store_key_md5.c Wed Nov 4 15:54:09 2009 @@ -35,18 +35,24 @@ #include "squid.h" -#include "../include/hex.h" - static cache_key null_key[SQUID_MD5_DIGEST_LENGTH]; static MemPool * pool_md5_key = NULL; +/* XXX this should be uhm, a library function! [ahc] */ +static char tohex[] = { '0','1','2','3','4','5','6','7','8','9', 'A', 'B', 'C', 'D', 'E', 'F' }; + const char * storeKeyText(const unsigned char *key) { static char buf[SQUID_MD5_DIGEST_LENGTH*2+1]; - - hex_from_byte_array(buf, (char *) key, SQUID_MD5_DIGEST_LENGTH); - buf[SQUID_MD5_DIGEST_LENGTH*2] = '\0'; + char *b = buf; + int i; + + for (i = 0; i < SQUID_MD5_DIGEST_LENGTH; i++) { + *(b++) = tohex[(key[i] >> 4) & 0x0f]; + *(b++) = tohex[key[i] & 0x0f]; + } + *b = '\0'; return buf; } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "lusca-commit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/lusca-commit?hl=en -~----------~----~----~----~------~----~------~--~---
