mirror of
https://github.com/mirror/wget.git
synced 2025-02-07 18:20:14 +08:00
[svn] Retired the `boolean' type. Renamed FREE_MAYBE to xfree_null and moved the
definition from wget.h to xmalloc.h. Moved the DEFAULT_LOGFILE define to log.h. Moved the INFINITE_RECURSION define to recur.h.
This commit is contained in:
parent
3e207912bd
commit
e2e9b753e4
@ -1,3 +1,11 @@
|
||||
2003-11-02 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* wget.h: Retired the `boolean' type. Moved the DEFAULT_LOGFILE
|
||||
define to log.h. Moved the INFINITE_RECURSION define to recur.h.
|
||||
|
||||
* xmalloc.h: Renamed FREE_MAYBE to xfree_null and moved the
|
||||
definition from wget.h to xmalloc.h.
|
||||
|
||||
2003-11-02 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* html-parse.c (decode_entity): New function; split the decoding
|
||||
|
@ -401,7 +401,7 @@ write_backup_file (const char *file, downloaded_file_t downloaded_file_return)
|
||||
/* Construct the backup filename as the original name plus ".orig". */
|
||||
size_t filename_len = strlen(file);
|
||||
char* filename_plus_orig_suffix;
|
||||
boolean already_wrote_backup_file = FALSE;
|
||||
int already_wrote_backup_file = 0;
|
||||
slist* converted_file_ptr;
|
||||
static slist* converted_files = NULL;
|
||||
|
||||
@ -435,7 +435,7 @@ write_backup_file (const char *file, downloaded_file_t downloaded_file_return)
|
||||
while (converted_file_ptr != NULL)
|
||||
if (strcmp(converted_file_ptr->string, file) == 0)
|
||||
{
|
||||
already_wrote_backup_file = TRUE;
|
||||
already_wrote_backup_file = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -145,10 +145,10 @@ cookie_new (void)
|
||||
static void
|
||||
delete_cookie (struct cookie *cookie)
|
||||
{
|
||||
FREE_MAYBE (cookie->domain);
|
||||
FREE_MAYBE (cookie->path);
|
||||
FREE_MAYBE (cookie->attr);
|
||||
FREE_MAYBE (cookie->value);
|
||||
xfree_null (cookie->domain);
|
||||
xfree_null (cookie->path);
|
||||
xfree_null (cookie->attr);
|
||||
xfree_null (cookie->value);
|
||||
xfree (cookie);
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ update_cookie_field (struct cookie *cookie,
|
||||
{
|
||||
if (!VALUE_NON_EMPTY)
|
||||
return 0;
|
||||
FREE_MAYBE (cookie->domain);
|
||||
xfree_null (cookie->domain);
|
||||
/* Strictly speaking, we should set cookie->domain_exact if the
|
||||
domain doesn't begin with a dot. But many sites set the
|
||||
domain to "foo.com" and expect "subhost.foo.com" to get the
|
||||
@ -366,7 +366,7 @@ update_cookie_field (struct cookie *cookie,
|
||||
{
|
||||
if (!VALUE_NON_EMPTY)
|
||||
return 0;
|
||||
FREE_MAYBE (cookie->path);
|
||||
xfree_null (cookie->path);
|
||||
cookie->path = strdupdelim (value_b, value_e);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1150,7 +1150,7 @@ ftp_pwd (struct rbuf *rbuf, char **pwd)
|
||||
request = strtok (NULL, "\"");
|
||||
|
||||
/* Has the `pwd' been already allocated? Free! */
|
||||
FREE_MAYBE (*pwd);
|
||||
xfree_null (*pwd);
|
||||
|
||||
*pwd = xstrdup (request);
|
||||
|
||||
|
14
src/ftp-ls.c
14
src/ftp-ls.c
@ -358,8 +358,8 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
if (error || ignore)
|
||||
{
|
||||
DEBUGP (("Skipping.\n"));
|
||||
FREE_MAYBE (cur.name);
|
||||
FREE_MAYBE (cur.linkto);
|
||||
xfree_null (cur.name);
|
||||
xfree_null (cur.linkto);
|
||||
xfree (line);
|
||||
continue;
|
||||
}
|
||||
@ -783,7 +783,7 @@ ftp_parse_ls (const char *file, const enum stype system_type)
|
||||
switch (system_type)
|
||||
{
|
||||
case ST_UNIX:
|
||||
return ftp_parse_unix_ls (file, FALSE);
|
||||
return ftp_parse_unix_ls (file, 0);
|
||||
case ST_WINNT:
|
||||
{
|
||||
/* Detect whether the listing is simulating the UNIX format */
|
||||
@ -802,16 +802,16 @@ ftp_parse_ls (const char *file, const enum stype system_type)
|
||||
if (c >= '0' && c <='9')
|
||||
return ftp_parse_winnt_ls (file);
|
||||
else
|
||||
return ftp_parse_unix_ls (file, TRUE);
|
||||
return ftp_parse_unix_ls (file, 1);
|
||||
}
|
||||
case ST_VMS:
|
||||
return ftp_parse_vms_ls (file);
|
||||
case ST_MACOS:
|
||||
return ftp_parse_unix_ls (file, TRUE);
|
||||
return ftp_parse_unix_ls (file, 1);
|
||||
default:
|
||||
logprintf (LOG_NOTQUIET, _("\
|
||||
Unsupported listing type, trying Unix listing parser.\n"));
|
||||
return ftp_parse_unix_ls (file, FALSE);
|
||||
return ftp_parse_unix_ls (file, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
|
||||
+ (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
|
||||
sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");
|
||||
xfree (tmpu);
|
||||
FREE_MAYBE (tmpp);
|
||||
xfree_null (tmpp);
|
||||
}
|
||||
else
|
||||
upwd = xstrdup ("");
|
||||
|
@ -54,6 +54,7 @@ so, delete this exception statement from your version. */
|
||||
#include "host.h"
|
||||
#include "netrc.h"
|
||||
#include "convert.h" /* for downloaded_file */
|
||||
#include "recur.h" /* for INFINITE_RECURSION */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
@ -416,7 +417,7 @@ Error in server response, closing control connection.\n"));
|
||||
break;
|
||||
case FTPSRVERR :
|
||||
/* PWD unsupported -- assume "/". */
|
||||
FREE_MAYBE (con->id);
|
||||
xfree_null (con->id);
|
||||
con->id = xstrdup ("/");
|
||||
break;
|
||||
case FTPOK:
|
||||
@ -1924,9 +1925,9 @@ ftp_loop (struct url *u, int *dt, struct url *proxy)
|
||||
/* If a connection was left, quench it. */
|
||||
if (rbuf_initialized_p (&con.rbuf))
|
||||
CLOSE (RBUF_FD (&con.rbuf));
|
||||
FREE_MAYBE (con.id);
|
||||
xfree_null (con.id);
|
||||
con.id = NULL;
|
||||
FREE_MAYBE (con.target);
|
||||
xfree_null (con.target);
|
||||
con.target = NULL;
|
||||
return res;
|
||||
}
|
||||
@ -1941,7 +1942,7 @@ delelement (struct fileinfo *f, struct fileinfo **start)
|
||||
struct fileinfo *next = f->next;
|
||||
|
||||
xfree (f->name);
|
||||
FREE_MAYBE (f->linkto);
|
||||
xfree_null (f->linkto);
|
||||
xfree (f);
|
||||
|
||||
if (next)
|
||||
|
@ -623,7 +623,7 @@ get_urls_html (const char *file, const char *url, int *meta_disallow_follow)
|
||||
if (meta_disallow_follow)
|
||||
*meta_disallow_follow = ctx.nofollow;
|
||||
|
||||
FREE_MAYBE (ctx.base);
|
||||
xfree_null (ctx.base);
|
||||
read_file_free (fm);
|
||||
return ctx.head;
|
||||
}
|
||||
@ -715,6 +715,6 @@ get_urls_file (const char *file)
|
||||
void
|
||||
cleanup_html_url (void)
|
||||
{
|
||||
FREE_MAYBE (interesting_tags);
|
||||
FREE_MAYBE (interesting_attributes);
|
||||
xfree_null (interesting_tags);
|
||||
xfree_null (interesting_attributes);
|
||||
}
|
||||
|
92
src/http.c
92
src/http.c
@ -582,9 +582,9 @@ struct http_stat
|
||||
static void
|
||||
free_hstat (struct http_stat *hs)
|
||||
{
|
||||
FREE_MAYBE (hs->newloc);
|
||||
FREE_MAYBE (hs->remote_time);
|
||||
FREE_MAYBE (hs->error);
|
||||
xfree_null (hs->newloc);
|
||||
xfree_null (hs->remote_time);
|
||||
xfree_null (hs->error);
|
||||
|
||||
/* Guard against being called twice. */
|
||||
hs->newloc = NULL;
|
||||
@ -987,9 +987,9 @@ Accept: %s\r\n\
|
||||
DEBUGP (("---request begin---\n%s", request));
|
||||
|
||||
/* Free the temporary memory. */
|
||||
FREE_MAYBE (wwwauth);
|
||||
FREE_MAYBE (proxyauth);
|
||||
FREE_MAYBE (cookies);
|
||||
xfree_null (wwwauth);
|
||||
xfree_null (proxyauth);
|
||||
xfree_null (cookies);
|
||||
xfree (full_path);
|
||||
|
||||
/* Send the request to server. */
|
||||
@ -1079,8 +1079,8 @@ Accept: %s\r\n\
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logputs (LOG_NOTQUIET, _("End of file while parsing headers.\n"));
|
||||
xfree (hdr);
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
CLOSE_INVALIDATE (sock);
|
||||
return HEOF;
|
||||
}
|
||||
@ -1090,8 +1090,8 @@ Accept: %s\r\n\
|
||||
logprintf (LOG_NOTQUIET, _("Read error (%s) in headers.\n"),
|
||||
strerror (errno));
|
||||
xfree (hdr);
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
CLOSE_INVALIDATE (sock);
|
||||
return HERR;
|
||||
}
|
||||
@ -1251,7 +1251,7 @@ Accept: %s\r\n\
|
||||
&& authenticate_h)
|
||||
{
|
||||
/* Authorization is required. */
|
||||
FREE_MAYBE (type);
|
||||
xfree_null (type);
|
||||
type = NULL;
|
||||
free_hstat (hs);
|
||||
CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
|
||||
@ -1313,8 +1313,8 @@ Accept: %s\r\n\
|
||||
hs->newloc ? _(" [following]") : "");
|
||||
CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
|
||||
might be more bytes in the body. */
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
return NEWLOCATION;
|
||||
}
|
||||
}
|
||||
@ -1384,8 +1384,8 @@ Accept: %s\r\n\
|
||||
hs->res = 0;
|
||||
/* Mark as successfully retrieved. */
|
||||
*dt |= RETROKF;
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
|
||||
might be more bytes in the body. */
|
||||
return RETRUNNEEDED;
|
||||
@ -1399,8 +1399,8 @@ Accept: %s\r\n\
|
||||
\n\
|
||||
Continued download failed on this file, which conflicts with `-c'.\n\
|
||||
Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
CLOSE_INVALIDATE (sock);
|
||||
return CONTNOTSUPPORTED;
|
||||
}
|
||||
@ -1415,8 +1415,8 @@ Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
|
||||
{
|
||||
/* This means the whole request was somehow misunderstood by the
|
||||
server. Bail out. */
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
CLOSE_INVALIDATE (sock);
|
||||
return RANGEERR;
|
||||
}
|
||||
@ -1455,7 +1455,7 @@ Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
}
|
||||
}
|
||||
FREE_MAYBE (type);
|
||||
xfree_null (type);
|
||||
type = NULL; /* We don't need it any more. */
|
||||
|
||||
/* Return if we have no intention of further downloading. */
|
||||
@ -1464,8 +1464,8 @@ Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
|
||||
/* In case the caller cares to look... */
|
||||
hs->len = 0L;
|
||||
hs->res = 0;
|
||||
FREE_MAYBE (type);
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (type);
|
||||
xfree_null (all_headers);
|
||||
CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
|
||||
might be more bytes in the body. */
|
||||
return RETRFINISHED;
|
||||
@ -1483,7 +1483,7 @@ Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
|
||||
logprintf (LOG_NOTQUIET, "%s: %s\n", *hs->local_file, strerror (errno));
|
||||
CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there
|
||||
might be more bytes in the body. */
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (all_headers);
|
||||
return FOPENERR;
|
||||
}
|
||||
}
|
||||
@ -1547,7 +1547,7 @@ Refusing to truncate existing file `%s'.\n\n"), *hs->local_file);
|
||||
if (flush_res == EOF)
|
||||
hs->res = -2;
|
||||
}
|
||||
FREE_MAYBE (all_headers);
|
||||
xfree_null (all_headers);
|
||||
if (hs->res == -2)
|
||||
return FWRITEERR;
|
||||
return RETRFINISHED;
|
||||
@ -1632,14 +1632,14 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
if (has_html_suffix_p (*hstat.local_file))
|
||||
*dt |= TEXTHTML;
|
||||
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
}
|
||||
|
||||
use_ts = 0;
|
||||
if (opt.timestamping)
|
||||
{
|
||||
boolean local_dot_orig_file_exists = FALSE;
|
||||
int local_dot_orig_file_exists = 0;
|
||||
|
||||
if (opt.backup_converted)
|
||||
/* If -K is specified, we'll act on the assumption that it was specified
|
||||
@ -1666,7 +1666,7 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
/* Try to stat() the .orig file. */
|
||||
if (stat (filename_plus_orig_suffix, &st) == 0)
|
||||
{
|
||||
local_dot_orig_file_exists = TRUE;
|
||||
local_dot_orig_file_exists = 1;
|
||||
local_filename = filename_plus_orig_suffix;
|
||||
}
|
||||
}
|
||||
@ -1788,7 +1788,7 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
case SSLERRCTXCREATE: case CONTNOTSUPPORTED:
|
||||
/* Fatal errors just return from the function. */
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return err;
|
||||
break;
|
||||
case FWRITEERR: case FOPENERR:
|
||||
@ -1797,7 +1797,7 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"),
|
||||
*hstat.local_file, strerror (errno));
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return err;
|
||||
break;
|
||||
case CONSSLERR:
|
||||
@ -1805,7 +1805,7 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("Unable to establish SSL connection.\n"));
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return err;
|
||||
break;
|
||||
case NEWLOCATION:
|
||||
@ -1816,17 +1816,17 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
_("ERROR: Redirection (%d) without location.\n"),
|
||||
hstat.statcode);
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return WRONGCODE;
|
||||
}
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return NEWLOCATION;
|
||||
break;
|
||||
case RETRUNNEEDED:
|
||||
/* The file was already fully retrieved. */
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
break;
|
||||
case RETRFINISHED:
|
||||
@ -1849,7 +1849,7 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
|
||||
tms, hstat.statcode, hstat.error);
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return WRONGCODE;
|
||||
}
|
||||
|
||||
@ -1893,7 +1893,7 @@ Last-modified header invalid -- time-stamp ignored.\n"));
|
||||
Server file no newer than local file `%s' -- not retrieving.\n\n"),
|
||||
local_filename);
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
}
|
||||
else if (tml >= tmr)
|
||||
@ -1931,7 +1931,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
||||
if (opt.spider)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode, hstat.error);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
}
|
||||
|
||||
@ -1958,7 +1958,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
||||
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
||||
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
}
|
||||
else if (hstat.res == 0) /* No read error */
|
||||
@ -1985,7 +1985,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
||||
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
||||
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
}
|
||||
else if (hstat.len < hstat.contlen) /* meaning we lost the
|
||||
@ -2016,7 +2016,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
||||
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
||||
|
||||
free_hstat (&hstat);
|
||||
FREE_MAYBE (dummy);
|
||||
xfree_null (dummy);
|
||||
return RETROK;
|
||||
}
|
||||
else /* the same, but not accepted */
|
||||
@ -2323,7 +2323,7 @@ extract_header_attr (const char *au, const char *attr_name, char **ret)
|
||||
;
|
||||
if (!*ep)
|
||||
return -1;
|
||||
FREE_MAYBE (*ret);
|
||||
xfree_null (*ret);
|
||||
*ret = strdupdelim (cp, ep);
|
||||
return ep - au + 1;
|
||||
}
|
||||
@ -2380,9 +2380,9 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
options[i].variable);
|
||||
if (skip < 0)
|
||||
{
|
||||
FREE_MAYBE (realm);
|
||||
FREE_MAYBE (opaque);
|
||||
FREE_MAYBE (nonce);
|
||||
xfree_null (realm);
|
||||
xfree_null (opaque);
|
||||
xfree_null (nonce);
|
||||
return NULL;
|
||||
}
|
||||
else if (skip)
|
||||
@ -2415,9 +2415,9 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
}
|
||||
if (!realm || !nonce || !user || !passwd || !path || !method)
|
||||
{
|
||||
FREE_MAYBE (realm);
|
||||
FREE_MAYBE (opaque);
|
||||
FREE_MAYBE (nonce);
|
||||
xfree_null (realm);
|
||||
xfree_null (opaque);
|
||||
xfree_null (nonce);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
49
src/init.c
49
src/init.c
@ -65,6 +65,7 @@ so, delete this exception statement from your version. */
|
||||
#include "netrc.h"
|
||||
#include "cookies.h" /* for cookie_jar_delete */
|
||||
#include "progress.h"
|
||||
#include "recur.h" /* for INFINITE_RECURSION */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
@ -353,7 +354,7 @@ wgetrc_file_name (void)
|
||||
file = (char *)xmalloc (strlen (home) + 1 + strlen (".wgetrc") + 1);
|
||||
sprintf (file, "%s/.wgetrc", home);
|
||||
}
|
||||
FREE_MAYBE (home);
|
||||
xfree_null (home);
|
||||
#else /* WINDOWS */
|
||||
/* Under Windows, "home" is (for the purposes of this function) the
|
||||
directory where `wget.exe' resides, and `wget.ini' will be used
|
||||
@ -715,7 +716,7 @@ cmd_string (const char *com, const char *val, void *closure)
|
||||
{
|
||||
char **pstring = (char **)closure;
|
||||
|
||||
FREE_MAYBE (*pstring);
|
||||
xfree_null (*pstring);
|
||||
*pstring = xstrdup (val);
|
||||
return 1;
|
||||
}
|
||||
@ -734,7 +735,7 @@ cmd_file (const char *com, const char *val, void *closure)
|
||||
{
|
||||
char **pstring = (char **)closure;
|
||||
|
||||
FREE_MAYBE (*pstring);
|
||||
xfree_null (*pstring);
|
||||
|
||||
/* #### If VAL is empty, perhaps should set *CLOSURE to NULL. */
|
||||
|
||||
@ -1040,7 +1041,7 @@ cmd_spec_header (const char *com, const char *val, void *closure)
|
||||
if (!*val)
|
||||
{
|
||||
/* Empty header means reset headers. */
|
||||
FREE_MAYBE (opt.user_header);
|
||||
xfree_null (opt.user_header);
|
||||
opt.user_header = NULL;
|
||||
}
|
||||
else
|
||||
@ -1108,7 +1109,7 @@ cmd_spec_progress (const char *com, const char *val, void *closure)
|
||||
exec_name, com, val);
|
||||
return 0;
|
||||
}
|
||||
FREE_MAYBE (opt.progress_type);
|
||||
xfree_null (opt.progress_type);
|
||||
|
||||
/* Don't call set_progress_implementation here. It will be called
|
||||
in main() when it becomes clear what the log output is. */
|
||||
@ -1324,10 +1325,10 @@ cleanup (void)
|
||||
extern acc_t *netrc_list;
|
||||
free_netrc (netrc_list);
|
||||
}
|
||||
FREE_MAYBE (opt.lfilename);
|
||||
FREE_MAYBE (opt.dir_prefix);
|
||||
FREE_MAYBE (opt.input_filename);
|
||||
FREE_MAYBE (opt.output_document);
|
||||
xfree_null (opt.lfilename);
|
||||
xfree_null (opt.dir_prefix);
|
||||
xfree_null (opt.input_filename);
|
||||
xfree_null (opt.output_document);
|
||||
free_vec (opt.accepts);
|
||||
free_vec (opt.rejects);
|
||||
free_vec (opt.excludes);
|
||||
@ -1335,24 +1336,24 @@ cleanup (void)
|
||||
free_vec (opt.domains);
|
||||
free_vec (opt.follow_tags);
|
||||
free_vec (opt.ignore_tags);
|
||||
FREE_MAYBE (opt.progress_type);
|
||||
xfree_null (opt.progress_type);
|
||||
xfree (opt.ftp_acc);
|
||||
FREE_MAYBE (opt.ftp_pass);
|
||||
FREE_MAYBE (opt.ftp_proxy);
|
||||
FREE_MAYBE (opt.https_proxy);
|
||||
FREE_MAYBE (opt.http_proxy);
|
||||
xfree_null (opt.ftp_pass);
|
||||
xfree_null (opt.ftp_proxy);
|
||||
xfree_null (opt.https_proxy);
|
||||
xfree_null (opt.http_proxy);
|
||||
free_vec (opt.no_proxy);
|
||||
FREE_MAYBE (opt.useragent);
|
||||
FREE_MAYBE (opt.referer);
|
||||
FREE_MAYBE (opt.http_user);
|
||||
FREE_MAYBE (opt.http_passwd);
|
||||
FREE_MAYBE (opt.user_header);
|
||||
xfree_null (opt.useragent);
|
||||
xfree_null (opt.referer);
|
||||
xfree_null (opt.http_user);
|
||||
xfree_null (opt.http_passwd);
|
||||
xfree_null (opt.user_header);
|
||||
#ifdef HAVE_SSL
|
||||
FREE_MAYBE (opt.sslcertkey);
|
||||
FREE_MAYBE (opt.sslcertfile);
|
||||
xfree_null (opt.sslcertkey);
|
||||
xfree_null (opt.sslcertfile);
|
||||
#endif /* HAVE_SSL */
|
||||
FREE_MAYBE (opt.bind_address);
|
||||
FREE_MAYBE (opt.cookies_input);
|
||||
FREE_MAYBE (opt.cookies_output);
|
||||
xfree_null (opt.bind_address);
|
||||
xfree_null (opt.cookies_input);
|
||||
xfree_null (opt.cookies_output);
|
||||
#endif
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ so, delete this exception statement from your version. */
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
/* The log file to which Wget writes to after HUP. */
|
||||
#define DEFAULT_LOGFILE "wget-log"
|
||||
|
||||
/* Make gcc check for the format of logmsg() and debug_logmsg(). */
|
||||
#ifdef __GNUC__
|
||||
# define GCC_FORMAT_ATTR(a, b) __attribute__ ((format (printf, a, b)))
|
||||
|
@ -895,8 +895,8 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
||||
logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
|
||||
}
|
||||
|
||||
FREE_MAYBE (redirected_URL);
|
||||
FREE_MAYBE (filename);
|
||||
xfree_null (redirected_URL);
|
||||
xfree_null (filename);
|
||||
}
|
||||
|
||||
/* And then from the input file, if any. */
|
||||
|
@ -455,9 +455,9 @@ free_netrc(acc_t *l)
|
||||
while (l)
|
||||
{
|
||||
t = l->next;
|
||||
FREE_MAYBE (l->acc);
|
||||
FREE_MAYBE (l->passwd);
|
||||
FREE_MAYBE (l->host);
|
||||
xfree_null (l->acc);
|
||||
xfree_null (l->passwd);
|
||||
xfree_null (l->host);
|
||||
xfree (l);
|
||||
l = t;
|
||||
}
|
||||
|
10
src/recur.c
10
src/recur.c
@ -222,7 +222,7 @@ retrieve_tree (const char *start_url)
|
||||
int descend = 0;
|
||||
char *url, *referer, *file = NULL;
|
||||
int depth, html_allowed;
|
||||
boolean dash_p_leaf_HTML = FALSE;
|
||||
int dash_p_leaf_HTML = 0;
|
||||
|
||||
if (opt.quota && total_downloaded_bytes > opt.quota)
|
||||
break;
|
||||
@ -304,7 +304,7 @@ retrieve_tree (const char *start_url)
|
||||
one, but we allow one more level so that the leaf
|
||||
pages that contain frames can be loaded
|
||||
correctly. */
|
||||
dash_p_leaf_HTML = TRUE;
|
||||
dash_p_leaf_HTML = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,8 +382,8 @@ retrieve_tree (const char *start_url)
|
||||
}
|
||||
|
||||
xfree (url);
|
||||
FREE_MAYBE (referer);
|
||||
FREE_MAYBE (file);
|
||||
xfree_null (referer);
|
||||
xfree_null (file);
|
||||
}
|
||||
|
||||
/* If anything is left of the queue due to a premature exit, free it
|
||||
@ -395,7 +395,7 @@ retrieve_tree (const char *start_url)
|
||||
(const char **)&d1, (const char **)&d2, &d3, &d4))
|
||||
{
|
||||
xfree (d1);
|
||||
FREE_MAYBE (d2);
|
||||
xfree_null (d2);
|
||||
}
|
||||
}
|
||||
url_queue_delete (queue);
|
||||
|
@ -30,6 +30,14 @@ so, delete this exception statement from your version. */
|
||||
#ifndef RECUR_H
|
||||
#define RECUR_H
|
||||
|
||||
/* For most options, 0 means no limits, but with -p in the picture,
|
||||
that causes a problem on the maximum recursion depth variable. To
|
||||
retain backwards compatibility we allow users to consider "0" to be
|
||||
synonymous with "inf" for -l, but internally infinite recursion is
|
||||
specified by -1 and 0 means to only retrieve the requisites of a
|
||||
single document. */
|
||||
#define INFINITE_RECURSION -1
|
||||
|
||||
struct urlpos;
|
||||
|
||||
void recursive_cleanup PARAMS ((void));
|
||||
|
@ -406,7 +406,7 @@ free_specs (struct robot_specs *specs)
|
||||
int i;
|
||||
for (i = 0; i < specs->count; i++)
|
||||
xfree (specs->paths[i].path);
|
||||
FREE_MAYBE (specs->paths);
|
||||
xfree_null (specs->paths);
|
||||
xfree (specs);
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
||||
if (file)
|
||||
*file = local_file ? local_file : NULL;
|
||||
else
|
||||
FREE_MAYBE (local_file);
|
||||
xfree_null (local_file);
|
||||
|
||||
url_free (u);
|
||||
|
||||
@ -601,8 +601,8 @@ retrieve_from_file (const char *file, int html, int *count)
|
||||
dt &= ~RETROKF;
|
||||
}
|
||||
|
||||
FREE_MAYBE (new_file);
|
||||
FREE_MAYBE (filename);
|
||||
xfree_null (new_file);
|
||||
xfree_null (filename);
|
||||
}
|
||||
|
||||
/* Free the linked list of URL-s. */
|
||||
@ -675,7 +675,7 @@ free_urlpos (struct urlpos *l)
|
||||
struct urlpos *next = l->next;
|
||||
if (l->url)
|
||||
url_free (l->url);
|
||||
FREE_MAYBE (l->local_name);
|
||||
xfree_null (l->local_name);
|
||||
xfree (l);
|
||||
l = next;
|
||||
}
|
||||
|
10
src/url.c
10
src/url.c
@ -1236,11 +1236,11 @@ url_free (struct url *url)
|
||||
xfree (url->path);
|
||||
xfree (url->url);
|
||||
|
||||
FREE_MAYBE (url->params);
|
||||
FREE_MAYBE (url->query);
|
||||
FREE_MAYBE (url->fragment);
|
||||
FREE_MAYBE (url->user);
|
||||
FREE_MAYBE (url->passwd);
|
||||
xfree_null (url->params);
|
||||
xfree_null (url->query);
|
||||
xfree_null (url->fragment);
|
||||
xfree_null (url->user);
|
||||
xfree_null (url->passwd);
|
||||
|
||||
xfree (url->dir);
|
||||
xfree (url->file);
|
||||
|
96
src/wget.h
96
src/wget.h
@ -1,5 +1,5 @@
|
||||
/* Miscellaneous declarations.
|
||||
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Wget.
|
||||
|
||||
@ -27,9 +27,10 @@ modify this file, you may extend this exception to your version of the
|
||||
file, but you are not obligated to do so. If you do not wish to do
|
||||
so, delete this exception statement from your version. */
|
||||
|
||||
/* This file contains some declarations that don't fit anywhere else.
|
||||
It also contains some useful includes, like the obnoxious TIME_H
|
||||
inclusion. */
|
||||
/* This file contains declarations that are universally useful and
|
||||
those that don't fit elsewhere. It also includes sysdep.h which
|
||||
includes some often-needed system includes, like the obnoxious
|
||||
<time.h> inclusion. */
|
||||
|
||||
#ifndef WGET_H
|
||||
#define WGET_H
|
||||
@ -60,7 +61,7 @@ so, delete this exception statement from your version. */
|
||||
# include <libintl.h>
|
||||
# endif /* HAVE_LIBINTL_H */
|
||||
#else /* not HAVE_NLS */
|
||||
# define _(string) string
|
||||
# define _(string) (string)
|
||||
#endif /* not HAVE_NLS */
|
||||
|
||||
/* No-op version of gettext, used for constant strings. */
|
||||
@ -102,15 +103,11 @@ so, delete this exception statement from your version. */
|
||||
|
||||
/* Likewise for logging functions. */
|
||||
#include "log.h"
|
||||
|
||||
/* #### Find a better place for this. */
|
||||
/* The log file to which Wget writes to after HUP. */
|
||||
#define DEFAULT_LOGFILE "wget-log"
|
||||
|
||||
/* Useful macros used across the code: */
|
||||
|
||||
/* The number of elements in an array. For example:
|
||||
static char a[] = "foo"; -- countof(a) == 4 (for terminating \0)
|
||||
static char a[] = "foo"; -- countof(a) == 4 (note terminating \0)
|
||||
int a[5] = {1, 2}; -- countof(a) == 5
|
||||
char *a[] = { -- countof(a) == 3
|
||||
"foo", "bar", "baz"
|
||||
@ -118,17 +115,17 @@ so, delete this exception statement from your version. */
|
||||
#define countof(array) (sizeof (array) / sizeof ((array)[0]))
|
||||
|
||||
/* Zero out a value. */
|
||||
#define xzero(x) memset (&(x), '\0', sizeof ((x)))
|
||||
#define xzero(x) memset (&(x), '\0', sizeof (x))
|
||||
|
||||
/* Convert an ASCII hex digit to the corresponding number between 0
|
||||
and 15. X should be a hexadecimal digit that satisfies isxdigit;
|
||||
and 15. H should be a hexadecimal digit that satisfies isxdigit;
|
||||
otherwise, the result is undefined. */
|
||||
#define XDIGIT_TO_NUM(h) ((h) < 'A' ? (h) - '0' : TOUPPER (h) - 'A' + 10)
|
||||
#define X2DIGITS_TO_NUM(h1, h2) ((XDIGIT_TO_NUM (h1) << 4) + XDIGIT_TO_NUM (h2))
|
||||
|
||||
/* The reverse of the above: convert a number in the [0, 16) range to
|
||||
the ASCII representation of the corresponding hex digit. The `+ 0'
|
||||
is so you don't accidentally use it as an lvalue. */
|
||||
the ASCII representation of the corresponding hexadecimal digit.
|
||||
`+ 0' is there so you can't accidentally use it as an lvalue. */
|
||||
#define XNUM_TO_DIGIT(x) ("0123456789ABCDEF"[x] + 0)
|
||||
#define XNUM_TO_digit(x) ("0123456789abcdef"[x] + 0)
|
||||
|
||||
@ -146,24 +143,20 @@ so, delete this exception statement from your version. */
|
||||
|
||||
/* Return non-zero if string bounded between BEG and END is equal to
|
||||
STRING_LITERAL. The comparison is case-sensitive. */
|
||||
#define BOUNDED_EQUAL(beg, end, string_literal) \
|
||||
((end) - (beg) == sizeof (string_literal) - 1 \
|
||||
&& !memcmp ((beg), (string_literal), \
|
||||
sizeof (string_literal) - 1))
|
||||
#define BOUNDED_EQUAL(beg, end, string_literal) \
|
||||
((end) - (beg) == sizeof (string_literal) - 1 \
|
||||
&& !memcmp (beg, string_literal, sizeof (string_literal) - 1))
|
||||
|
||||
/* The same as above, except the comparison is case-insensitive. */
|
||||
#define BOUNDED_EQUAL_NO_CASE(beg, end, string_literal) \
|
||||
((end) - (beg) == sizeof (string_literal) - 1 \
|
||||
&& !strncasecmp ((beg), (string_literal), \
|
||||
sizeof (string_literal) - 1))
|
||||
#define BOUNDED_EQUAL_NO_CASE(beg, end, string_literal) \
|
||||
((end) - (beg) == sizeof (string_literal) - 1 \
|
||||
&& !strncasecmp (beg, string_literal, sizeof (string_literal) - 1))
|
||||
|
||||
/* Note that this much more elegant definition cannot be used:
|
||||
|
||||
#define STRDUP_ALLOCA(str) (strcpy ((char *)alloca (strlen (str) + 1), str))
|
||||
|
||||
This is because some compilers don't handle alloca() as argument to
|
||||
function correctly. Gcc on Intel platforms has been reported to
|
||||
offend in this case. */
|
||||
/* Like ptr=strdup(str), but allocates the space for PTR on the stack.
|
||||
This cannot be an expression because this is not portable:
|
||||
#define STRDUP_ALLOCA(str) (strcpy (alloca (strlen (str) + 1), str))
|
||||
The problem is that some compilers can't handle alloca() being an
|
||||
argument to a function. */
|
||||
|
||||
#define STRDUP_ALLOCA(ptr, str) do { \
|
||||
char **SA_dest = &(ptr); \
|
||||
@ -179,22 +172,19 @@ so, delete this exception statement from your version. */
|
||||
will realloc BASEVAR as necessary so that it can hold at least
|
||||
NEEDED_SIZE objects. The reallocing is done by doubling, which
|
||||
ensures constant amortized time per element. */
|
||||
#define DO_REALLOC(basevar, sizevar, needed_size, type) do { \
|
||||
/* Avoid side effects by prefixing the local vars. */ \
|
||||
long do_realloc_needed_size = (needed_size); \
|
||||
long do_realloc_newsize = 0; \
|
||||
while ((sizevar) < (do_realloc_needed_size)) { \
|
||||
do_realloc_newsize = 2*(sizevar); \
|
||||
if (do_realloc_newsize < 32) \
|
||||
do_realloc_newsize = 32; \
|
||||
(sizevar) = do_realloc_newsize; \
|
||||
} \
|
||||
if (do_realloc_newsize) \
|
||||
basevar = (type *)xrealloc (basevar, do_realloc_newsize * sizeof (type)); \
|
||||
} while (0)
|
||||
|
||||
/* Free FOO if it is non-NULL. */
|
||||
#define FREE_MAYBE(foo) do { if (foo) xfree ((foo)); } while (0)
|
||||
#define DO_REALLOC(basevar, sizevar, needed_size, type) do { \
|
||||
long DR_needed_size = (needed_size); \
|
||||
long DR_newsize = 0; \
|
||||
while ((sizevar) < (DR_needed_size)) { \
|
||||
DR_newsize = sizevar << 1; \
|
||||
if (DR_newsize < 16) \
|
||||
DR_newsize = 16; \
|
||||
(sizevar) = DR_newsize; \
|
||||
} \
|
||||
if (DR_newsize) \
|
||||
basevar = (type *)xrealloc (basevar, DR_newsize * sizeof (type)); \
|
||||
} while (0)
|
||||
|
||||
extern const char *exec_name;
|
||||
|
||||
@ -231,24 +221,6 @@ typedef enum
|
||||
SSLERRCERTFILE,SSLERRCERTKEY,SSLERRCTXCREATE
|
||||
} uerr_t;
|
||||
|
||||
/* These are not used widely. They should either be removed or used
|
||||
consistently. */
|
||||
typedef unsigned char boolean;
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
/* For most options, 0 means no limits, but with -p in the picture,
|
||||
that causes a problem on the maximum recursion depth variable. To
|
||||
retain backwards compatibility we allow users to consider "0" to be
|
||||
synonymous with "inf" for -l, but internally infinite recursion is
|
||||
specified by -1 and 0 means to only retrieve the requisites of a
|
||||
single document. */
|
||||
#define INFINITE_RECURSION -1
|
||||
|
||||
/* In case old systems don't have EAFNOSUPPORT, which we use below. */
|
||||
#ifndef EAFNOSUPPORT
|
||||
# define EAFNOSUPPORT EINVAL
|
||||
|
@ -76,4 +76,10 @@ char *xstrdup_debug PARAMS ((const char *, const char *, int));
|
||||
|
||||
#define alloca_array(type, size) ((type *) alloca ((size) * sizeof (type)))
|
||||
|
||||
/* Free P if it is non-NULL. C requires free() to behaves this way by
|
||||
default, but Wget's code is historically careful not to pass NULL
|
||||
to free. This allows us to assert p!=NULL in xfree to check
|
||||
additional errors. (But we currently don't do that!) */
|
||||
#define xfree_null(p) if (!(p)) ; else xfree (p)
|
||||
|
||||
#endif /* XMALLOC_H */
|
||||
|
Loading…
Reference in New Issue
Block a user