mod-xhtml-neg-cvs Mailing List for XHTML negotiation module (Page 2)
Brought to you by:
run2000
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(51) |
Apr
(37) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ru...@us...> - 2004-04-11 00:16:29
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17036 Modified Files: mod_xhtml_neg.c Log Message: Parse q-values more in keeping with RFC2616. This now always works the same way regardless of system locale. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** mod_xhtml_neg.c 2 Apr 2004 10:41:19 -0000 1.23 --- mod_xhtml_neg.c 11 Apr 2004 00:02:55 -0000 1.24 *************** *** 77,81 **** * @author Nicholas Cull <ru...@us...> * @date 1 March 2004 ! * @version 0.93 * * @history --- 77,81 ---- * @author Nicholas Cull <ru...@us...> * @date 1 March 2004 ! * @version 0.94 * * @history *************** *** 87,90 **** --- 87,91 ---- * 0.92 Pick up the AddDefaultCharset directive from the Apache core \n * 0.93 Use a better hash function for ETag uniqueness \n + * 0.94 Parse q-values correctly irrespective of system locale \n * * @directive *************** *** 496,499 **** --- 497,567 ---- } + /* + * Taken from a mod_negotiation fix on the Apache 2.1 branch. + */ + + /** + * Parse quality value. atof(3) is not well-usable here, because it depends + * on the locale (argh). + * + * However, RFC 2616 states: \n + * 3.9 Quality Values + * + * [...] HTTP/1.1 applications MUST NOT generate more than three digits + * after the decimal point. User configuration of these values SHOULD also + * be limited in this fashion. + * + * qvalue = ( "0" [ "." 0*3DIGIT ] ) + * | ( "1" [ "." 0*3("0") ] ) + * + * This is quite easy. If the supplied string doesn't match the above + * definition (loosely), we simply return 1 (same as if there's no q-value) + * + * @param string a string containing a q-value to be parsed + * @return the parsed q-value, truncated to three decimal places if necessary + */ + + static float mod_xhtml_atoq(const char *string) + { + if (mod_xhtml_strempty(string)) { + return 1.0f; + } + + while (*string && apr_isspace(*string)) { + ++string; + } + + /* Be tolerant and accept qvalues without leading zero + * (also for backwards compat, where atof() was in use) + * This also handles the 1.0 case. + */ + if (*string != '.' && *string++ != '0') { + return 1.0f; + } + + if (*string == '.') { + /* Better only one division later, than dealing with fscking + * IEEE format 0.1 factors ... + */ + int i = 0; + + if (*++string >= '0' && *string <= '9') { + i += (*string - '0') * 100; + + if (*++string >= '0' && *string <= '9') { + i += (*string - '0') * 10; + + if (*++string > '0' && *string <= '9') { + i += (*string - '0'); + } + } + } + + return (float)i / 1000.0f; + } + + return 0.0f; + } + /** * This naughty function goes digging into the Apache http_core module *************** *** 850,854 **** if (parm[0] == 'q' && (parm[1] == '\0' || (parm[1] == 's' && parm[2] == '\0'))) { ! result->q_value = (float)atof(cp); } else if (mod_xhtml_strcmp(parm, "charset") == 0) { --- 918,922 ---- if (parm[0] == 'q' && (parm[1] == '\0' || (parm[1] == 's' && parm[2] == '\0'))) { ! result->q_value = (float)mod_xhtml_atoq(cp); } else if (mod_xhtml_strcmp(parm, "charset") == 0) { |
From: <ru...@us...> - 2004-04-11 00:11:01
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16112 Modified Files: mod_xhtml_neg.c Log Message: Doxygen update. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** mod_xhtml_neg.c 10 Apr 2004 23:44:06 -0000 1.37 --- mod_xhtml_neg.c 10 Apr 2004 23:57:26 -0000 1.38 *************** *** 87,90 **** --- 87,91 ---- * 0.92 Pick up the AddDefaultCharset directive from the Apache core \n * 0.93 Use a better hash function for ETag uniqueness \n + * 0.94 Parse q-values correctly irrespective of system locale \n * * @directive *************** *** 501,505 **** * on the locale (argh). * ! * However, RFC 2616 states: * 3.9 Quality Values * --- 502,506 ---- * on the locale (argh). * ! * However, RFC 2616 states: \n * 3.9 Quality Values * |
From: <ru...@us...> - 2004-04-10 23:57:41
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13934 Modified Files: mod_xhtml_neg.c Log Message: Parse q-values correctly in Accept and Accept-Charset headers, regardless of the locale settings. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** mod_xhtml_neg.c 2 Apr 2004 10:40:41 -0000 1.36 --- mod_xhtml_neg.c 10 Apr 2004 23:44:06 -0000 1.37 *************** *** 493,496 **** --- 493,563 ---- } + /* + * Taken from a mod_negotiation fix on the Apache 2.1 branch. + */ + + /** + * Parse quality value. atof(3) is not well-usable here, because it depends + * on the locale (argh). + * + * However, RFC 2616 states: + * 3.9 Quality Values + * + * [...] HTTP/1.1 applications MUST NOT generate more than three digits + * after the decimal point. User configuration of these values SHOULD also + * be limited in this fashion. + * + * qvalue = ( "0" [ "." 0*3DIGIT ] ) + * | ( "1" [ "." 0*3("0") ] ) + * + * This is quite easy. If the supplied string doesn't match the above + * definition (loosely), we simply return 1 (same as if there's no q-value) + * + * @param string a string containing a q-value to be parsed + * @return the parsed q-value, truncated to three decimal places if necessary + */ + + static float mod_xhtml_atoq(const char *string) + { + if (mod_xhtml_strempty(string)) { + return 1.0f; + } + + while (*string && ap_isspace(*string)) { + ++string; + } + + /* Be tolerant and accept qvalues without leading zero + * (also for backwards compat, where atof() was in use) + * This also handles the 1.0 case. + */ + if (*string != '.' && *string++ != '0') { + return 1.0f; + } + + if (*string == '.') { + /* Better only one division later, than dealing with fscking + * IEEE format 0.1 factors ... + */ + int i = 0; + + if (*++string >= '0' && *string <= '9') { + i += (*string - '0') * 100; + + if (*++string >= '0' && *string <= '9') { + i += (*string - '0') * 10; + + if (*++string > '0' && *string <= '9') { + i += (*string - '0'); + } + } + } + + return (float)i / 1000.0f; + } + + return 0.0f; + } + /** * This naughty function goes digging into the Apache http_core module *************** *** 845,849 **** if (parm[0] == 'q' && (parm[1] == '\0' || (parm[1] == 's' && parm[2] == '\0'))) { ! result->q_value = (float)atof(cp); } else if (mod_xhtml_strcmp(parm, "charset") == 0) { --- 912,916 ---- if (parm[0] == 'q' && (parm[1] == '\0' || (parm[1] == 's' && parm[2] == '\0'))) { ! result->q_value = (float)mod_xhtml_atoq(cp); } else if (mod_xhtml_strcmp(parm, "charset") == 0) { |
From: <ru...@us...> - 2004-04-02 10:53:31
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19598 Modified Files: mod_xhtml_neg.c Log Message: Removed some unused variables following lint parse. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** mod_xhtml_neg.c 2 Apr 2004 09:09:30 -0000 1.22 --- mod_xhtml_neg.c 2 Apr 2004 10:41:19 -0000 1.23 *************** *** 642,646 **** char *data; unsigned long hash; ! int len, i; data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); --- 642,646 ---- char *data; unsigned long hash; ! int len; data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); *************** *** 926,931 **** { apr_array_header_t *accept_recs; ! accept_rec *list, *item; ! int star_found, iso8859_found, i; if (accept_charset_line == NULL) { --- 926,930 ---- { apr_array_header_t *accept_recs; ! int star_found, iso8859_found; if (accept_charset_line == NULL) { |
From: <ru...@us...> - 2004-04-02 10:52:48
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19471 Modified Files: mod_xhtml_neg.c Log Message: Removed some unused variables following lint parse. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** mod_xhtml_neg.c 2 Apr 2004 09:10:40 -0000 1.35 --- mod_xhtml_neg.c 2 Apr 2004 10:40:41 -0000 1.36 *************** *** 639,643 **** char *data; unsigned long hash; ! int len, i; data = ap_pstrcat( p, rec->name, ";", rec->charset, NULL ); --- 639,643 ---- char *data; unsigned long hash; ! int len; data = ap_pstrcat( p, rec->name, ";", rec->charset, NULL ); *************** *** 920,925 **** { array_header *accept_recs; ! accept_rec *list, *item; ! int star_found, iso8859_found, i; if (accept_charset_line == NULL) { --- 920,924 ---- { array_header *accept_recs; ! int star_found, iso8859_found; if (accept_charset_line == NULL) { |
From: <ru...@us...> - 2004-04-02 09:22:46
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3546 Modified Files: mod_xhtml_neg.c Log Message: Always set a Vary header regardless of the HTTP version. This deals with some proxy servers that aren't smart about dealing with 1.0 requests and responses. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** mod_xhtml_neg.c 1 Apr 2004 10:52:34 -0000 1.34 --- mod_xhtml_neg.c 2 Apr 2004 09:10:40 -0000 1.35 *************** *** 1423,1429 **** r->no_cache = 1; } - } else { - set_vary_header(r); } return OK; --- 1423,1428 ---- r->no_cache = 1; } } + set_vary_header(r); return OK; |
From: <ru...@us...> - 2004-04-02 09:21:36
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3361 Modified Files: mod_xhtml_neg.c Log Message: Always set a Vary header regardless of the HTTP version. This deals with some proxy servers that aren't smart about dealing with 1.0 requests and responses. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** mod_xhtml_neg.c 1 Apr 2004 11:11:00 -0000 1.21 --- mod_xhtml_neg.c 2 Apr 2004 09:09:30 -0000 1.22 *************** *** 1436,1442 **** r->no_cache = 1; } - } else { - set_vary_header(r); } return DECLINED; --- 1436,1441 ---- r->no_cache = 1; } } + set_vary_header(r); return DECLINED; |
From: <ru...@us...> - 2004-04-01 11:22:58
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18079 Modified Files: mod_xhtml_neg.c Log Message: Minor Doxygen fix. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** mod_xhtml_neg.c 1 Apr 2004 10:52:02 -0000 1.20 --- mod_xhtml_neg.c 1 Apr 2004 11:11:00 -0000 1.21 *************** *** 591,595 **** * request * @param content_rec the accept_rec that matched the content negotiation ! * @return a string that contains a correctly formatted content-type value * @todo should we send the "profile" parameter as well? */ --- 591,596 ---- * request * @param content_rec the accept_rec that matched the content negotiation ! * @return a string that contains a correctly formatted content-type value, ! * or NULL if there is no valid record * @todo should we send the "profile" parameter as well? */ |
From: <ru...@us...> - 2004-04-01 11:09:38
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15674 Modified Files: Doxyfile Log Message: Updated Doxyfile for 0.94. Index: Doxyfile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/Doxyfile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Doxyfile 31 Mar 2004 09:31:09 -0000 1.4 --- Doxyfile 1 Apr 2004 10:57:40 -0000 1.5 *************** *** 24,28 **** # if some version control system is used. ! PROJECT_NUMBER = 0.93 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) --- 24,28 ---- # if some version control system is used. ! PROJECT_NUMBER = 0.94 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) |
From: <ru...@us...> - 2004-04-01 11:09:13
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15606 Modified Files: Doxyfile Log Message: Updated Doxyfile for 0.94. Index: Doxyfile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/Doxyfile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Doxyfile 31 Mar 2004 09:33:57 -0000 1.4 --- Doxyfile 1 Apr 2004 10:57:16 -0000 1.5 *************** *** 24,28 **** # if some version control system is used. ! PROJECT_NUMBER = 0.93 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) --- 24,28 ---- # if some version control system is used. ! PROJECT_NUMBER = 0.94 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) |
From: <ru...@us...> - 2004-04-01 11:04:32
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14600 Modified Files: mod_xhtml_neg.c Log Message: Move notes in Doxygen comments into @note tags. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** mod_xhtml_neg.c 1 Apr 2004 10:27:32 -0000 1.33 --- mod_xhtml_neg.c 1 Apr 2004 10:52:34 -0000 1.34 *************** *** 588,592 **** * request * @param content_rec the accept_rec that matched the content negotiation ! * @return a string that contains a correctly formatted content-type value * @todo should we send the "profile" parameter as well? */ --- 588,593 ---- * request * @param content_rec the accept_rec that matched the content negotiation ! * @return a string that contains a correctly formatted content-type value, ! * or NULL if there is no valid record * @todo should we send the "profile" parameter as well? */ *************** *** 620,624 **** * The hash function is a hash in the public domain by By Bob Jenkins. See * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. ! * Note that since we're only using this algorithm for Etag uniqueness rather * than for a hashtable lookup, DoS attacks such as those described in * http://www.cs.rice.edu/~scrosby/hash/ are not an issue here, especially --- 621,626 ---- * The hash function is a hash in the public domain by By Bob Jenkins. See * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. ! * ! * @note Since we're only using this algorithm for Etag uniqueness rather * than for a hashtable lookup, DoS attacks such as those described in * http://www.cs.rice.edu/~scrosby/hash/ are not an issue here, especially *************** *** 649,654 **** * Make an accept_rec with an explicit charset. If the record already * contains a charset parameter, it is returned as-is. Otherwise, the ! * parameter default_charset is used. Note that default_charset can be ! * NULL, in which case charset will be set to the empty string. * * @param p a memory pool from which we can allocate temporary memory for this --- 651,658 ---- * Make an accept_rec with an explicit charset. If the record already * contains a charset parameter, it is returned as-is. Otherwise, the ! * parameter default_charset is used. ! * ! * @note default_charset can be NULL, in which case charset will be set to ! * the empty string. * * @param p a memory pool from which we can allocate temporary memory for this |
From: <ru...@us...> - 2004-04-01 11:03:59
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14503 Modified Files: mod_xhtml_neg.c Log Message: Move notes in Doxygen comments into @note tags. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mod_xhtml_neg.c 1 Apr 2004 10:28:17 -0000 1.19 --- mod_xhtml_neg.c 1 Apr 2004 10:52:02 -0000 1.20 *************** *** 623,627 **** * The hash function is a hash in the public domain by By Bob Jenkins. See * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. ! * Note that since we're only using this algorithm for Etag uniqueness rather * than for a hashtable lookup, DoS attacks such as those described in * http://www.cs.rice.edu/~scrosby/hash/ are not an issue here, especially --- 623,628 ---- * The hash function is a hash in the public domain by By Bob Jenkins. See * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. ! * ! * @note Since we're only using this algorithm for Etag uniqueness rather * than for a hashtable lookup, DoS attacks such as those described in * http://www.cs.rice.edu/~scrosby/hash/ are not an issue here, especially *************** *** 652,657 **** * Make an accept_rec with an explicit charset. If the record already * contains a charset parameter, it is returned as-is. Otherwise, the ! * parameter default_charset is used. Note that default_charset can be ! * NULL, in which case charset will be set to the empty string. * * @param p a memory pool from which we can allocate temporary memory for this --- 653,660 ---- * Make an accept_rec with an explicit charset. If the record already * contains a charset parameter, it is returned as-is. Otherwise, the ! * parameter default_charset is used. ! * ! * @note default_charset can be NULL, in which case charset will be set to ! * the empty string. * * @param p a memory pool from which we can allocate temporary memory for this *************** *** 1285,1289 **** * here. This is mainly setup, control flow and logging going on here. * ! * Note that due to the way we hook into the Apache handler system means * we always return DECLINED, even though handling was a success. * We do this so that the default handler will always run, and so that --- 1288,1292 ---- * here. This is mainly setup, control flow and logging going on here. * ! * @note Due to the way we hook into the Apache handler system means * we always return DECLINED, even though handling was a success. * We do this so that the default handler will always run, and so that |
From: <ru...@us...> - 2004-04-01 10:40:14
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9994 Modified Files: lookupa.c mod_xhtml_neg.c Log Message: Fix minor Doxygen problems. Index: lookupa.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/lookupa.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lookupa.c 31 Mar 2004 09:33:57 -0000 1.2 --- lookupa.c 1 Apr 2004 10:28:17 -0000 1.3 *************** *** 58,64 **** @brief lookup() -- hash a variable-length key into a 32-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param level can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of --- 58,64 ---- @brief lookup() -- hash a variable-length key into a 32-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param length the length of the key, counting by bytes ! @param level can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mod_xhtml_neg.c 1 Apr 2004 09:41:45 -0000 1.18 --- mod_xhtml_neg.c 1 Apr 2004 10:28:17 -0000 1.19 *************** *** 591,595 **** * request * @param content_rec the accept_rec that matched the content negotiation ! * @param a string that contains a correctly formatted content-type value * @todo should we send the "profile" parameter as well? */ --- 591,595 ---- * request * @param content_rec the accept_rec that matched the content negotiation ! * @return a string that contains a correctly formatted content-type value * @todo should we send the "profile" parameter as well? */ |
From: <ru...@us...> - 2004-04-01 10:39:34
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9840 Modified Files: lookupa.c mod_xhtml_neg.c Log Message: Fix minor Doxygen problems. Index: lookupa.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/lookupa.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lookupa.c 31 Mar 2004 09:31:09 -0000 1.2 --- lookupa.c 1 Apr 2004 10:27:32 -0000 1.3 *************** *** 58,64 **** @brief lookup() -- hash a variable-length key into a 32-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param level can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of --- 58,64 ---- @brief lookup() -- hash a variable-length key into a 32-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param length the length of the key, counting by bytes ! @param level can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** mod_xhtml_neg.c 1 Apr 2004 09:34:48 -0000 1.32 --- mod_xhtml_neg.c 1 Apr 2004 10:27:32 -0000 1.33 *************** *** 588,592 **** * request * @param content_rec the accept_rec that matched the content negotiation ! * @param a string that contains a correctly formatted content-type value * @todo should we send the "profile" parameter as well? */ --- 588,592 ---- * request * @param content_rec the accept_rec that matched the content negotiation ! * @return a string that contains a correctly formatted content-type value * @todo should we send the "profile" parameter as well? */ |
From: <ru...@us...> - 2004-04-01 09:53:48
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv925 Modified Files: mod_xhtml_neg.c Log Message: Use bitmask on the correct variable (hash result, not length). Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** mod_xhtml_neg.c 1 Apr 2004 09:34:14 -0000 1.17 --- mod_xhtml_neg.c 1 Apr 2004 09:41:45 -0000 1.18 *************** *** 643,648 **** data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); ! len = mod_xhtml_strlen( data ) & 0xffffffff; ! hash = lookup( data, len, 0 ); rec->hashcode = apr_psprintf(p, "\"%08lx\"", (unsigned long) hash); --- 643,648 ---- data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); ! len = mod_xhtml_strlen( data ); ! hash = lookup( data, len, 0 ) & 0xffffffff; rec->hashcode = apr_psprintf(p, "\"%08lx\"", (unsigned long) hash); |
From: <ru...@us...> - 2004-04-01 09:51:53
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv608 Modified Files: mod_xhtml_neg.html Log Message: Minor fixes to the HTML file. Index: mod_xhtml_neg.html =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mod_xhtml_neg.html 7 Mar 2004 09:57:22 -0000 1.2 --- mod_xhtml_neg.html 1 Apr 2004 09:39:57 -0000 1.3 *************** *** 108,114 **** <li>When a "q" parameter is not specified, 1.0 is assumed. Values for "q" should be between 0.0 and 1.0.</li> ! <li>If a "charset" parameter is not specified, "iso-8859-1" is assumed ! unless the content type is "text/xml" or "text/xml-external-parsed-entity", ! where "us-ascii" is assumed.</li> <li>If a "profile" is not specified, none is assumed.</li> </ul> --- 108,115 ---- <li>When a "q" parameter is not specified, 1.0 is assumed. Values for "q" should be between 0.0 and 1.0.</li> ! <li>If a "charset" parameter is not specified, the character set is taken ! from the <code>AddDefaultCharset</code> directive. If this is not ! specified, "iso-8859-1" is assumed unless the content type is "text/xml" ! or "text/xml-external-parsed-entity", where "us-ascii" is assumed.</li> <li>If a "profile" is not specified, none is assumed.</li> </ul> *************** *** 116,119 **** --- 117,124 ---- <p>If no match is found using content-negotiation, the default content type is used.</p> + + <p>Note that setting the <code>AddDefaultCharset</code> directive for the + Apache core is recommended regardless of whether the "charset" parameter + is specified.</p> <h2><a id="starsignore" *************** *** 161,164 **** --- 166,171 ---- correctly negotiated content to user-agents.</p> <hr /> + + <p>Back <a href="./">home</a>.</p> </body> </html> |
From: <ru...@us...> - 2004-04-01 09:51:24
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv524 Modified Files: mod_xhtml_neg.html Log Message: Minor fixes to the HTML file. Index: mod_xhtml_neg.html =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mod_xhtml_neg.html 13 Mar 2004 07:07:50 -0000 1.1.1.1 --- mod_xhtml_neg.html 1 Apr 2004 09:39:20 -0000 1.2 *************** *** 108,114 **** <li>When a "q" parameter is not specified, 1.0 is assumed. Values for "q" should be between 0.0 and 1.0.</li> ! <li>If a "charset" parameter is not specified, "iso-8859-1" is assumed ! unless the content type is "text/xml" or "text/xml-external-parsed-entity", ! where "us-ascii" is assumed.</li> <li>If a "profile" is not specified, none is assumed.</li> </ul> --- 108,115 ---- <li>When a "q" parameter is not specified, 1.0 is assumed. Values for "q" should be between 0.0 and 1.0.</li> ! <li>If a "charset" parameter is not specified, the character set is taken ! from the <code>AddDefaultCharset</code> directive. If this is not ! specified, "iso-8859-1" is assumed unless the content type is "text/xml" ! or "text/xml-external-parsed-entity", where "us-ascii" is assumed.</li> <li>If a "profile" is not specified, none is assumed.</li> </ul> *************** *** 116,119 **** --- 117,124 ---- <p>If no match is found using content-negotiation, the default content type is used.</p> + + <p>Note that setting the <code>AddDefaultCharset</code> directive for the + Apache core is recommended regardless of whether the "charset" parameter + is specified.</p> <h2><a id="starsignore" *************** *** 161,164 **** --- 166,171 ---- correctly negotiated content to user-agents.</p> <hr /> + + <p>Back <a href="./">home</a>.</p> </body> </html> |
From: <ru...@us...> - 2004-04-01 09:46:44
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32178 Modified Files: mod_xhtml_neg.c Log Message: Fix null pointer whenever the best accept_rec is null. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** mod_xhtml_neg.c 31 Mar 2004 09:45:28 -0000 1.31 --- mod_xhtml_neg.c 1 Apr 2004 09:34:48 -0000 1.32 *************** *** 667,671 **** accept_rec *newrec; ! if( ! mod_xhtml_strempty( rec->charset )) { return rec; } --- 667,671 ---- accept_rec *newrec; ! if(( rec == NULL ) || ( ! mod_xhtml_strempty( rec->charset ))) { return rec; } |
From: <ru...@us...> - 2004-04-01 09:46:12
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32073 Modified Files: mod_xhtml_neg.c Log Message: Fix null pointer whenever the best accept_rec is null. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** mod_xhtml_neg.c 31 Mar 2004 09:46:11 -0000 1.16 --- mod_xhtml_neg.c 1 Apr 2004 09:34:14 -0000 1.17 *************** *** 670,674 **** accept_rec *newrec; ! if( ! mod_xhtml_strempty( rec->charset )) { return rec; } --- 670,674 ---- accept_rec *newrec; ! if(( rec == NULL ) || ( ! mod_xhtml_strempty( rec->charset ))) { return rec; } |
From: <ru...@us...> - 2004-03-31 09:57:58
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26507 Modified Files: mod_xhtml_neg.c Log Message: Added bitmask to hash code to make sure we get back a 32-bit value. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** mod_xhtml_neg.c 30 Mar 2004 10:37:04 -0000 1.15 --- mod_xhtml_neg.c 31 Mar 2004 09:46:11 -0000 1.16 *************** *** 623,626 **** --- 623,630 ---- * The hash function is a hash in the public domain by By Bob Jenkins. See * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. + * Note that since we're only using this algorithm for Etag uniqueness rather + * than for a hashtable lookup, DoS attacks such as those described in + * http://www.cs.rice.edu/~scrosby/hash/ are not an issue here, especially + * since our hash keys come from data in either httpd.conf or .htaccess files. * * @param p a memory pool from which we can allocate temporary memory for this *************** *** 639,643 **** data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); ! len = mod_xhtml_strlen( data ); hash = lookup( data, len, 0 ); --- 643,647 ---- data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); ! len = mod_xhtml_strlen( data ) & 0xffffffff; hash = lookup( data, len, 0 ); |
From: <ru...@us...> - 2004-03-31 09:57:14
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26294 Modified Files: mod_xhtml_neg.c Log Message: Added bitmask to hash code to make sure we get back a 32-bit value. Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/mod_xhtml_neg.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** mod_xhtml_neg.c 30 Mar 2004 10:35:46 -0000 1.30 --- mod_xhtml_neg.c 31 Mar 2004 09:45:28 -0000 1.31 *************** *** 620,623 **** --- 620,627 ---- * The hash function is a hash in the public domain by By Bob Jenkins. See * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. + * Note that since we're only using this algorithm for Etag uniqueness rather + * than for a hashtable lookup, DoS attacks such as those described in + * http://www.cs.rice.edu/~scrosby/hash/ are not an issue here, especially + * since our hash keys come from data in either httpd.conf or .htaccess files. * * @param p a memory pool from which we can allocate temporary memory for this *************** *** 637,641 **** data = ap_pstrcat( p, rec->name, ";", rec->charset, NULL ); len = mod_xhtml_strlen( data ); ! hash = lookup( data, len, 0 ); rec->hashcode = ap_psprintf(p, "\"%08lx\"", (unsigned long) hash); --- 641,645 ---- data = ap_pstrcat( p, rec->name, ";", rec->charset, NULL ); len = mod_xhtml_strlen( data ); ! hash = lookup( data, len, 0 ) & 0xffffffff; rec->hashcode = ap_psprintf(p, "\"%08lx\"", (unsigned long) hash); |
From: <ru...@us...> - 2004-03-31 09:45:43
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24086 Modified Files: lookupa.c Doxyfile Log Message: Doxygenise lookupa.c. Index: lookupa.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/lookupa.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lookupa.c 30 Mar 2004 10:37:54 -0000 1.1 --- lookupa.c 31 Mar 2004 09:33:57 -0000 1.2 *************** *** 1,8 **** ! /* ! -------------------------------------------------------------------- lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c ! -------------------------------------------------------------------- */ --- 1,8 ---- ! /** @file ! lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c ! */ *************** *** 11,39 **** #endif ! /* ! -------------------------------------------------------------------- ! mix -- mix 3 32-bit values reversibly. For every delta with one or two bit set, and the deltas of all three ! high bits or all three low bits, whether the original value of a,b,c ! is almost all zero or is uniformly distributed, ! * If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. ! * If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) ! mix() was built out of 36 single-cycle latency instructions in a ! structure that could supported 2x parallelism, like so: ! a -= b; ! a -= c; x = (c>>13); ! b -= c; a ^= x; ! b -= a; x = (a<<8); ! c -= a; b ^= x; ! c -= b; x = (b>>13); ! ... ! Unfortunately, superscalar Pentiums and Sparcs can't take advantage ! of that parallelism. They've also turned some of those single-cycle ! latency instructions into multi-cycle latency instructions. Still, ! this is the fastest good hash I could find. There were about 2^^68 ! to choose from. I only looked at a billion or so. ! -------------------------------------------------------------------- */ #define mix(a,b,c) \ --- 11,43 ---- #endif ! /** ! ! @brief mix -- mix 3 32-bit values reversibly. ! For every delta with one or two bit set, and the deltas of all three ! high bits or all three low bits, whether the original value of a,b,c ! is almost all zero or is uniformly distributed, ! - If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. ! - If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) ! ! mix() was built out of 36 single-cycle latency instructions in a ! structure that could supported 2x parallelism, like so: ! @verbatim ! a -= b; ! a -= c; x = (c>>13); ! b -= c; a ^= x; ! b -= a; x = (a<<8); ! c -= a; b ^= x; ! c -= b; x = (b>>13); ! ... ! @endverbatim ! Unfortunately, superscalar Pentiums and Sparcs can't take advantage ! of that parallelism. They've also turned some of those single-cycle ! latency instructions into multi-cycle latency instructions. Still, ! this is the fastest good hash I could find. There were about 2^^68 ! to choose from. I only looked at a billion or so. ! */ #define mix(a,b,c) \ *************** *** 50,59 **** } ! /* ! -------------------------------------------------------------------- ! lookup() -- hash a variable-length key into a 32-bit value ! k : the key (the unaligned variable-length array of bytes) ! len : the length of the key, counting by bytes ! level : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. --- 54,65 ---- } ! /** ! ! @brief lookup() -- hash a variable-length key into a 32-bit value ! ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param level can be any 4-byte value ! Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. *************** *** 63,71 **** --- 69,81 ---- mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do + @verbatim h = (h & hashmask(10)); + @endverbatim In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (ub1 **)k, do it like this: + @verbatim for (i=0, h=0; i<n; ++i) h = lookup( k[i], len[i], h); + @endverbatim By Bob Jenkins, 1996. bob...@bu.... You may use this *************** *** 75,79 **** Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. ! -------------------------------------------------------------------- */ --- 85,89 ---- Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. ! */ *************** *** 121,131 **** ! /* ! -------------------------------------------------------------------- ! mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. ! Repeating mix() three times achieves avalanche. Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. ! -------------------------------------------------------------------- */ #define mixc(a,b,c,d,e,f,g,h) \ --- 131,142 ---- ! /** ! ! @brief mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. ! ! Repeating mix() three times achieves avalanche. \n Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. ! */ #define mixc(a,b,c,d,e,f,g,h) \ *************** *** 141,156 **** } ! /* ! -------------------------------------------------------------------- ! checksum() -- hash a variable-length key into a 256-bit value ! k : the key (the unaligned variable-length array of bytes) ! len : the length of the key, counting by bytes ! state : an array of CHECKSTATE 4-byte values (256 bits) The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); (c) Bob Jenkins, 1996. bob...@bu.... You may use this --- 152,170 ---- } ! /** ! ! @brief checksum() -- hash a variable-length key into a 256-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param state an array of CHECKSTATE 4-byte values (256 bits) ! The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: + @verbatim for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); + @endverbatim (c) Bob Jenkins, 1996. bob...@bu.... You may use this *************** *** 161,165 **** Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. ! -------------------------------------------------------------------- */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) --- 175,179 ---- Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. ! */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) Index: Doxyfile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/Doxyfile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Doxyfile 30 Mar 2004 10:37:04 -0000 1.3 --- Doxyfile 31 Mar 2004 09:33:57 -0000 1.4 *************** *** 310,314 **** # with spaces. ! INPUT = mod_xhtml_neg.c # If the value of the INPUT tag contains directories, you can use the --- 310,314 ---- # with spaces. ! INPUT = mod_xhtml_neg.c lookupa.c # If the value of the INPUT tag contains directories, you can use the |
From: <ru...@us...> - 2004-03-31 09:42:55
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23733 Modified Files: lookupa.c Doxyfile Log Message: Doxygenise lookupa.c. Index: lookupa.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/lookupa.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lookupa.c 30 Mar 2004 10:35:46 -0000 1.1 --- lookupa.c 31 Mar 2004 09:31:09 -0000 1.2 *************** *** 1,8 **** ! /* ! -------------------------------------------------------------------- lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c ! -------------------------------------------------------------------- */ --- 1,8 ---- ! /** @file ! lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c ! */ *************** *** 11,39 **** #endif ! /* ! -------------------------------------------------------------------- ! mix -- mix 3 32-bit values reversibly. For every delta with one or two bit set, and the deltas of all three ! high bits or all three low bits, whether the original value of a,b,c ! is almost all zero or is uniformly distributed, ! * If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. ! * If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) ! mix() was built out of 36 single-cycle latency instructions in a ! structure that could supported 2x parallelism, like so: ! a -= b; ! a -= c; x = (c>>13); ! b -= c; a ^= x; ! b -= a; x = (a<<8); ! c -= a; b ^= x; ! c -= b; x = (b>>13); ! ... ! Unfortunately, superscalar Pentiums and Sparcs can't take advantage ! of that parallelism. They've also turned some of those single-cycle ! latency instructions into multi-cycle latency instructions. Still, ! this is the fastest good hash I could find. There were about 2^^68 ! to choose from. I only looked at a billion or so. ! -------------------------------------------------------------------- */ #define mix(a,b,c) \ --- 11,43 ---- #endif ! /** ! ! @brief mix -- mix 3 32-bit values reversibly. ! For every delta with one or two bit set, and the deltas of all three ! high bits or all three low bits, whether the original value of a,b,c ! is almost all zero or is uniformly distributed, ! - If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. ! - If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) ! ! mix() was built out of 36 single-cycle latency instructions in a ! structure that could supported 2x parallelism, like so: ! @verbatim ! a -= b; ! a -= c; x = (c>>13); ! b -= c; a ^= x; ! b -= a; x = (a<<8); ! c -= a; b ^= x; ! c -= b; x = (b>>13); ! ... ! @endverbatim ! Unfortunately, superscalar Pentiums and Sparcs can't take advantage ! of that parallelism. They've also turned some of those single-cycle ! latency instructions into multi-cycle latency instructions. Still, ! this is the fastest good hash I could find. There were about 2^^68 ! to choose from. I only looked at a billion or so. ! */ #define mix(a,b,c) \ *************** *** 50,59 **** } ! /* ! -------------------------------------------------------------------- ! lookup() -- hash a variable-length key into a 32-bit value ! k : the key (the unaligned variable-length array of bytes) ! len : the length of the key, counting by bytes ! level : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. --- 54,65 ---- } ! /** ! ! @brief lookup() -- hash a variable-length key into a 32-bit value ! ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param level can be any 4-byte value ! Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. *************** *** 63,71 **** --- 69,81 ---- mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do + @verbatim h = (h & hashmask(10)); + @endverbatim In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (ub1 **)k, do it like this: + @verbatim for (i=0, h=0; i<n; ++i) h = lookup( k[i], len[i], h); + @endverbatim By Bob Jenkins, 1996. bob...@bu.... You may use this *************** *** 75,79 **** Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. ! -------------------------------------------------------------------- */ --- 85,89 ---- Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. ! */ *************** *** 121,131 **** ! /* ! -------------------------------------------------------------------- ! mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. ! Repeating mix() three times achieves avalanche. Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. ! -------------------------------------------------------------------- */ #define mixc(a,b,c,d,e,f,g,h) \ --- 131,142 ---- ! /** ! ! @brief mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. ! ! Repeating mix() three times achieves avalanche. \n Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. ! */ #define mixc(a,b,c,d,e,f,g,h) \ *************** *** 141,156 **** } ! /* ! -------------------------------------------------------------------- ! checksum() -- hash a variable-length key into a 256-bit value ! k : the key (the unaligned variable-length array of bytes) ! len : the length of the key, counting by bytes ! state : an array of CHECKSTATE 4-byte values (256 bits) The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); (c) Bob Jenkins, 1996. bob...@bu.... You may use this --- 152,170 ---- } ! /** ! ! @brief checksum() -- hash a variable-length key into a 256-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param state an array of CHECKSTATE 4-byte values (256 bits) ! The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: + @verbatim for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); + @endverbatim (c) Bob Jenkins, 1996. bob...@bu.... You may use this *************** *** 161,165 **** Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. ! -------------------------------------------------------------------- */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) --- 175,179 ---- Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. ! */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) Index: Doxyfile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg/Doxyfile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Doxyfile 30 Mar 2004 10:35:46 -0000 1.3 --- Doxyfile 31 Mar 2004 09:31:09 -0000 1.4 *************** *** 310,314 **** # with spaces. ! INPUT = mod_xhtml_neg.c # If the value of the INPUT tag contains directories, you can use the --- 310,314 ---- # with spaces. ! INPUT = mod_xhtml_neg.c lookupa.c # If the value of the INPUT tag contains directories, you can use the |
From: <ru...@us...> - 2004-03-30 10:49:32
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30548 Added Files: lookupa.c lookupa.h Log Message: Use a better hashing algorithm for generating ETag suffix. --- NEW FILE: lookupa.c --- /* -------------------------------------------------------------------- lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c -------------------------------------------------------------------- */ #ifndef LOOKUPA #include "lookupa.h" #endif /* -------------------------------------------------------------------- mix -- mix 3 32-bit values reversibly. For every delta with one or two bit set, and the deltas of all three high bits or all three low bits, whether the original value of a,b,c is almost all zero or is uniformly distributed, * If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. * If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) mix() was built out of 36 single-cycle latency instructions in a structure that could supported 2x parallelism, like so: a -= b; a -= c; x = (c>>13); b -= c; a ^= x; b -= a; x = (a<<8); c -= a; b ^= x; c -= b; x = (b>>13); ... Unfortunately, superscalar Pentiums and Sparcs can't take advantage of that parallelism. They've also turned some of those single-cycle latency instructions into multi-cycle latency instructions. Still, this is the fastest good hash I could find. There were about 2^^68 to choose from. I only looked at a billion or so. -------------------------------------------------------------------- */ #define mix(a,b,c) \ { \ a -= b; a -= c; a ^= (c>>13); \ b -= c; b -= a; b ^= (a<<8); \ c -= a; c -= b; c ^= (b>>13); \ a -= b; a -= c; a ^= (c>>12); \ b -= c; b -= a; b ^= (a<<16); \ c -= a; c -= b; c ^= (b>>5); \ a -= b; a -= c; a ^= (c>>3); \ b -= c; b -= a; b ^= (a<<10); \ c -= a; c -= b; c ^= (b>>15); \ } /* -------------------------------------------------------------------- lookup() -- hash a variable-length key into a 32-bit value k : the key (the unaligned variable-length array of bytes) len : the length of the key, counting by bytes level : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. About 6len+35 instructions. The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do h = (h & hashmask(10)); In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (ub1 **)k, do it like this: for (i=0, h=0; i<n; ++i) h = lookup( k[i], len[i], h); By Bob Jenkins, 1996. bob...@bu.... You may use this code any way you wish, private, educational, or commercial. See http://burtleburtle.net/bob/hash/evahash.html Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. -------------------------------------------------------------------- */ ub4 lookup( register ub1 *k, register ub4 length, register ub4 level ) { register ub4 a,b,c,len; /* Set up the internal state */ len = length; a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ c = level; /* the previous hash value */ /*---------------------------------------- handle most of the key */ while (len >= 12) { a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); mix(a,b,c); k += 12; len -= 12; } /*------------------------------------- handle the last 11 bytes */ c += length; switch(len) /* all the case statements fall through */ { case 11: c+=((ub4)k[10]<<24); case 10: c+=((ub4)k[9]<<16); case 9 : c+=((ub4)k[8]<<8); /* the first byte of c is reserved for the length */ case 8 : b+=((ub4)k[7]<<24); case 7 : b+=((ub4)k[6]<<16); case 6 : b+=((ub4)k[5]<<8); case 5 : b+=k[4]; case 4 : a+=((ub4)k[3]<<24); case 3 : a+=((ub4)k[2]<<16); case 2 : a+=((ub4)k[1]<<8); case 1 : a+=k[0]; /* case 0: nothing left to add */ } mix(a,b,c); /*-------------------------------------------- report the result */ return c; } /* -------------------------------------------------------------------- mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. Repeating mix() three times achieves avalanche. Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. -------------------------------------------------------------------- */ #define mixc(a,b,c,d,e,f,g,h) \ { \ a^=b<<11; d+=a; b+=c; \ b^=c>>2; e+=b; c+=d; \ c^=d<<8; f+=c; d+=e; \ d^=e>>16; g+=d; e+=f; \ e^=f<<10; h+=e; f+=g; \ f^=g>>4; a+=f; g+=h; \ g^=h<<8; b+=g; h+=a; \ h^=a>>9; c+=h; a+=b; \ } /* -------------------------------------------------------------------- checksum() -- hash a variable-length key into a 256-bit value k : the key (the unaligned variable-length array of bytes) len : the length of the key, counting by bytes state : an array of CHECKSTATE 4-byte values (256 bits) The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); (c) Bob Jenkins, 1996. bob...@bu.... You may use this code any way you wish, private, educational, or commercial, as long as this whole comment accompanies it. See http://burtleburtle.net/bob/hash/evahash.html Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. -------------------------------------------------------------------- */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) { register ub4 a,b,c,d,e,f,g,h,length; /* Use the length and level; add in the golden ratio. */ length = len; a=state[0]; b=state[1]; c=state[2]; d=state[3]; e=state[4]; f=state[5]; g=state[6]; h=state[7]; /*---------------------------------------- handle most of the key */ while (len >= 32) { a += (k[0] +(k[1]<<8) +(k[2]<<16) +(k[3]<<24)); b += (k[4] +(k[5]<<8) +(k[6]<<16) +(k[7]<<24)); c += (k[8] +(k[9]<<8) +(k[10]<<16)+(k[11]<<24)); d += (k[12]+(k[13]<<8)+(k[14]<<16)+(k[15]<<24)); e += (k[16]+(k[17]<<8)+(k[18]<<16)+(k[19]<<24)); f += (k[20]+(k[21]<<8)+(k[22]<<16)+(k[23]<<24)); g += (k[24]+(k[25]<<8)+(k[26]<<16)+(k[27]<<24)); h += (k[28]+(k[29]<<8)+(k[30]<<16)+(k[31]<<24)); mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); k += 32; len -= 32; } /*------------------------------------- handle the last 31 bytes */ h += length; switch(len) { case 31: h+=(k[30]<<24); case 30: h+=(k[29]<<16); case 29: h+=(k[28]<<8); case 28: g+=(k[27]<<24); case 27: g+=(k[26]<<16); case 26: g+=(k[25]<<8); case 25: g+=k[24]; case 24: f+=(k[23]<<24); case 23: f+=(k[22]<<16); case 22: f+=(k[21]<<8); case 21: f+=k[20]; case 20: e+=(k[19]<<24); case 19: e+=(k[18]<<16); case 18: e+=(k[17]<<8); case 17: e+=k[16]; case 16: d+=(k[15]<<24); case 15: d+=(k[14]<<16); case 14: d+=(k[13]<<8); case 13: d+=k[12]; case 12: c+=(k[11]<<24); case 11: c+=(k[10]<<16); case 10: c+=(k[9]<<8); case 9 : c+=k[8]; case 8 : b+=(k[7]<<24); case 7 : b+=(k[6]<<16); case 6 : b+=(k[5]<<8); case 5 : b+=k[4]; case 4 : a+=(k[3]<<24); case 3 : a+=(k[2]<<16); case 2 : a+=(k[1]<<8); case 1 : a+=k[0]; } mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); /*-------------------------------------------- report the result */ state[0]=a; state[1]=b; state[2]=c; state[3]=d; state[4]=e; state[5]=f; state[6]=g; state[7]=h; } --- NEW FILE: lookupa.h --- /* ------------------------------------------------------------------------------ By Bob Jenkins, September 1996. lookupa.h, a hash function for table lookup, same function as lookup.c. Use this code in any way you wish. Public Domain. It has no warranty. Source is http://burtleburtle.net/bob/c/lookupa.h ------------------------------------------------------------------------------ */ #ifndef LOOKUPA #define LOOKUPA typedef unsigned long int ub4; typedef unsigned char ub1; #define CHECKSTATE 8 #define hashsize(n) ((ub4)1<<(n)) #define hashmask(n) (hashsize(n)-1) ub4 lookup(ub1 *k, ub4 length, ub4 level); void checksum(ub1 *k, ub4 length, ub4 *state); #endif /* LOOKUPA */ |
From: <ru...@us...> - 2004-03-30 10:48:53
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30437 Modified Files: Doxyfile Makefile mod_xhtml_neg.c Log Message: Use a better hashing algorithm for generating ETag suffix. Index: Doxyfile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/Doxyfile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Doxyfile 25 Mar 2004 10:20:54 -0000 1.2 --- Doxyfile 30 Mar 2004 10:37:04 -0000 1.3 *************** *** 24,28 **** # if some version control system is used. ! PROJECT_NUMBER = 0.92 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) --- 24,28 ---- # if some version control system is used. ! PROJECT_NUMBER = 0.93 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) Index: Makefile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 25 Mar 2004 09:40:01 -0000 1.2 --- Makefile 30 Mar 2004 10:37:04 -0000 1.3 *************** *** 4,8 **** build: ! $(APXS) -i -a -c mod_xhtml_neg.c clean: --- 4,8 ---- build: ! $(APXS) -i -a -c mod_xhtml_neg.c lookupa.c clean: Index: mod_xhtml_neg.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/mod_xhtml_neg.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** mod_xhtml_neg.c 28 Mar 2004 05:56:40 -0000 1.14 --- mod_xhtml_neg.c 30 Mar 2004 10:37:04 -0000 1.15 *************** *** 77,81 **** * @author Nicholas Cull <ru...@us...> * @date 1 March 2004 ! * @version 0.92 * * @history --- 77,81 ---- * @author Nicholas Cull <ru...@us...> * @date 1 March 2004 ! * @version 0.93 * * @history *************** *** 86,89 **** --- 86,90 ---- * 0.9 ETag handled correctly for different content types. \n * 0.92 Pick up the AddDefaultCharset directive from the Apache core \n + * 0.93 Use a better hash function for ETag uniqueness \n * * @directive *************** *** 126,129 **** --- 127,131 ---- #include "http_protocol.h" #include "http_log.h" + #include "lookupa.h" /** Read/write flags used when opening the log file. */ *************** *** 613,623 **** * Make a simple hash code for the given accept_rec structure. This allows * us to generate unique Etags for accepted content-types. The Etag ! * consists of two simple values, the length of the interesting data, ! * and a simple hash of each character. These are then represented as ! * two hyphen separated, zero padded hexadecimal numbers. * * The data that we use to generate the hash is the content-type and charset, * concatenated as one long string. * * @param p a memory pool from which we can allocate temporary memory for this * request --- 615,627 ---- * Make a simple hash code for the given accept_rec structure. This allows * us to generate unique Etags for accepted content-types. The Etag ! * consists of a hash of each character. This is then represented as a ! * zero padded hexadecimal number. * * The data that we use to generate the hash is the content-type and charset, * concatenated as one long string. * + * The hash function is a hash in the public domain by By Bob Jenkins. See + * lookupa.c or http://burtleburtle.net/bob/hash/doobs.html for details. + * * @param p a memory pool from which we can allocate temporary memory for this * request *************** *** 634,650 **** int len, i; ! data = apr_pstrcat( p, rec->name, rec->charset, NULL ); len = mod_xhtml_strlen( data ); ! hash = 7; ! ! /* Note that we use a multiplier of 128 rather than 256 since HTTP ! * headers are only guaranteed 7-bit US-ASCII safe. ! */ ! for( i = 0; i < len; i++ ) { ! hash = hash * 128 + data[ i ]; ! } ! rec->hashcode = apr_psprintf(p, "\"%02x-%08lx\"", ! len, (unsigned long) hash); } --- 638,646 ---- int len, i; ! data = apr_pstrcat( p, rec->name, ";", rec->charset, NULL ); len = mod_xhtml_strlen( data ); ! hash = lookup( data, len, 0 ); ! rec->hashcode = apr_psprintf(p, "\"%08lx\"", (unsigned long) hash); } |