]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store_key_md5.cc
3 static cache_key null_key
[MD5_DIGEST_CHARS
];
6 storeKeyText(const unsigned char *key
)
8 LOCAL_ARRAY(char, buf
, 33);
11 for (i
= 0; i
< MD5_DIGEST_CHARS
; i
++) {
13 snprintf(buf
+ o
, 33 - o
, "%02X", *(key
+ i
));
19 storeKeyScan(const char *buf
)
21 static unsigned char digest
[MD5_DIGEST_CHARS
];
25 for (i
= 0; i
< MD5_DIGEST_CHARS
; i
++) {
26 t
[0] = *(buf
+ (j
++));
27 t
[1] = *(buf
+ (j
++));
29 *(digest
+ i
) = (unsigned char) strtol(t
, NULL
, 16);
35 storeKeyHashCmp(const void *a
, const void *b
)
37 const unsigned char *A
= a
;
38 const unsigned char *B
= b
;
40 for (i
= 0; i
< MD5_DIGEST_CHARS
; i
++) {
50 storeKeyHashHash(const void *key
, unsigned int n
)
52 /* note, n must be a power of 2! */
53 const unsigned char *digest
= key
;
54 unsigned int i
= digest
[0]
62 storeKeyPrivate(const char *url
, method_t method
, int num
)
64 static cache_key digest
[MD5_DIGEST_CHARS
];
67 char key_buf
[MAX_URL
+ 100];
69 debug(20, 3) ("storeKeyPrivate: %s %s\n",
70 RequestMethodStr
[method
], url
);
71 n
= snprintf(key_buf
, MAX_URL
+ 100, "%d %s %s",
73 RequestMethodStr
[method
],
76 MD5Update(&M
, (unsigned char *) key_buf
, n
);
82 storeKeyPublic(const char *url
, method_t method
)
84 static cache_key digest
[MD5_DIGEST_CHARS
];
87 char key_buf
[MAX_URL
+ 100];
88 n
= snprintf(key_buf
, MAX_URL
+ 100, "%s %s",
89 RequestMethodStr
[method
],
92 MD5Update(&M
, (unsigned char *) key_buf
, n
);
98 storeKeyDup(const cache_key
* key
)
100 cache_key
*dup
= xmalloc(MD5_DIGEST_CHARS
);
101 xmemcpy(dup
, key
, MD5_DIGEST_CHARS
);
102 /* XXX account key */
107 storeKeyFree(const cache_key
* key
)
110 /* XXX account key */
114 storeKeyHashBuckets(int nobj
)
126 storeKeyNull(const cache_key
* key
)
128 if (memcmp(key
, null_key
, MD5_DIGEST_CHARS
) == 0)
137 memset(null_key
, '\0', MD5_DIGEST_CHARS
);