From: robertc <> Date: Tue, 15 Oct 2002 15:25:32 +0000 (+0000) Subject: really fix squid3 for c++ compilers with prefixed vtables X-Git-Tag: SQUID_3_0_PRE1~640 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a8b20e85f4247c8f81ee4257f50d3646cbf9366;p=thirdparty%2Fsquid.git really fix squid3 for c++ compilers with prefixed vtables --- diff --git a/include/hash.h b/include/hash.h index c4a48af19b..99bd430cbb 100644 --- a/include/hash.h +++ b/include/hash.h @@ -1,5 +1,5 @@ /* - * $Id: hash.h,v 1.6 2002/10/13 20:34:51 robertc Exp $ + * $Id: hash.h,v 1.7 2002/10/15 09:25:32 robertc Exp $ */ #ifndef SQUID_HASH_H @@ -30,9 +30,9 @@ SQUIDCEXTERN hash_table *hash_create(HASHCMP *, int, HASHHASH *); SQUIDCEXTERN void hash_join(hash_table *, hash_link *); SQUIDCEXTERN void hash_remove_link(hash_table *, hash_link *); SQUIDCEXTERN int hashPrime(int n); -SQUIDCEXTERN void *hash_lookup(hash_table *, const void *); +SQUIDCEXTERN hash_link *hash_lookup(hash_table *, const void *); SQUIDCEXTERN void hash_first(hash_table *); -SQUIDCEXTERN void *hash_next(hash_table *); +SQUIDCEXTERN hash_link *hash_next(hash_table *); SQUIDCEXTERN void hash_last(hash_table *); SQUIDCEXTERN hash_link *hash_get_bucket(hash_table *, unsigned int); SQUIDCEXTERN void hashFreeMemory(hash_table *); diff --git a/lib/hash.c b/lib/hash.c index 0108471059..a001d9a196 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -1,6 +1,6 @@ /* - * $Id: hash.c,v 1.13 2002/10/02 11:06:30 robertc Exp $ + * $Id: hash.c,v 1.14 2002/10/15 09:25:32 robertc Exp $ * * DEBUG: section 0 Hash Tables * AUTHOR: Harvest Derived @@ -179,7 +179,7 @@ hash_join(hash_table * hid, hash_link * lnk) * 'hid'. Returns a pointer to the hash bucket on success; otherwise * returns NULL. */ -void * +hash_link * hash_lookup(hash_table * hid, const void *k) { hash_link *walker; @@ -225,7 +225,7 @@ hash_first(hash_table * hid) * * MUST call hash_first() before hash_next(). */ -void * +hash_link * hash_next(hash_table * hid) { hash_link *this = hid->next; diff --git a/src/auth/basic/auth_basic.cc b/src/auth/basic/auth_basic.cc index 1e6fb25b54..ce7a6f6432 100644 --- a/src/auth/basic/auth_basic.cc +++ b/src/auth/basic/auth_basic.cc @@ -1,5 +1,5 @@ /* - * $Id: auth_basic.cc,v 1.19 2002/10/13 20:35:17 robertc Exp $ + * $Id: auth_basic.cc,v 1.20 2002/10/15 09:25:34 robertc Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -387,9 +387,9 @@ authBasicAuthUserFindUsername(const char *username) if (username && (usernamehash = static_cast(hash_lookup(proxy_auth_username_cache, username)))) { while (usernamehash) { if ((authUserHashPointerUser(usernamehash)->auth_type == AUTH_BASIC) && - !strcmp(username, usernamehash->key)) + !strcmp(username, (char const *)usernamehash->key)) return authUserHashPointerUser(usernamehash); - usernamehash = usernamehash->next; + usernamehash = static_cast(usernamehash->next); } } return NULL; diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index a4a7da4e56..3c62a1c886 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_digest.cc,v 1.16 2002/10/13 20:35:20 robertc Exp $ + * $Id: auth_digest.cc,v 1.17 2002/10/15 09:25:34 robertc Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -121,9 +121,9 @@ authDigestNonceEncode(digest_nonce_h * nonce) { if (!nonce) return; - if (nonce->hash.key) - xfree(nonce->hash.key); - nonce->hash.key = xstrdup(base64_encode_bin((char *) &(nonce->noncedata), sizeof(digest_nonce_data))); + if (nonce->key) + xfree(nonce->key); + nonce->key = xstrdup(base64_encode_bin((char *) &(nonce->noncedata), sizeof(digest_nonce_data))); } static digest_nonce_h * @@ -183,12 +183,12 @@ authenticateDigestNonceNew(void) * loop until we get a unique nonce. The nonce creation must * have a random factor */ - while ((temp = authenticateDigestNonceFindNonce((char const *)(newnonce->hash.key)))) { + while ((temp = authenticateDigestNonceFindNonce((char const *)(newnonce->key)))) { /* create a new nonce */ newnonce->noncedata.randomdata = squid_random(); authDigestNonceEncode(newnonce); } - hash_join(digest_nonce_cache, &newnonce->hash); + hash_join(digest_nonce_cache, newnonce); /* the cache's link */ authDigestNonceLink(newnonce); newnonce->flags.incache = 1; @@ -203,10 +203,10 @@ authenticateDigestNonceDelete(digest_nonce_h * nonce) assert(nonce->references == 0); #if UNREACHABLECODE if (nonce->flags.incache) - hash_remove_link(digest_nonce_cache, &nonce->hash); + hash_remove_link(digest_nonce_cache, nonce); #endif assert(nonce->flags.incache == 0); - safe_free(nonce->hash.key); + safe_free(nonce->key); memPoolFree(digest_nonce_pool, nonce); } } @@ -265,10 +265,10 @@ authenticateDigestNonceCacheCleanup(void *data) (long int)current_time.tv_sec); hash_first(digest_nonce_cache); while ((nonce = ((digest_nonce_h *) hash_next(digest_nonce_cache)))) { - debug(29, 3) ("authenticateDigestNonceCacheCleanup: nonce entry : %p '%s'\n", nonce, (char *)nonce->hash.key); + debug(29, 3) ("authenticateDigestNonceCacheCleanup: nonce entry : %p '%s'\n", nonce, (char *)nonce->key); debug(29, 4) ("authenticateDigestNonceCacheCleanup: Creation time: %ld\n", (long int)nonce->noncedata.creationtime); if (authDigestNonceIsStale(nonce)) { - debug(29, 4) ("authenticateDigestNonceCacheCleanup: Removing nonce %s from cache due to timeout.\n", (char *)nonce->hash.key); + debug(29, 4) ("authenticateDigestNonceCacheCleanup: Removing nonce %s from cache due to timeout.\n", (char *)nonce->key); assert(nonce->flags.incache); /* invalidate nonce so future requests fail */ nonce->flags.valid = 0; @@ -319,7 +319,7 @@ authenticateDigestNonceNonceb64(digest_nonce_h * nonce) { if (!nonce) return NULL; - return (char const *)nonce->hash.key; + return (char const *)nonce->key; } static digest_nonce_h * @@ -414,7 +414,7 @@ authDigestNoncePurge(digest_nonce_h * nonce) return; if (!nonce->flags.incache) return; - hash_remove_link(digest_nonce_cache, &nonce->hash); + hash_remove_link(digest_nonce_cache, nonce); nonce->flags.incache = 0; /* the cache's link */ authDigestNonceUnlink(nonce); @@ -440,7 +440,7 @@ authDigestUserFindUsername(const char *username) if (username && (usernamehash = static_cast(hash_lookup(proxy_auth_username_cache, username)))) { while ((authUserHashPointerUser(usernamehash)->auth_type != AUTH_DIGEST) && (usernamehash->next)) - usernamehash = usernamehash->next; + usernamehash = static_cast(usernamehash->next); auth_user = NULL; if (authUserHashPointerUser(usernamehash)->auth_type == AUTH_DIGEST) { auth_user = authUserHashPointerUser(usernamehash); diff --git a/src/auth/digest/auth_digest.h b/src/auth/digest/auth_digest.h index 74b63f8f2c..ac89255429 100644 --- a/src/auth/digest/auth_digest.h +++ b/src/auth/digest/auth_digest.h @@ -59,8 +59,7 @@ struct _digest_nonce_data { }; /* the nonce structure we'll pass around */ -struct _digest_nonce_h { - hash_link hash; /* must be first */ +struct _digest_nonce_h : public hash_link { digest_nonce_data noncedata; /* number of uses we've seen of this nonce */ unsigned long nc; diff --git a/src/auth/ntlm/auth_ntlm.cc b/src/auth/ntlm/auth_ntlm.cc index f5b52e5e82..70c82f68b8 100644 --- a/src/auth/ntlm/auth_ntlm.cc +++ b/src/auth/ntlm/auth_ntlm.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_ntlm.cc,v 1.23 2002/10/13 20:35:23 robertc Exp $ + * $Id: auth_ntlm.cc,v 1.24 2002/10/15 09:25:35 robertc Exp $ * * DEBUG: section 29 NTLM Authenticator * AUTHOR: Robert Collins @@ -912,7 +912,7 @@ authenticateProxyAuthCacheAddLink(const char *key, auth_user_t * auth_user) node = ntlm_user->proxy_auth_list.head; /* prevent duplicates */ while (node) { - if (!strcmp(key, ((struct ProxyAuthCachePointer *) node->data)->key)) + if (!strcmp(key, (char const *)((struct ProxyAuthCachePointer *) node->data)->key)) return; node = node->next; } @@ -1037,7 +1037,7 @@ authenticateNTLMAuthenticateUser(auth_user_request_t * auth_user_request, reques * string */ if ((usernamehash = static_cast(hash_lookup(proxy_auth_username_cache, ntlm_user->username)))) { while ((authUserHashPointerUser(usernamehash)->auth_type != auth_user->auth_type) && (usernamehash->next) && !authenticateNTLMcmpUsername(static_cast(authUserHashPointerUser(usernamehash)->scheme_data), ntlm_user)) - usernamehash = usernamehash->next; + usernamehash = static_cast(usernamehash->next); if (authUserHashPointerUser(usernamehash)->auth_type == auth_user->auth_type) { /* * add another link from the new proxy_auth to the diff --git a/src/auth/ntlm/auth_ntlm.h b/src/auth/ntlm/auth_ntlm.h index 069d63d7c8..5c2de44bc4 100644 --- a/src/auth/ntlm/auth_ntlm.h +++ b/src/auth/ntlm/auth_ntlm.h @@ -62,10 +62,8 @@ struct _auth_ntlm_config { time_t challengelifetime; }; -struct ProxyAuthCachePointer { - /* first two items must be same as hash_link */ - char *key; - auth_user_hash_pointer *next;dlink_node link; +struct ProxyAuthCachePointer : public hash_link { + dlink_node link; /* other hash entries that point to the same auth_user */ auth_user_t *auth_user; }; diff --git a/src/authenticate.cc b/src/authenticate.cc index 757a8b0677..4225b932e4 100644 --- a/src/authenticate.cc +++ b/src/authenticate.cc @@ -1,6 +1,6 @@ /* - * $Id: authenticate.cc,v 1.45 2002/10/14 10:47:51 adrian Exp $ + * $Id: authenticate.cc,v 1.46 2002/10/15 09:25:33 robertc Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -1088,8 +1088,10 @@ AuthUserHashPointer::operator delete (void *address) } AuthUserHashPointer::AuthUserHashPointer (auth_user_t * anAuth_user): -key (anAuth_user->username()), next (NULL), auth_user (anAuth_user) +auth_user (anAuth_user) { + key = (void *)anAuth_user->username(); + next = NULL; hash_join(proxy_auth_username_cache, (hash_link *) this); /* lock for presence in the cache */ authenticateAuthUserLock(auth_user); diff --git a/src/authenticate.h b/src/authenticate.h index c0ea93cfc8..fd7161a5fd 100644 --- a/src/authenticate.h +++ b/src/authenticate.h @@ -1,6 +1,6 @@ /* - * $Id: authenticate.h,v 1.2 2002/10/14 06:19:49 adrian Exp $ + * $Id: authenticate.h,v 1.3 2002/10/15 09:25:33 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -43,10 +43,8 @@ class AuthUser; #endif -struct AuthUserHashPointer { +struct AuthUserHashPointer : public hash_link { /* first two items must be same as hash_link */ - char const *key; - auth_user_hash_pointer *next; #ifdef __cplusplus public: static void removeFromCache (void *anAuthUserHashPointer); diff --git a/src/external_acl.cc b/src/external_acl.cc index 23902620b6..8e27a6abfb 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.15 2002/10/13 20:35:01 robertc Exp $ + * $Id: external_acl.cc,v 1.16 2002/10/15 09:25:33 robertc Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -64,8 +64,7 @@ static void external_acl_cache_touch(external_acl * def, external_acl_entry * en * external_acl cache entry * Used opaqueue in the interface */ -struct _external_acl_entry { - hash_link hash; +struct _external_acl_entry: public hash_link { dlink_node lru; int result; time_t date; @@ -409,7 +408,7 @@ aclMatchExternal(void *data, aclCheck_t * ch) entry = ch->extacl_entry; if (entry) { if (cbdataReferenceValid(entry) && entry->def == acl->def && - strcmp((char *)entry->hash.key, key) == 0) { + strcmp((char *)entry->key, key) == 0) { /* Ours, use it.. */ } else { /* Not valid, or not ours.. get rid of it */ @@ -577,7 +576,7 @@ static void free_external_acl_entry(void *data) { external_acl_entry *entry = static_cast(data); - safe_free(entry->hash.key); + safe_free(entry->key); safe_free(entry->user); safe_free(entry->error); } @@ -605,7 +604,7 @@ external_acl_cache_add(external_acl * def, const char *key, int result, char *us if (def->cache_size && def->cache_entries >= def->cache_size) external_acl_cache_delete(def, static_cast(def->lru_list.tail->data)); entry = cbdataAlloc(external_acl_entry); - entry->hash.key = xstrdup(key); + entry->key = xstrdup(key); entry->date = squid_curtime; entry->result = result; if (user) @@ -613,7 +612,7 @@ external_acl_cache_add(external_acl * def, const char *key, int result, char *us if (error) entry->error = xstrdup(error); entry->def = def; - hash_join(def->cache, &entry->hash); + hash_join(def->cache, entry); dlinkAdd(entry, &entry->lru, &def->lru_list); def->cache_entries += 1; return entry; @@ -622,7 +621,7 @@ external_acl_cache_add(external_acl * def, const char *key, int result, char *us static void external_acl_cache_delete(external_acl * def, external_acl_entry * entry) { - hash_remove_link(def->cache, &entry->hash); + hash_remove_link(def->cache, entry); dlinkDelete(&entry->lru, &def->lru_list); def->cache_entries -= 1; cbdataFree(entry); diff --git a/src/store.cc b/src/store.cc index 19b1a4f540..3ba1d0bd59 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.550 2002/10/15 08:03:30 robertc Exp $ + * $Id: store.cc,v 1.551 2002/10/15 09:25:33 robertc Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -361,12 +361,11 @@ storeUnlockObject(StoreEntry * e) StoreEntry * storeGet(const cache_key * key) { - void *p; PROF_start(storeGet); debug(20, 3) ("storeGet: looking up %s\n", storeKeyText(key)); - p = hash_lookup(store_table, key); + StoreEntry *p = static_cast(hash_lookup(store_table, key)); PROF_stop(storeGet); - return (StoreEntry *) p; + return p; } void