file, but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version. */
-/* Written by Hrvoje Niksic. Parts are loosely inspired by cookie
- code submitted by Tomasz Wegrzanowski.
+/* Written by Hrvoje Niksic. Parts are loosely inspired by the
+ cookie patch submitted by Tomasz Wegrzanowski.
- Ideas for future work:
+ This implements the client-side cookie support, as specified
+ (loosely) by Netscape's "preliminary specification", currently
+ available at:
- * Implement limits on cookie-related sizes, such as max. cookie
- size, max. number of cookies, etc.
+ http://wp.netscape.com/newsref/std/cookie_spec.html
- * Add more "cookie jar" methods, such as methods to iterate over
- stored cookies, to clear temporary cookies, to perform
- intelligent auto-saving, etc.
-
- * Support `Set-Cookie2' and `Cookie2' headers? Does anyone really
- use them? */
+ rfc2109 is not supported because of its incompatibilities with the
+ above widely-used specification. rfc2965 is entirely ignored,
+ since popular client software doesn't implement it, and even the
+ sites that do send Set-Cookie2 also emit Set-Cookie for
+ compatibility. */
#include <config.h>
#include <stdio.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
+#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
+#include <time.h>
#include "wget.h"
#include "utils.h"
#include "cookies.h"
/* This should *really* be in a .h file! */
-time_t http_atotm PARAMS ((const char *));
+time_t http_atotm (const char *);
\f
/* Declarations of `struct cookie' and the most basic functions. */
#ifdef ENABLE_DEBUG
if (opt.debug)
{
- time_t exptime = (time_t) cookie->expiry_time;
+ time_t exptime = cookie->expiry_time;
DEBUGP (("\nStored cookie %s %d%s %s <%s> <%s> [expiry %s] %s %s\n",
cookie->domain, cookie->port,
cookie->port == PORT_ANY ? " (ANY)" : "",
BOUNDED_TO_ALLOCA (value_b, value_e, value_copy);
expires = http_atotm (value_copy);
- if (expires != -1)
+ if (expires != (time_t) -1)
{
cookie->permanent = 1;
- cookie->expiry_time = (time_t)expires;
+ cookie->expiry_time = expires;
}
else
/* Error in expiration spec. Assume default (cookie doesn't
return 1;
}
-static int path_matches PARAMS ((const char *, const char *));
+static int path_matches (const char *, const char *);
/* Check whether PATH begins with COOKIE_PATH. */
if (!check_domain_match (cookie->domain, host))
{
logprintf (LOG_NOTQUIET,
- "Cookie coming from %s attempted to set domain to %s\n",
+ _("Cookie coming from %s attempted to set domain to %s\n"),
escnonprint (host), escnonprint (cookie->domain));
xfree (cookie->domain);
goto copy_domain;
FILE *fp = fopen (file, "r");
if (!fp)
{
- logprintf (LOG_NOTQUIET, "Cannot open cookies file `%s': %s\n",
+ logprintf (LOG_NOTQUIET, _("Cannot open cookies file `%s': %s\n"),
file, strerror (errno));
return;
}