mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] jar->chains_by_domain -> jar->chains
This commit is contained in:
parent
6359e38d96
commit
df4064bc68
@ -77,8 +77,8 @@ time_t http_atotm PARAMS ((const char *));
|
||||
the cookies. */
|
||||
|
||||
struct cookie_jar {
|
||||
/* Mapping between domains and their corresponding cookies. */
|
||||
struct hash_table *chains_by_domain;
|
||||
/* Cookie chains indexed by domain. */
|
||||
struct hash_table *chains;
|
||||
|
||||
int cookie_count; /* number of cookies in the jar. */
|
||||
};
|
||||
@ -91,7 +91,7 @@ struct cookie_jar *
|
||||
cookie_jar_new (void)
|
||||
{
|
||||
struct cookie_jar *jar = xmalloc (sizeof (struct cookie_jar));
|
||||
jar->chains_by_domain = make_nocase_string_hash_table (0);
|
||||
jar->chains = make_nocase_string_hash_table (0);
|
||||
jar->cookie_count = 0;
|
||||
return jar;
|
||||
}
|
||||
@ -157,10 +157,10 @@ delete_cookie (struct cookie *cookie)
|
||||
|
||||
/* Functions for storing cookies.
|
||||
|
||||
All cookies can be reached beginning with jar->chains_by_domain.
|
||||
The key in that table is the domain name, and the value is a linked
|
||||
list of all cookies from that domain. Every new cookie is placed
|
||||
on the head of the list. */
|
||||
All cookies can be reached beginning with jar->chains. The key in
|
||||
that table is the domain name, and the value is a linked list of
|
||||
all cookies from that domain. Every new cookie is placed on the
|
||||
head of the list. */
|
||||
|
||||
/* Find and return a cookie in JAR whose domain, path, and attribute
|
||||
name correspond to COOKIE. If found, PREVPTR will point to the
|
||||
@ -175,7 +175,7 @@ find_matching_cookie (struct cookie_jar *jar, struct cookie *cookie,
|
||||
{
|
||||
struct cookie *chain, *prev;
|
||||
|
||||
chain = hash_table_get (jar->chains_by_domain, cookie->domain);
|
||||
chain = hash_table_get (jar->chains, cookie->domain);
|
||||
if (!chain)
|
||||
goto nomatch;
|
||||
|
||||
@ -209,7 +209,7 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
|
||||
struct cookie *chain_head;
|
||||
char *chain_key;
|
||||
|
||||
if (hash_table_get_pair (jar->chains_by_domain, cookie->domain,
|
||||
if (hash_table_get_pair (jar->chains, cookie->domain,
|
||||
&chain_key, &chain_head))
|
||||
{
|
||||
/* A chain of cookies in this domain already exists. Check for
|
||||
@ -252,7 +252,7 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
|
||||
chain_key = xstrdup (cookie->domain);
|
||||
}
|
||||
|
||||
hash_table_put (jar->chains_by_domain, chain_key, cookie);
|
||||
hash_table_put (jar->chains, chain_key, cookie);
|
||||
++jar->cookie_count;
|
||||
|
||||
DEBUGP (("\nStored cookie %s %d%s %s %s %d %s %s %s\n",
|
||||
@ -277,7 +277,7 @@ discard_matching_cookie (struct cookie_jar *jar, struct cookie *cookie)
|
||||
{
|
||||
struct cookie *prev, *victim;
|
||||
|
||||
if (!hash_table_count (jar->chains_by_domain))
|
||||
if (!hash_table_count (jar->chains))
|
||||
/* No elements == nothing to discard. */
|
||||
return;
|
||||
|
||||
@ -294,18 +294,18 @@ discard_matching_cookie (struct cookie_jar *jar, struct cookie *cookie)
|
||||
char *chain_key = NULL;
|
||||
int res;
|
||||
|
||||
res = hash_table_get_pair (jar->chains_by_domain, victim->domain,
|
||||
res = hash_table_get_pair (jar->chains, victim->domain,
|
||||
&chain_key, NULL);
|
||||
assert (res != 0);
|
||||
if (!victim->next)
|
||||
{
|
||||
/* VICTIM was the only cookie in the chain. Destroy the
|
||||
chain and deallocate the chain key. */
|
||||
hash_table_remove (jar->chains_by_domain, victim->domain);
|
||||
hash_table_remove (jar->chains, victim->domain);
|
||||
xfree (chain_key);
|
||||
}
|
||||
else
|
||||
hash_table_put (jar->chains_by_domain, chain_key, victim->next);
|
||||
hash_table_put (jar->chains, chain_key, victim->next);
|
||||
}
|
||||
delete_cookie (victim);
|
||||
DEBUGP (("Discarded old cookie.\n"));
|
||||
@ -902,7 +902,7 @@ find_chains_of_host (struct cookie_jar *jar, const char *host,
|
||||
int passes, passcnt;
|
||||
|
||||
/* Bail out quickly if there are no cookies in the jar. */
|
||||
if (!hash_table_count (jar->chains_by_domain))
|
||||
if (!hash_table_count (jar->chains))
|
||||
return 0;
|
||||
|
||||
if (numeric_address_p (host))
|
||||
@ -922,7 +922,7 @@ find_chains_of_host (struct cookie_jar *jar, const char *host,
|
||||
srk.fer.hr's, then fer.hr's. */
|
||||
while (1)
|
||||
{
|
||||
struct cookie *chain = hash_table_get (jar->chains_by_domain, host);
|
||||
struct cookie *chain = hash_table_get (jar->chains, host);
|
||||
if (chain)
|
||||
dest[dest_count++] = chain;
|
||||
if (++passcnt >= passes)
|
||||
@ -1434,7 +1434,7 @@ cookie_jar_save (struct cookie_jar *jar, const char *file)
|
||||
fprintf (fp, "# Generated by Wget on %s.\n", datetime_str (NULL));
|
||||
fputs ("# Edit at your own risk.\n\n", fp);
|
||||
|
||||
hash_table_map (jar->chains_by_domain, save_cookies_mapper, fp);
|
||||
hash_table_map (jar->chains, save_cookies_mapper, fp);
|
||||
|
||||
if (ferror (fp))
|
||||
logprintf (LOG_NOTQUIET, _("Error writing to `%s': %s\n"),
|
||||
@ -1460,7 +1460,7 @@ nuke_cookie_chain (void *value, void *key, void *arg)
|
||||
struct cookie_jar *jar = (struct cookie_jar *)arg;
|
||||
|
||||
/* Remove the chain from the table and free the key. */
|
||||
hash_table_remove (jar->chains_by_domain, chain_key);
|
||||
hash_table_remove (jar->chains, chain_key);
|
||||
xfree (chain_key);
|
||||
|
||||
/* Then delete all the cookies in the chain. */
|
||||
@ -1480,8 +1480,8 @@ nuke_cookie_chain (void *value, void *key, void *arg)
|
||||
void
|
||||
cookie_jar_delete (struct cookie_jar *jar)
|
||||
{
|
||||
hash_table_map (jar->chains_by_domain, nuke_cookie_chain, jar);
|
||||
hash_table_destroy (jar->chains_by_domain);
|
||||
hash_table_map (jar->chains, nuke_cookie_chain, jar);
|
||||
hash_table_destroy (jar->chains);
|
||||
xfree (jar);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user