mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Committed <sxsbsv854j9.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
9439a6659b
commit
2ffb47eabf
@ -1,3 +1,17 @@
|
|||||||
|
2000-11-22 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* all: Use xfree() instead of free.
|
||||||
|
|
||||||
|
* utils.c (xfree): New function.
|
||||||
|
|
||||||
|
2000-11-21 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* url.c (convert_links): HTML-quote the converted string.
|
||||||
|
|
||||||
|
* utils.c (html_quote_string): Move here from ftp-ls.c
|
||||||
|
(html_quote_string): Make non-static; declare in utils.h.
|
||||||
|
(html_quote_string): Convert SP to  .
|
||||||
|
|
||||||
2000-11-21 Hrvoje Niksic <hniksic@arsdigita.com>
|
2000-11-21 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* ftp.c (getftp): Reformat Jan's code according to GNU coding
|
* ftp.c (getftp): Reformat Jan's code according to GNU coding
|
||||||
|
130
src/ftp-basic.c
130
src/ftp-basic.c
@ -139,41 +139,41 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
|
|||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPSRVERR;
|
return FTPSRVERR;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* Send USER username. */
|
/* Send USER username. */
|
||||||
request = ftp_request ("USER", acc);
|
request = ftp_request ("USER", acc);
|
||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
/* An unprobable possibility of logging without a password. */
|
/* An unprobable possibility of logging without a password. */
|
||||||
if (*respline == '2')
|
if (*respline == '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
/* Else, only response 3 is appropriate. */
|
/* Else, only response 3 is appropriate. */
|
||||||
if (*respline != '3')
|
if (*respline != '3')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPLOGREFUSED;
|
return FTPLOGREFUSED;
|
||||||
}
|
}
|
||||||
#ifdef USE_OPIE
|
#ifdef USE_OPIE
|
||||||
@ -205,7 +205,7 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bad:
|
bad:
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPLOGREFUSED;
|
return FTPLOGREFUSED;
|
||||||
}
|
}
|
||||||
if ((cp = calculate_skey_response (skey_sequence, cp, pass)) == 0)
|
if ((cp = calculate_skey_response (skey_sequence, cp, pass)) == 0)
|
||||||
@ -214,29 +214,29 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* USE_OPIE */
|
#endif /* USE_OPIE */
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* Send PASS password. */
|
/* Send PASS password. */
|
||||||
request = ftp_request ("PASS", pass);
|
request = ftp_request ("PASS", pass);
|
||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPLOGINC;
|
return FTPLOGINC;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -272,23 +272,23 @@ ftp_port (struct rbuf *rbuf)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPPORTERR;
|
return FTPPORTERR;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,20 +308,20 @@ ftp_pasv (struct rbuf *rbuf, unsigned char *addr)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get the server response. */
|
/* Get the server response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPNOPASV;
|
return FTPNOPASV;
|
||||||
}
|
}
|
||||||
/* Parse the request. */
|
/* Parse the request. */
|
||||||
@ -339,11 +339,11 @@ ftp_pasv (struct rbuf *rbuf, unsigned char *addr)
|
|||||||
else if (i < 5)
|
else if (i < 5)
|
||||||
{
|
{
|
||||||
/* When on the last number, anything can be a terminator. */
|
/* When on the last number, anything can be a terminator. */
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPINVPASV;
|
return FTPINVPASV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,23 +364,23 @@ ftp_type (struct rbuf *rbuf, int type)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPUNKNOWNTYPE;
|
return FTPUNKNOWNTYPE;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -399,28 +399,28 @@ ftp_cwd (struct rbuf *rbuf, const char *dir)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline == '5')
|
if (*respline == '5')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPNSFOD;
|
return FTPNSFOD;
|
||||||
}
|
}
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPRERR;
|
return FTPRERR;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -439,23 +439,23 @@ ftp_rest (struct rbuf *rbuf, long offset)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline != '3')
|
if (*respline != '3')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPRESTFAIL;
|
return FTPRESTFAIL;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -473,28 +473,28 @@ ftp_retr (struct rbuf *rbuf, const char *file)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline == '5')
|
if (*respline == '5')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPNSFOD;
|
return FTPNSFOD;
|
||||||
}
|
}
|
||||||
if (*respline != '1')
|
if (*respline != '1')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPRERR;
|
return FTPRERR;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -513,28 +513,28 @@ ftp_list (struct rbuf *rbuf, const char *file)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate respone. */
|
/* Get appropriate respone. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline == '5')
|
if (*respline == '5')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPNSFOD;
|
return FTPNSFOD;
|
||||||
}
|
}
|
||||||
if (*respline != '1')
|
if (*respline != '1')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPRERR;
|
return FTPRERR;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -552,20 +552,20 @@ ftp_syst (struct rbuf *rbuf, enum stype *host_type)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline == '5')
|
if (*respline == '5')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPSRVERR;
|
return FTPSRVERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ ftp_syst (struct rbuf *rbuf, enum stype *host_type)
|
|||||||
else
|
else
|
||||||
*host_type = ST_OTHER;
|
*host_type = ST_OTHER;
|
||||||
|
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
@ -602,20 +602,20 @@ ftp_pwd (struct rbuf *rbuf, char **pwd)
|
|||||||
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
{
|
{
|
||||||
free (request);
|
xfree (request);
|
||||||
return WRITEFAILED;
|
return WRITEFAILED;
|
||||||
}
|
}
|
||||||
free (request);
|
xfree (request);
|
||||||
/* Get appropriate response. */
|
/* Get appropriate response. */
|
||||||
err = ftp_response (rbuf, &respline);
|
err = ftp_response (rbuf, &respline);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (*respline == '5')
|
if (*respline == '5')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
return FTPSRVERR;
|
return FTPSRVERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,11 +625,11 @@ ftp_pwd (struct rbuf *rbuf, char **pwd)
|
|||||||
request = strtok (NULL, "\"");
|
request = strtok (NULL, "\"");
|
||||||
|
|
||||||
/* Has the `pwd' been already allocated? Free! */
|
/* Has the `pwd' been already allocated? Free! */
|
||||||
if (*pwd) free (*pwd);
|
FREE_MAYBE (*pwd);
|
||||||
|
|
||||||
*pwd = xstrdup (request);
|
*pwd = xstrdup (request);
|
||||||
|
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* All OK. */
|
/* All OK. */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
}
|
}
|
||||||
|
78
src/ftp-ls.c
78
src/ftp-ls.c
@ -114,14 +114,14 @@ ftp_parse_unix_ls (const char *file)
|
|||||||
/* Skip if total... */
|
/* Skip if total... */
|
||||||
if (!strncasecmp (line, "total", 5))
|
if (!strncasecmp (line, "total", 5))
|
||||||
{
|
{
|
||||||
free (line);
|
xfree (line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Get the first token (permissions). */
|
/* Get the first token (permissions). */
|
||||||
tok = strtok (line, " ");
|
tok = strtok (line, " ");
|
||||||
if (!tok)
|
if (!tok)
|
||||||
{
|
{
|
||||||
free (line);
|
xfree (line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ ftp_parse_unix_ls (const char *file)
|
|||||||
DEBUGP (("Skipping.\n"));
|
DEBUGP (("Skipping.\n"));
|
||||||
FREE_MAYBE (cur.name);
|
FREE_MAYBE (cur.name);
|
||||||
FREE_MAYBE (cur.linkto);
|
FREE_MAYBE (cur.linkto);
|
||||||
free (line);
|
xfree (line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ ftp_parse_unix_ls (const char *file)
|
|||||||
timestruct.tm_isdst = -1;
|
timestruct.tm_isdst = -1;
|
||||||
l->tstamp = mktime (×truct); /* store the time-stamp */
|
l->tstamp = mktime (×truct); /* store the time-stamp */
|
||||||
|
|
||||||
free (line);
|
xfree (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
@ -459,7 +459,7 @@ ftp_parse_nonunix_ls (const char *file)
|
|||||||
l->tstamp = fp.mtime;
|
l->tstamp = fp.mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
free (line);
|
xfree (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
@ -494,68 +494,6 @@ ftp_parse_ls (const char *file, const enum stype system_type)
|
|||||||
|
|
||||||
/* Stuff for creating FTP index. */
|
/* Stuff for creating FTP index. */
|
||||||
|
|
||||||
/* The function returns the pointer to the malloc-ed quoted version of
|
|
||||||
string s. It will recognize and quote numeric and special graphic
|
|
||||||
entities, as per RFC1866:
|
|
||||||
|
|
||||||
`&' -> `&'
|
|
||||||
`<' -> `<'
|
|
||||||
`>' -> `>'
|
|
||||||
`"' -> `"'
|
|
||||||
|
|
||||||
No other entities are recognized or replaced. */
|
|
||||||
static char *
|
|
||||||
html_quote_string (const char *s)
|
|
||||||
{
|
|
||||||
const char *b = s;
|
|
||||||
char *p, *res;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Pass through the string, and count the new size. */
|
|
||||||
for (i = 0; *s; s++, i++)
|
|
||||||
{
|
|
||||||
if (*s == '&')
|
|
||||||
i += 4; /* `amp;' */
|
|
||||||
else if (*s == '<' || *s == '>')
|
|
||||||
i += 3; /* `lt;' and `gt;' */
|
|
||||||
else if (*s == '\"')
|
|
||||||
i += 5; /* `quot;' */
|
|
||||||
}
|
|
||||||
res = (char *)xmalloc (i + 1);
|
|
||||||
s = b;
|
|
||||||
for (p = res; *s; s++)
|
|
||||||
{
|
|
||||||
switch (*s)
|
|
||||||
{
|
|
||||||
case '&':
|
|
||||||
*p++ = '&';
|
|
||||||
*p++ = 'a';
|
|
||||||
*p++ = 'm';
|
|
||||||
*p++ = 'p';
|
|
||||||
*p++ = ';';
|
|
||||||
break;
|
|
||||||
case '<': case '>':
|
|
||||||
*p++ = '&';
|
|
||||||
*p++ = (*s == '<' ? 'l' : 'g');
|
|
||||||
*p++ = 't';
|
|
||||||
*p++ = ';';
|
|
||||||
break;
|
|
||||||
case '\"':
|
|
||||||
*p++ = '&';
|
|
||||||
*p++ = 'q';
|
|
||||||
*p++ = 'u';
|
|
||||||
*p++ = 'o';
|
|
||||||
*p++ = 't';
|
|
||||||
*p++ = ';';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
*p++ = *s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*p = '\0';
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The function creates an HTML index containing references to given
|
/* The function creates an HTML index containing references to given
|
||||||
directories and files on the appropriate host. The references are
|
directories and files on the appropriate host. The references are
|
||||||
FTP. */
|
FTP. */
|
||||||
@ -586,7 +524,7 @@ ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
|
|||||||
upwd = (char *)xmalloc (strlen (tmpu)
|
upwd = (char *)xmalloc (strlen (tmpu)
|
||||||
+ (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
|
+ (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
|
||||||
sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");
|
sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");
|
||||||
free (tmpu);
|
xfree (tmpu);
|
||||||
FREE_MAYBE (tmpp);
|
FREE_MAYBE (tmpp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -652,11 +590,11 @@ ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
|
|||||||
else if (f->type == FT_SYMLINK)
|
else if (f->type == FT_SYMLINK)
|
||||||
fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)");
|
fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)");
|
||||||
putc ('\n', fp);
|
putc ('\n', fp);
|
||||||
free (htclfile);
|
xfree (htclfile);
|
||||||
f = f->next;
|
f = f->next;
|
||||||
}
|
}
|
||||||
fprintf (fp, "</pre>\n</body>\n</html>\n");
|
fprintf (fp, "</pre>\n</body>\n</html>\n");
|
||||||
free (upwd);
|
xfree (upwd);
|
||||||
if (!opt.dfp)
|
if (!opt.dfp)
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
else
|
else
|
||||||
|
28
src/ftp.c
28
src/ftp.c
@ -869,7 +869,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
rbuf_discard (&con->rbuf);
|
rbuf_discard (&con->rbuf);
|
||||||
if (err != FTPOK)
|
if (err != FTPOK)
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
/* The control connection is decidedly closed. Print the time
|
/* The control connection is decidedly closed. Print the time
|
||||||
only if it hasn't already been printed. */
|
only if it hasn't already been printed. */
|
||||||
if (res != -1)
|
if (res != -1)
|
||||||
@ -889,13 +889,13 @@ Error in server response, closing control connection.\n"));
|
|||||||
become apparent later. */
|
become apparent later. */
|
||||||
if (*respline != '2')
|
if (*respline != '2')
|
||||||
{
|
{
|
||||||
free (respline);
|
xfree (respline);
|
||||||
if (res != -1)
|
if (res != -1)
|
||||||
logprintf (LOG_NOTQUIET, "%s (%s) - ", tms, tmrate);
|
logprintf (LOG_NOTQUIET, "%s (%s) - ", tms, tmrate);
|
||||||
logputs (LOG_NOTQUIET, _("Data transfer aborted.\n"));
|
logputs (LOG_NOTQUIET, _("Data transfer aborted.\n"));
|
||||||
return FTPRETRINT;
|
return FTPRETRINT;
|
||||||
}
|
}
|
||||||
free (respline);
|
xfree (respline);
|
||||||
|
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
@ -927,7 +927,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
while ((line = read_whole_line (fp)))
|
while ((line = read_whole_line (fp)))
|
||||||
{
|
{
|
||||||
logprintf (LOG_ALWAYS, "%s\n", line);
|
logprintf (LOG_ALWAYS, "%s\n", line);
|
||||||
free (line);
|
xfree (line);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
@ -1041,7 +1041,7 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
ws_changetitle (hurl, 1);
|
ws_changetitle (hurl, 1);
|
||||||
#endif
|
#endif
|
||||||
free (hurl);
|
xfree (hurl);
|
||||||
}
|
}
|
||||||
/* Send getftp the proper length, if fileinfo was provided. */
|
/* Send getftp the proper length, if fileinfo was provided. */
|
||||||
if (f)
|
if (f)
|
||||||
@ -1109,7 +1109,7 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
|
|||||||
char *hurl = str_url (u->proxy ? u->proxy : u, 1);
|
char *hurl = str_url (u->proxy ? u->proxy : u, 1);
|
||||||
logprintf (LOG_NONVERBOSE, "%s URL: %s [%ld] -> \"%s\" [%d]\n",
|
logprintf (LOG_NONVERBOSE, "%s URL: %s [%ld] -> \"%s\" [%d]\n",
|
||||||
tms, hurl, len, locf, count);
|
tms, hurl, len, locf, count);
|
||||||
free (hurl);
|
xfree (hurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((con->cmd & DO_LIST))
|
if ((con->cmd & DO_LIST))
|
||||||
@ -1196,7 +1196,7 @@ ftp_get_listing (struct urlinfo *u, ccon *con)
|
|||||||
else
|
else
|
||||||
logprintf (LOG_VERBOSE, _("Removed `%s'.\n"), list_filename);
|
logprintf (LOG_VERBOSE, _("Removed `%s'.\n"), list_filename);
|
||||||
}
|
}
|
||||||
free (list_filename);
|
xfree (list_filename);
|
||||||
con->cmd &= ~DO_LIST;
|
con->cmd &= ~DO_LIST;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@ -1395,7 +1395,7 @@ Already have correct symlink %s -> %s\n\n"),
|
|||||||
else
|
else
|
||||||
DEBUGP (("Unrecognized permissions for %s.\n", u->local));
|
DEBUGP (("Unrecognized permissions for %s.\n", u->local));
|
||||||
|
|
||||||
free (u->local);
|
xfree (u->local);
|
||||||
u->local = olocal;
|
u->local = olocal;
|
||||||
u->file = ofile;
|
u->file = ofile;
|
||||||
/* Break on fatals. */
|
/* Break on fatals. */
|
||||||
@ -1608,7 +1608,7 @@ ftp_loop (struct urlinfo *u, int *dt)
|
|||||||
_("Wrote HTML-ized index to `%s'.\n"),
|
_("Wrote HTML-ized index to `%s'.\n"),
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
free (filename);
|
xfree (filename);
|
||||||
}
|
}
|
||||||
freefileinfo (f);
|
freefileinfo (f);
|
||||||
}
|
}
|
||||||
@ -1646,9 +1646,9 @@ delelement (struct fileinfo *f, struct fileinfo **start)
|
|||||||
struct fileinfo *prev = f->prev;
|
struct fileinfo *prev = f->prev;
|
||||||
struct fileinfo *next = f->next;
|
struct fileinfo *next = f->next;
|
||||||
|
|
||||||
free (f->name);
|
xfree (f->name);
|
||||||
FREE_MAYBE (f->linkto);
|
FREE_MAYBE (f->linkto);
|
||||||
free (f);
|
xfree (f);
|
||||||
|
|
||||||
if (next)
|
if (next)
|
||||||
next->prev = prev;
|
next->prev = prev;
|
||||||
@ -1666,10 +1666,10 @@ freefileinfo (struct fileinfo *f)
|
|||||||
while (f)
|
while (f)
|
||||||
{
|
{
|
||||||
struct fileinfo *next = f->next;
|
struct fileinfo *next = f->next;
|
||||||
free (f->name);
|
xfree (f->name);
|
||||||
if (f->linkto)
|
if (f->linkto)
|
||||||
free (f->linkto);
|
xfree (f->linkto);
|
||||||
free (f);
|
xfree (f);
|
||||||
f = next;
|
f = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,8 +192,8 @@ hash_table_new (int initial_size,
|
|||||||
void
|
void
|
||||||
hash_table_destroy (struct hash_table *ht)
|
hash_table_destroy (struct hash_table *ht)
|
||||||
{
|
{
|
||||||
free (ht->mappings);
|
xfree (ht->mappings);
|
||||||
free (ht);
|
xfree (ht);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The heart of almost all functions in this file -- find the mapping
|
/* The heart of almost all functions in this file -- find the mapping
|
||||||
@ -320,7 +320,7 @@ grow_hash_table (struct hash_table *ht)
|
|||||||
hash_table_put (ht, mp_key, mp->value);
|
hash_table_put (ht, mp_key, mp->value);
|
||||||
}
|
}
|
||||||
assert (ht->count == old_count);
|
assert (ht->count == old_count);
|
||||||
free (old_mappings);
|
xfree (old_mappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put VALUE in the hash table HT under the key KEY. This regrows the
|
/* Put VALUE in the hash table HT under the key KEY. This regrows the
|
||||||
@ -544,7 +544,7 @@ main (void)
|
|||||||
if (hash_table_get_pair (ht, line, &line_copy, NULL))
|
if (hash_table_get_pair (ht, line, &line_copy, NULL))
|
||||||
{
|
{
|
||||||
hash_table_remove (ht, line);
|
hash_table_remove (ht, line);
|
||||||
free (line_copy);
|
xfree (line_copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
20
src/host.c
20
src/host.c
@ -289,34 +289,34 @@ same_host (const char *u1, const char *u2)
|
|||||||
DEBUGP (("Comparing hosts %s and %s...\n", p1, p2));
|
DEBUGP (("Comparing hosts %s and %s...\n", p1, p2));
|
||||||
if (strcasecmp (p1, p2) == 0)
|
if (strcasecmp (p1, p2) == 0)
|
||||||
{
|
{
|
||||||
free (p1);
|
xfree (p1);
|
||||||
free (p2);
|
xfree (p2);
|
||||||
DEBUGP (("They are quite alike.\n"));
|
DEBUGP (("They are quite alike.\n"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (opt.simple_check)
|
else if (opt.simple_check)
|
||||||
{
|
{
|
||||||
free (p1);
|
xfree (p1);
|
||||||
free (p2);
|
xfree (p2);
|
||||||
DEBUGP (("Since checking is simple, I'd say they are not the same.\n"));
|
DEBUGP (("Since checking is simple, I'd say they are not the same.\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
real1 = realhost (p1);
|
real1 = realhost (p1);
|
||||||
real2 = realhost (p2);
|
real2 = realhost (p2);
|
||||||
free (p1);
|
xfree (p1);
|
||||||
free (p2);
|
xfree (p2);
|
||||||
if (strcasecmp (real1, real2) == 0)
|
if (strcasecmp (real1, real2) == 0)
|
||||||
{
|
{
|
||||||
DEBUGP (("They are alike, after realhost()->%s.\n", real1));
|
DEBUGP (("They are alike, after realhost()->%s.\n", real1));
|
||||||
free (real1);
|
xfree (real1);
|
||||||
free (real2);
|
xfree (real2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUGP (("They are not the same (%s, %s).\n", real1, real2));
|
DEBUGP (("They are not the same (%s, %s).\n", real1, real2));
|
||||||
free (real1);
|
xfree (real1);
|
||||||
free (real2);
|
xfree (real2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,15 +166,15 @@ struct pool {
|
|||||||
/* Forget old pool contents. The allocated memory is not freed. */
|
/* Forget old pool contents. The allocated memory is not freed. */
|
||||||
#define POOL_REWIND(pool) pool.index = 0
|
#define POOL_REWIND(pool) pool.index = 0
|
||||||
|
|
||||||
/* Free heap-allocated memory for contents of POOL. This calls free()
|
/* Free heap-allocated memory for contents of POOL. This calls
|
||||||
if the memory was allocated through malloc. It also restores
|
xfree() if the memory was allocated through malloc. It also
|
||||||
`contents' and `size' to their original, pre-malloc values. That
|
restores `contents' and `size' to their original, pre-malloc
|
||||||
way after POOL_FREE, the pool is fully usable, just as if it were
|
values. That way after POOL_FREE, the pool is fully usable, just
|
||||||
freshly initialized with POOL_INIT. */
|
as if it were freshly initialized with POOL_INIT. */
|
||||||
|
|
||||||
#define POOL_FREE(pool) do { \
|
#define POOL_FREE(pool) do { \
|
||||||
if (!(pool).alloca_p) \
|
if (!(pool).alloca_p) \
|
||||||
free ((pool).contents); \
|
xfree ((pool).contents); \
|
||||||
(pool).contents = (pool).orig_contents; \
|
(pool).contents = (pool).orig_contents; \
|
||||||
(pool).size = (pool).orig_size; \
|
(pool).size = (pool).orig_size; \
|
||||||
(pool).index = 0; \
|
(pool).index = 0; \
|
||||||
@ -812,7 +812,7 @@ map_html_tags (const char *text, int size,
|
|||||||
finish:
|
finish:
|
||||||
POOL_FREE (pool);
|
POOL_FREE (pool);
|
||||||
if (!attr_pair_alloca_p)
|
if (!attr_pair_alloca_p)
|
||||||
free (pairs);
|
xfree (pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef ADVANCE
|
#undef ADVANCE
|
||||||
|
@ -416,7 +416,7 @@ collect_tags_mapper (struct taginfo *tag, void *arg)
|
|||||||
if (!newbase)
|
if (!newbase)
|
||||||
break;
|
break;
|
||||||
if (closure->base)
|
if (closure->base)
|
||||||
free (closure->base);
|
xfree (closure->base);
|
||||||
if (closure->parent_base)
|
if (closure->parent_base)
|
||||||
closure->base = url_concat (closure->parent_base, newbase);
|
closure->base = url_concat (closure->parent_base, newbase);
|
||||||
else
|
else
|
||||||
|
@ -182,7 +182,7 @@ htmlfindurl (const char *buf, int bufsize, int *size, int init,
|
|||||||
s->tag = strdupdelim (p, buf);
|
s->tag = strdupdelim (p, buf);
|
||||||
if (*buf == '>')
|
if (*buf == '>')
|
||||||
{
|
{
|
||||||
free (s->tag);
|
xfree (s->tag);
|
||||||
s->tag = NULL;
|
s->tag = NULL;
|
||||||
++buf, --bufsize;
|
++buf, --bufsize;
|
||||||
continue;
|
continue;
|
||||||
@ -605,7 +605,7 @@ ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
|
|||||||
upwd = (char *)xmalloc (strlen (tmpu)
|
upwd = (char *)xmalloc (strlen (tmpu)
|
||||||
+ (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
|
+ (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
|
||||||
sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");
|
sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");
|
||||||
free (tmpu);
|
xfree (tmpu);
|
||||||
FREE_MAYBE (tmpp);
|
FREE_MAYBE (tmpp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -671,11 +671,11 @@ ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
|
|||||||
else if (f->type == FT_SYMLINK)
|
else if (f->type == FT_SYMLINK)
|
||||||
fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)");
|
fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)");
|
||||||
putc ('\n', fp);
|
putc ('\n', fp);
|
||||||
free (htclfile);
|
xfree (htclfile);
|
||||||
f = f->next;
|
f = f->next;
|
||||||
}
|
}
|
||||||
fprintf (fp, "</pre>\n</body>\n</html>\n");
|
fprintf (fp, "</pre>\n</body>\n</html>\n");
|
||||||
free (upwd);
|
xfree (upwd);
|
||||||
if (!opt.dfp)
|
if (!opt.dfp)
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
else
|
else
|
||||||
|
46
src/http.c
46
src/http.c
@ -763,7 +763,7 @@ Accept: %s\r\n\
|
|||||||
what you accept." Oh boy. */
|
what you accept." Oh boy. */
|
||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logputs (LOG_NOTQUIET, _("End of file while parsing headers.\n"));
|
logputs (LOG_NOTQUIET, _("End of file while parsing headers.\n"));
|
||||||
free (hdr);
|
xfree (hdr);
|
||||||
FREE_MAYBE (type);
|
FREE_MAYBE (type);
|
||||||
FREE_MAYBE (hs->newloc);
|
FREE_MAYBE (hs->newloc);
|
||||||
FREE_MAYBE (all_headers);
|
FREE_MAYBE (all_headers);
|
||||||
@ -775,7 +775,7 @@ Accept: %s\r\n\
|
|||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logprintf (LOG_NOTQUIET, _("Read error (%s) in headers.\n"),
|
logprintf (LOG_NOTQUIET, _("Read error (%s) in headers.\n"),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
free (hdr);
|
xfree (hdr);
|
||||||
FREE_MAYBE (type);
|
FREE_MAYBE (type);
|
||||||
FREE_MAYBE (hs->newloc);
|
FREE_MAYBE (hs->newloc);
|
||||||
FREE_MAYBE (all_headers);
|
FREE_MAYBE (all_headers);
|
||||||
@ -816,7 +816,7 @@ Accept: %s\r\n\
|
|||||||
hs->error = xstrdup (_("No data received"));
|
hs->error = xstrdup (_("No data received"));
|
||||||
else
|
else
|
||||||
hs->error = xstrdup (_("Malformed status line"));
|
hs->error = xstrdup (_("Malformed status line"));
|
||||||
free (hdr);
|
xfree (hdr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (!*error)
|
else if (!*error)
|
||||||
@ -837,7 +837,7 @@ Accept: %s\r\n\
|
|||||||
/* Exit on empty header. */
|
/* Exit on empty header. */
|
||||||
if (!*hdr)
|
if (!*hdr)
|
||||||
{
|
{
|
||||||
free (hdr);
|
xfree (hdr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,7 +905,7 @@ Accept: %s\r\n\
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
done_header:
|
done_header:
|
||||||
free (hdr);
|
xfree (hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
@ -935,12 +935,12 @@ Accept: %s\r\n\
|
|||||||
retrying it. */
|
retrying it. */
|
||||||
failed:
|
failed:
|
||||||
logputs (LOG_NOTQUIET, _("Authorization failed.\n"));
|
logputs (LOG_NOTQUIET, _("Authorization failed.\n"));
|
||||||
free (authenticate_h);
|
xfree (authenticate_h);
|
||||||
return AUTHFAILED;
|
return AUTHFAILED;
|
||||||
}
|
}
|
||||||
else if (!known_authentication_scheme_p (authenticate_h))
|
else if (!known_authentication_scheme_p (authenticate_h))
|
||||||
{
|
{
|
||||||
free (authenticate_h);
|
xfree (authenticate_h);
|
||||||
logputs (LOG_NOTQUIET, _("Unknown authentication scheme.\n"));
|
logputs (LOG_NOTQUIET, _("Unknown authentication scheme.\n"));
|
||||||
return AUTHFAILED;
|
return AUTHFAILED;
|
||||||
}
|
}
|
||||||
@ -960,7 +960,7 @@ Accept: %s\r\n\
|
|||||||
/* We do not need this anymore. */
|
/* We do not need this anymore. */
|
||||||
if (authenticate_h)
|
if (authenticate_h)
|
||||||
{
|
{
|
||||||
free (authenticate_h);
|
xfree (authenticate_h);
|
||||||
authenticate_h = NULL;
|
authenticate_h = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,8 +1192,8 @@ File `%s' already there, will not retrieve.\n"), u->local);
|
|||||||
if (((suf = suffix (u->local)) != NULL)
|
if (((suf = suffix (u->local)) != NULL)
|
||||||
&& (!strcmp (suf, "html") || !strcmp (suf, "htm")))
|
&& (!strcmp (suf, "html") || !strcmp (suf, "htm")))
|
||||||
*dt |= TEXTHTML;
|
*dt |= TEXTHTML;
|
||||||
free (suf);
|
xfree (suf);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
/* Another harmless lie: */
|
/* Another harmless lie: */
|
||||||
return RETROK;
|
return RETROK;
|
||||||
}
|
}
|
||||||
@ -1286,7 +1286,7 @@ File `%s' already there, will not retrieve.\n"), u->local);
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
ws_changetitle (hurl, 1);
|
ws_changetitle (hurl, 1);
|
||||||
#endif
|
#endif
|
||||||
free (hurl);
|
xfree (hurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default document type is empty. However, if spider mode is
|
/* Default document type is empty. However, if spider mode is
|
||||||
@ -1341,7 +1341,7 @@ File `%s' already there, will not retrieve.\n"), u->local);
|
|||||||
case HOSTERR: case CONREFUSED: case PROXERR: case AUTHFAILED:
|
case HOSTERR: case CONREFUSED: case PROXERR: case AUTHFAILED:
|
||||||
/* Fatal errors just return from the function. */
|
/* Fatal errors just return from the function. */
|
||||||
FREEHSTAT (hstat);
|
FREEHSTAT (hstat);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FWRITEERR: case FOPENERR:
|
case FWRITEERR: case FOPENERR:
|
||||||
@ -1350,7 +1350,7 @@ File `%s' already there, will not retrieve.\n"), u->local);
|
|||||||
logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"),
|
logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"),
|
||||||
u->local, strerror (errno));
|
u->local, strerror (errno));
|
||||||
FREEHSTAT (hstat);
|
FREEHSTAT (hstat);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case NEWLOCATION:
|
case NEWLOCATION:
|
||||||
@ -1360,11 +1360,11 @@ File `%s' already there, will not retrieve.\n"), u->local);
|
|||||||
logprintf (LOG_NOTQUIET,
|
logprintf (LOG_NOTQUIET,
|
||||||
_("ERROR: Redirection (%d) without location.\n"),
|
_("ERROR: Redirection (%d) without location.\n"),
|
||||||
hstat.statcode);
|
hstat.statcode);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return WRONGCODE;
|
return WRONGCODE;
|
||||||
}
|
}
|
||||||
FREEHSTAT (hstat);
|
FREEHSTAT (hstat);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return NEWLOCATION;
|
return NEWLOCATION;
|
||||||
break;
|
break;
|
||||||
case RETRFINISHED:
|
case RETRFINISHED:
|
||||||
@ -1381,13 +1381,13 @@ File `%s' already there, will not retrieve.\n"), u->local);
|
|||||||
/* #### Ugly ugly ugly! */
|
/* #### Ugly ugly ugly! */
|
||||||
char *hurl = str_url (u->proxy ? u->proxy : u, 1);
|
char *hurl = str_url (u->proxy ? u->proxy : u, 1);
|
||||||
logprintf (LOG_NONVERBOSE, "%s:\n", hurl);
|
logprintf (LOG_NONVERBOSE, "%s:\n", hurl);
|
||||||
free (hurl);
|
xfree (hurl);
|
||||||
}
|
}
|
||||||
logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"),
|
logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"),
|
||||||
tms, hstat.statcode, hstat.error);
|
tms, hstat.statcode, hstat.error);
|
||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
FREEHSTAT (hstat);
|
FREEHSTAT (hstat);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return WRONGCODE;
|
return WRONGCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1431,7 +1431,7 @@ Last-modified header invalid -- time-stamp ignored.\n"));
|
|||||||
Server file no newer than local file `%s' -- not retrieving.\n\n"),
|
Server file no newer than local file `%s' -- not retrieving.\n\n"),
|
||||||
local_filename);
|
local_filename);
|
||||||
FREEHSTAT (hstat);
|
FREEHSTAT (hstat);
|
||||||
free(filename_plus_orig_suffix);/*must precede every return!*/
|
xfree (filename_plus_orig_suffix); /*must precede every return!*/
|
||||||
return RETROK;
|
return RETROK;
|
||||||
}
|
}
|
||||||
else if (tml >= tmr)
|
else if (tml >= tmr)
|
||||||
@ -1459,7 +1459,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
|||||||
if (opt.spider)
|
if (opt.spider)
|
||||||
{
|
{
|
||||||
logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode, hstat.error);
|
logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode, hstat.error);
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return RETROK;
|
return RETROK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,7 +1489,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
|||||||
else
|
else
|
||||||
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
||||||
|
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree(filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return RETROK;
|
return RETROK;
|
||||||
}
|
}
|
||||||
else if (hstat.res == 0) /* No read error */
|
else if (hstat.res == 0) /* No read error */
|
||||||
@ -1515,7 +1515,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
|||||||
else
|
else
|
||||||
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
||||||
|
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return RETROK;
|
return RETROK;
|
||||||
}
|
}
|
||||||
else if (hstat.len < hstat.contlen) /* meaning we lost the
|
else if (hstat.len < hstat.contlen) /* meaning we lost the
|
||||||
@ -1544,7 +1544,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
|||||||
else
|
else
|
||||||
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
downloaded_file(FILE_DOWNLOADED_NORMALLY, locf);
|
||||||
|
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return RETROK;
|
return RETROK;
|
||||||
}
|
}
|
||||||
else /* the same, but not accepted */
|
else /* the same, but not accepted */
|
||||||
@ -1580,7 +1580,7 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size);
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while (!opt.ntry || (count < opt.ntry));
|
while (!opt.ntry || (count < opt.ntry));
|
||||||
free(filename_plus_orig_suffix); /* must precede every return! */
|
xfree (filename_plus_orig_suffix); /* must precede every return! */
|
||||||
return TRYLIMEXC;
|
return TRYLIMEXC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
src/init.c
20
src/init.c
@ -311,7 +311,7 @@ wgetrc_file_name (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (!file_exists_p (file))
|
if (!file_exists_p (file))
|
||||||
{
|
{
|
||||||
free (file);
|
xfree (file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
@ -341,15 +341,15 @@ run_wgetrc (const char *file)
|
|||||||
|
|
||||||
/* Parse the line. */
|
/* Parse the line. */
|
||||||
status = parse_line (line, &com, &val);
|
status = parse_line (line, &com, &val);
|
||||||
free (line);
|
xfree (line);
|
||||||
/* If everything is OK, set the value. */
|
/* If everything is OK, set the value. */
|
||||||
if (status == 1)
|
if (status == 1)
|
||||||
{
|
{
|
||||||
if (!setval (com, val))
|
if (!setval (com, val))
|
||||||
fprintf (stderr, _("%s: Error in %s at line %d.\n"), exec_name,
|
fprintf (stderr, _("%s: Error in %s at line %d.\n"), exec_name,
|
||||||
file, ln);
|
file, ln);
|
||||||
free (com);
|
xfree (com);
|
||||||
free (val);
|
xfree (val);
|
||||||
}
|
}
|
||||||
else if (status == 0)
|
else if (status == 0)
|
||||||
fprintf (stderr, _("%s: Error in %s at line %d.\n"), exec_name,
|
fprintf (stderr, _("%s: Error in %s at line %d.\n"), exec_name,
|
||||||
@ -390,7 +390,7 @@ initialize (void)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
run_wgetrc (file);
|
run_wgetrc (file);
|
||||||
free (file);
|
xfree (file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ parse_line (const char *line, char **com, char **val)
|
|||||||
/* If the command is invalid, exit now. */
|
/* If the command is invalid, exit now. */
|
||||||
if (comind (*com) == -1)
|
if (comind (*com) == -1)
|
||||||
{
|
{
|
||||||
free (*com);
|
xfree (*com);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ parse_line (const char *line, char **com, char **val)
|
|||||||
/* If '=' not found, bail out. */
|
/* If '=' not found, bail out. */
|
||||||
if (*p != '=')
|
if (*p != '=')
|
||||||
{
|
{
|
||||||
free (*com);
|
xfree (*com);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Skip spaces after '='. */
|
/* Skip spaces after '='. */
|
||||||
@ -993,7 +993,7 @@ cleanup (void)
|
|||||||
if (opt.dfp)
|
if (opt.dfp)
|
||||||
fclose (opt.dfp);
|
fclose (opt.dfp);
|
||||||
FREE_MAYBE (opt.lfilename);
|
FREE_MAYBE (opt.lfilename);
|
||||||
free (opt.dir_prefix);
|
xfree (opt.dir_prefix);
|
||||||
FREE_MAYBE (opt.input_filename);
|
FREE_MAYBE (opt.input_filename);
|
||||||
FREE_MAYBE (opt.output_document);
|
FREE_MAYBE (opt.output_document);
|
||||||
free_vec (opt.accepts);
|
free_vec (opt.accepts);
|
||||||
@ -1003,8 +1003,8 @@ cleanup (void)
|
|||||||
free_vec (opt.domains);
|
free_vec (opt.domains);
|
||||||
free_vec (opt.follow_tags);
|
free_vec (opt.follow_tags);
|
||||||
free_vec (opt.ignore_tags);
|
free_vec (opt.ignore_tags);
|
||||||
free (opt.ftp_acc);
|
xfree (opt.ftp_acc);
|
||||||
free (opt.ftp_pass);
|
xfree (opt.ftp_pass);
|
||||||
FREE_MAYBE (opt.ftp_proxy);
|
FREE_MAYBE (opt.ftp_proxy);
|
||||||
FREE_MAYBE (opt.http_proxy);
|
FREE_MAYBE (opt.http_proxy);
|
||||||
free_vec (opt.no_proxy);
|
free_vec (opt.no_proxy);
|
||||||
|
@ -112,7 +112,7 @@ free_log_line (int num)
|
|||||||
struct log_ln *ln = log_lines + num;
|
struct log_ln *ln = log_lines + num;
|
||||||
if (ln->malloced_line)
|
if (ln->malloced_line)
|
||||||
{
|
{
|
||||||
free (ln->malloced_line);
|
xfree (ln->malloced_line);
|
||||||
ln->malloced_line = NULL;
|
ln->malloced_line = NULL;
|
||||||
}
|
}
|
||||||
ln->content = NULL;
|
ln->content = NULL;
|
||||||
@ -346,7 +346,7 @@ logvprintf (enum log_options o, const char *fmt, va_list args)
|
|||||||
saved_append (write_ptr);
|
saved_append (write_ptr);
|
||||||
fputs (write_ptr, logfp);
|
fputs (write_ptr, logfp);
|
||||||
if (bigmsg)
|
if (bigmsg)
|
||||||
free (bigmsg);
|
xfree (bigmsg);
|
||||||
}
|
}
|
||||||
if (!opt.no_flush)
|
if (!opt.no_flush)
|
||||||
fflush (logfp);
|
fflush (logfp);
|
||||||
@ -524,7 +524,7 @@ redirect_output (const char *messij)
|
|||||||
logfp = stdin;
|
logfp = stdin;
|
||||||
}
|
}
|
||||||
fprintf (stderr, messij, logfile);
|
fprintf (stderr, messij, logfile);
|
||||||
free (logfile);
|
xfree (logfile);
|
||||||
/* Dump the previous screenful of output to LOGFILE. */
|
/* Dump the previous screenful of output to LOGFILE. */
|
||||||
log_dump ();
|
log_dump ();
|
||||||
save_log_p = 0;
|
save_log_p = 0;
|
||||||
|
@ -535,8 +535,8 @@ GNU General Public License for more details.\n"));
|
|||||||
optarg);
|
optarg);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
free (com);
|
xfree (com);
|
||||||
free (val);
|
xfree (val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
|
@ -208,7 +208,7 @@ ws_mypath (void)
|
|||||||
strcpy (wspathsave, buffer);
|
strcpy (wspathsave, buffer);
|
||||||
return wspathsave;
|
return wspathsave;
|
||||||
}
|
}
|
||||||
free (buffer);
|
xfree (buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/netrc.c
16
src/netrc.c
@ -79,7 +79,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
|
|||||||
char *path = (char *)alloca (strlen (home) + 1
|
char *path = (char *)alloca (strlen (home) + 1
|
||||||
+ strlen (NETRC_FILE_NAME) + 1);
|
+ strlen (NETRC_FILE_NAME) + 1);
|
||||||
sprintf (path, "%s/%s", home, NETRC_FILE_NAME);
|
sprintf (path, "%s/%s", home, NETRC_FILE_NAME);
|
||||||
free (home);
|
xfree (home);
|
||||||
err = stat (path, &buf);
|
err = stat (path, &buf);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
netrc_list = parse_netrc (path);
|
netrc_list = parse_netrc (path);
|
||||||
@ -173,7 +173,7 @@ read_whole_line (FILE *fp)
|
|||||||
}
|
}
|
||||||
if (c == EOF && !i)
|
if (c == EOF && !i)
|
||||||
{
|
{
|
||||||
free(line);
|
xfree(line);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,9 +200,9 @@ maybe_add_to_list (acc_t **newentry, acc_t **list)
|
|||||||
if (a && ! a->acc)
|
if (a && ! a->acc)
|
||||||
{
|
{
|
||||||
/* Free any allocated space. */
|
/* Free any allocated space. */
|
||||||
free (a->host);
|
xfree (a->host);
|
||||||
free (a->acc);
|
xfree (a->acc);
|
||||||
free (a->passwd);
|
xfree (a->passwd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -392,14 +392,14 @@ parse_netrc (const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (line);
|
xfree (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
/* Finalize the last machine entry we found. */
|
/* Finalize the last machine entry we found. */
|
||||||
maybe_add_to_list (¤t, &retval);
|
maybe_add_to_list (¤t, &retval);
|
||||||
free (current);
|
xfree (current);
|
||||||
|
|
||||||
/* Reverse the order of the list so that it appears in file order. */
|
/* Reverse the order of the list so that it appears in file order. */
|
||||||
current = retval;
|
current = retval;
|
||||||
@ -433,7 +433,7 @@ free_netrc(acc_t *l)
|
|||||||
FREE_MAYBE (l->acc);
|
FREE_MAYBE (l->acc);
|
||||||
FREE_MAYBE (l->passwd);
|
FREE_MAYBE (l->passwd);
|
||||||
FREE_MAYBE (l->host);
|
FREE_MAYBE (l->host);
|
||||||
free(l);
|
xfree (l);
|
||||||
l = t;
|
l = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
src/recur.c
22
src/recur.c
@ -382,10 +382,10 @@ recursive_retrieve (const char *file, const char *this_url)
|
|||||||
/* Just lowercase the hostname. */
|
/* Just lowercase the hostname. */
|
||||||
for (p = u->host; *p; p++)
|
for (p = u->host; *p; p++)
|
||||||
*p = TOLOWER (*p);
|
*p = TOLOWER (*p);
|
||||||
free (u->url);
|
xfree (u->url);
|
||||||
u->url = str_url (u, 0);
|
u->url = str_url (u, 0);
|
||||||
}
|
}
|
||||||
free (constr);
|
xfree (constr);
|
||||||
constr = xstrdup (u->url);
|
constr = xstrdup (u->url);
|
||||||
string_set_add (undesirable_urls, constr);
|
string_set_add (undesirable_urls, constr);
|
||||||
if (!inl && !((u->proto == URLFTP) && !this_url_ftp))
|
if (!inl && !((u->proto == URLFTP) && !this_url_ftp))
|
||||||
@ -422,7 +422,7 @@ recursive_retrieve (const char *file, const char *this_url)
|
|||||||
rfile = url_filename (rurl);
|
rfile = url_filename (rurl);
|
||||||
forbidden = parse_robots (rfile);
|
forbidden = parse_robots (rfile);
|
||||||
freeurl (rurl, 1);
|
freeurl (rurl, 1);
|
||||||
free (rfile);
|
xfree (rfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ recursive_retrieve (const char *file, const char *this_url)
|
|||||||
}
|
}
|
||||||
if (newloc)
|
if (newloc)
|
||||||
{
|
{
|
||||||
free (constr);
|
xfree (constr);
|
||||||
constr = newloc;
|
constr = newloc;
|
||||||
}
|
}
|
||||||
/* In case of convert_links: If there was no error, add it to
|
/* In case of convert_links: If there was no error, add it to
|
||||||
@ -657,9 +657,9 @@ robots_url (const char *url, const char *robots_filename)
|
|||||||
|
|
||||||
err = parseurl (url, u, 0);
|
err = parseurl (url, u, 0);
|
||||||
assert (err == URLOK && u->proto == URLHTTP);
|
assert (err == URLOK && u->proto == URLHTTP);
|
||||||
free (u->file);
|
xfree (u->file);
|
||||||
free (u->dir);
|
xfree (u->dir);
|
||||||
free (u->url);
|
xfree (u->url);
|
||||||
u->dir = xstrdup ("");
|
u->dir = xstrdup ("");
|
||||||
u->file = xstrdup (robots_filename);
|
u->file = xstrdup (robots_filename);
|
||||||
u->url = str_url (u, 0);
|
u->url = str_url (u, 0);
|
||||||
@ -764,7 +764,7 @@ parse_robots (const char *robots_filename)
|
|||||||
for (cmd = line; *cmd && ISSPACE (*cmd); cmd++);
|
for (cmd = line; *cmd && ISSPACE (*cmd); cmd++);
|
||||||
if (!*cmd)
|
if (!*cmd)
|
||||||
{
|
{
|
||||||
free (line);
|
xfree (line);
|
||||||
DEBUGP (("(chucked out)\n"));
|
DEBUGP (("(chucked out)\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -772,7 +772,7 @@ parse_robots (const char *robots_filename)
|
|||||||
for (str = cmd; *str && *str != ':'; str++);
|
for (str = cmd; *str && *str != ':'; str++);
|
||||||
if (!*str)
|
if (!*str)
|
||||||
{
|
{
|
||||||
free (line);
|
xfree (line);
|
||||||
DEBUGP (("(chucked out)\n"));
|
DEBUGP (("(chucked out)\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -831,7 +831,7 @@ parse_robots (const char *robots_filename)
|
|||||||
}
|
}
|
||||||
else if (!wget_matched)
|
else if (!wget_matched)
|
||||||
{
|
{
|
||||||
free (line);
|
xfree (line);
|
||||||
DEBUGP (("(chucking out since it is not applicable for Wget)\n"));
|
DEBUGP (("(chucking out since it is not applicable for Wget)\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ parse_robots (const char *robots_filename)
|
|||||||
/* unknown command */
|
/* unknown command */
|
||||||
DEBUGP (("(chucked out)\n"));
|
DEBUGP (("(chucked out)\n"));
|
||||||
}
|
}
|
||||||
free (line);
|
xfree (line);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
return entries;
|
return entries;
|
||||||
|
22
src/retr.c
22
src/retr.c
@ -355,7 +355,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
freeurl (u, 1);
|
freeurl (u, 1);
|
||||||
if (redirections)
|
if (redirections)
|
||||||
string_set_free (redirections);
|
string_set_free (redirections);
|
||||||
free (url);
|
xfree (url);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
freeurl (u, 1);
|
freeurl (u, 1);
|
||||||
if (redirections)
|
if (redirections)
|
||||||
string_set_free (redirections);
|
string_set_free (redirections);
|
||||||
free (url);
|
xfree (url);
|
||||||
return PROXERR;
|
return PROXERR;
|
||||||
}
|
}
|
||||||
/* Parse the proxy URL. */
|
/* Parse the proxy URL. */
|
||||||
@ -406,7 +406,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
freeurl (u, 1);
|
freeurl (u, 1);
|
||||||
if (redirections)
|
if (redirections)
|
||||||
string_set_free (redirections);
|
string_set_free (redirections);
|
||||||
free (url);
|
xfree (url);
|
||||||
return PROXERR;
|
return PROXERR;
|
||||||
}
|
}
|
||||||
u->proto = URLHTTP;
|
u->proto = URLHTTP;
|
||||||
@ -456,7 +456,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
there break the rules and use relative URLs, and popular
|
there break the rules and use relative URLs, and popular
|
||||||
browsers are lenient about this, so wget should be too. */
|
browsers are lenient about this, so wget should be too. */
|
||||||
construced_newloc = url_concat (url, mynewloc);
|
construced_newloc = url_concat (url, mynewloc);
|
||||||
free (mynewloc);
|
xfree (mynewloc);
|
||||||
mynewloc = construced_newloc;
|
mynewloc = construced_newloc;
|
||||||
|
|
||||||
/* Now, see if this new location makes sense. */
|
/* Now, see if this new location makes sense. */
|
||||||
@ -469,15 +469,15 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
freeurl (u, 1);
|
freeurl (u, 1);
|
||||||
if (redirections)
|
if (redirections)
|
||||||
string_set_free (redirections);
|
string_set_free (redirections);
|
||||||
free (url);
|
xfree (url);
|
||||||
free (mynewloc);
|
xfree (mynewloc);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now mynewloc will become newloc_struct->url, because if the
|
/* Now mynewloc will become newloc_struct->url, because if the
|
||||||
Location contained relative paths like .././something, we
|
Location contained relative paths like .././something, we
|
||||||
don't want that propagating as url. */
|
don't want that propagating as url. */
|
||||||
free (mynewloc);
|
xfree (mynewloc);
|
||||||
mynewloc = xstrdup (newloc_struct->url);
|
mynewloc = xstrdup (newloc_struct->url);
|
||||||
|
|
||||||
if (!redirections)
|
if (!redirections)
|
||||||
@ -498,13 +498,13 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
freeurl (u, 1);
|
freeurl (u, 1);
|
||||||
if (redirections)
|
if (redirections)
|
||||||
string_set_free (redirections);
|
string_set_free (redirections);
|
||||||
free (url);
|
xfree (url);
|
||||||
free (mynewloc);
|
xfree (mynewloc);
|
||||||
return WRONGCODE;
|
return WRONGCODE;
|
||||||
}
|
}
|
||||||
string_set_add (redirections, newloc_struct->url);
|
string_set_add (redirections, newloc_struct->url);
|
||||||
|
|
||||||
free (url);
|
xfree (url);
|
||||||
url = mynewloc;
|
url = mynewloc;
|
||||||
freeurl (u, 1);
|
freeurl (u, 1);
|
||||||
u = newloc_struct;
|
u = newloc_struct;
|
||||||
@ -525,7 +525,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
|
|||||||
if (newloc)
|
if (newloc)
|
||||||
*newloc = url;
|
*newloc = url;
|
||||||
else
|
else
|
||||||
free (url);
|
xfree (url);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
58
src/url.c
58
src/url.c
@ -61,7 +61,7 @@ static char unsafe_char_table[256];
|
|||||||
if (contains_unsafe (s)) \
|
if (contains_unsafe (s)) \
|
||||||
{ \
|
{ \
|
||||||
char *uc_tmp = encode_string (s); \
|
char *uc_tmp = encode_string (s); \
|
||||||
free (s); \
|
xfree (s); \
|
||||||
(s) = uc_tmp; \
|
(s) = uc_tmp; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -377,7 +377,7 @@ freeurl (struct urlinfo *u, int complete)
|
|||||||
if (u->proxy)
|
if (u->proxy)
|
||||||
freeurl (u->proxy, 1);
|
freeurl (u->proxy, 1);
|
||||||
if (complete)
|
if (complete)
|
||||||
free (u);
|
xfree (u);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,7 +697,7 @@ str_url (const struct urlinfo *u, int hide)
|
|||||||
tmp[1] = '2';
|
tmp[1] = '2';
|
||||||
tmp[2] = 'F';
|
tmp[2] = 'F';
|
||||||
strcpy (tmp + 3, dir + 1);
|
strcpy (tmp + 3, dir + 1);
|
||||||
free (dir);
|
xfree (dir);
|
||||||
dir = tmp;
|
dir = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,9 +741,9 @@ str_url (const struct urlinfo *u, int hide)
|
|||||||
if (*dir)
|
if (*dir)
|
||||||
res[l++] = '/';
|
res[l++] = '/';
|
||||||
strcpy (res + l, file);
|
strcpy (res + l, file);
|
||||||
free (host);
|
xfree (host);
|
||||||
free (dir);
|
xfree (dir);
|
||||||
free (file);
|
xfree (file);
|
||||||
FREE_MAYBE (user);
|
FREE_MAYBE (user);
|
||||||
FREE_MAYBE (passwd);
|
FREE_MAYBE (passwd);
|
||||||
return res;
|
return res;
|
||||||
@ -839,9 +839,9 @@ free_urlpos (urlpos *l)
|
|||||||
while (l)
|
while (l)
|
||||||
{
|
{
|
||||||
urlpos *next = l->next;
|
urlpos *next = l->next;
|
||||||
free (l->url);
|
xfree (l->url);
|
||||||
FREE_MAYBE (l->local_name);
|
FREE_MAYBE (l->local_name);
|
||||||
free (l);
|
xfree (l);
|
||||||
l = next;
|
l = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -894,7 +894,7 @@ mkalldirs (const char *path)
|
|||||||
{
|
{
|
||||||
if (S_ISDIR (st.st_mode))
|
if (S_ISDIR (st.st_mode))
|
||||||
{
|
{
|
||||||
free (t);
|
xfree (t);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -918,7 +918,7 @@ mkalldirs (const char *path)
|
|||||||
res = make_directory (t);
|
res = make_directory (t);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
logprintf (LOG_NOTQUIET, "%s: %s", t, strerror (errno));
|
logprintf (LOG_NOTQUIET, "%s: %s", t, strerror (errno));
|
||||||
free (t);
|
xfree (t);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,7 +962,7 @@ mkstruct (const struct urlinfo *u)
|
|||||||
if (opt.add_hostdir && !opt.simple_check)
|
if (opt.add_hostdir && !opt.simple_check)
|
||||||
{
|
{
|
||||||
char *nhost = realhost (host);
|
char *nhost = realhost (host);
|
||||||
free (host);
|
xfree (host);
|
||||||
host = nhost;
|
host = nhost;
|
||||||
}
|
}
|
||||||
/* Add dir_prefix and hostname (if required) to the beginning of
|
/* Add dir_prefix and hostname (if required) to the beginning of
|
||||||
@ -985,7 +985,7 @@ mkstruct (const struct urlinfo *u)
|
|||||||
else
|
else
|
||||||
dirpref = "";
|
dirpref = "";
|
||||||
}
|
}
|
||||||
free (host);
|
xfree (host);
|
||||||
|
|
||||||
/* If there is a prefix, prepend it. */
|
/* If there is a prefix, prepend it. */
|
||||||
if (*dirpref)
|
if (*dirpref)
|
||||||
@ -1008,7 +1008,7 @@ mkstruct (const struct urlinfo *u)
|
|||||||
/* Finally, construct the full name. */
|
/* Finally, construct the full name. */
|
||||||
res = (char *)xmalloc (strlen (dir) + 1 + strlen (file) + 1);
|
res = (char *)xmalloc (strlen (dir) + 1 + strlen (file) + 1);
|
||||||
sprintf (res, "%s%s%s", dir, *dir ? "/" : "", file);
|
sprintf (res, "%s%s%s", dir, *dir ? "/" : "", file);
|
||||||
free (dir);
|
xfree (dir);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1042,7 +1042,7 @@ url_filename (const struct urlinfo *u)
|
|||||||
char *nfile = (char *)xmalloc (strlen (opt.dir_prefix)
|
char *nfile = (char *)xmalloc (strlen (opt.dir_prefix)
|
||||||
+ 1 + strlen (file) + 1);
|
+ 1 + strlen (file) + 1);
|
||||||
sprintf (nfile, "%s/%s", opt.dir_prefix, file);
|
sprintf (nfile, "%s/%s", opt.dir_prefix, file);
|
||||||
free (file);
|
xfree (file);
|
||||||
file = nfile;
|
file = nfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1071,7 +1071,7 @@ url_filename (const struct urlinfo *u)
|
|||||||
|
|
||||||
/* Find a unique name. */
|
/* Find a unique name. */
|
||||||
name = unique_name (file);
|
name = unique_name (file);
|
||||||
free (file);
|
xfree (file);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1245,11 +1245,11 @@ opt_url (struct urlinfo *u)
|
|||||||
{
|
{
|
||||||
/* Find the "true" host. */
|
/* Find the "true" host. */
|
||||||
char *host = realhost (u->host);
|
char *host = realhost (u->host);
|
||||||
free (u->host);
|
xfree (u->host);
|
||||||
u->host = host;
|
u->host = host;
|
||||||
assert (u->dir != NULL); /* the URL must have been parsed */
|
assert (u->dir != NULL); /* the URL must have been parsed */
|
||||||
/* Refresh the printed representation. */
|
/* Refresh the printed representation. */
|
||||||
free (u->url);
|
xfree (u->url);
|
||||||
u->url = str_url (u, 0);
|
u->url = str_url (u, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1389,24 +1389,28 @@ convert_links (const char *file, urlpos *l)
|
|||||||
{
|
{
|
||||||
/* Convert absolute URL to relative. */
|
/* Convert absolute URL to relative. */
|
||||||
char *newname = construct_relative (file, l->local_name);
|
char *newname = construct_relative (file, l->local_name);
|
||||||
|
char *quoted_newname = html_quote_string (newname);
|
||||||
putc (*p, fp); /* quoting char */
|
putc (*p, fp); /* quoting char */
|
||||||
fputs (newname, fp);
|
fputs (quoted_newname, fp);
|
||||||
p += l->size - 1;
|
p += l->size - 1;
|
||||||
putc (*p, fp); /* close quote */
|
putc (*p, fp); /* close quote */
|
||||||
++p;
|
++p;
|
||||||
|
xfree (newname);
|
||||||
|
xfree (quoted_newname);
|
||||||
DEBUGP (("TO_RELATIVE: %s to %s at position %d in %s.\n",
|
DEBUGP (("TO_RELATIVE: %s to %s at position %d in %s.\n",
|
||||||
l->url, newname, l->pos, file));
|
l->url, newname, l->pos, file));
|
||||||
free (newname);
|
|
||||||
}
|
}
|
||||||
else if (l->convert == CO_CONVERT_TO_COMPLETE)
|
else if (l->convert == CO_CONVERT_TO_COMPLETE)
|
||||||
{
|
{
|
||||||
/* Convert the link to absolute URL. */
|
/* Convert the link to absolute URL. */
|
||||||
char *newlink = l->url;
|
char *newlink = l->url;
|
||||||
|
char *quoted_newlink = html_quote_string (newlink);
|
||||||
putc (*p, fp); /* quoting char */
|
putc (*p, fp); /* quoting char */
|
||||||
fputs (newlink, fp);
|
fputs (quoted_newlink, fp);
|
||||||
p += l->size - 1;
|
p += l->size - 1;
|
||||||
putc (*p, fp); /* close quote */
|
putc (*p, fp); /* close quote */
|
||||||
++p;
|
++p;
|
||||||
|
xfree (quoted_newlink);
|
||||||
DEBUGP (("TO_COMPLETE: <something> to %s at position %d in %s.\n",
|
DEBUGP (("TO_COMPLETE: <something> to %s at position %d in %s.\n",
|
||||||
newlink, l->pos, file));
|
newlink, l->pos, file));
|
||||||
}
|
}
|
||||||
@ -1553,7 +1557,19 @@ write_backup_file (const char *file, downloaded_file_t downloaded_file_return)
|
|||||||
rather than making a copy of the string... Another note is that I
|
rather than making a copy of the string... Another note is that I
|
||||||
thought I could just add a field to the urlpos structure saying
|
thought I could just add a field to the urlpos structure saying
|
||||||
that we'd written a .orig file for this URL, but that didn't work,
|
that we'd written a .orig file for this URL, but that didn't work,
|
||||||
so I had to make this separate list. */
|
so I had to make this separate list.
|
||||||
|
|
||||||
|
This [adding a field to the urlpos structure] didn't work
|
||||||
|
because convert_file() is called twice: once after all its
|
||||||
|
sublinks have been retrieved in recursive_retrieve(), and
|
||||||
|
once at the end of the day in convert_all_links(). The
|
||||||
|
original linked list collected in recursive_retrieve() is
|
||||||
|
lost after the first invocation of convert_links(), and
|
||||||
|
convert_all_links() makes a new one (it calls get_urls_html()
|
||||||
|
for each file it covers.) That's why your approach didn't
|
||||||
|
work. The way to make it work is perhaps to make this flag a
|
||||||
|
field in the `urls_html' list. */
|
||||||
|
|
||||||
converted_file_ptr = xmalloc(sizeof(*converted_file_ptr));
|
converted_file_ptr = xmalloc(sizeof(*converted_file_ptr));
|
||||||
converted_file_ptr->string = xstrdup(file); /* die on out-of-mem. */
|
converted_file_ptr->string = xstrdup(file); /* die on out-of-mem. */
|
||||||
converted_file_ptr->next = converted_files;
|
converted_file_ptr->next = converted_files;
|
||||||
|
117
src/utils.c
117
src/utils.c
@ -80,7 +80,9 @@ memfatal (const char *s)
|
|||||||
|
|
||||||
/* xmalloc, xrealloc and xstrdup exit the program if there is not
|
/* xmalloc, xrealloc and xstrdup exit the program if there is not
|
||||||
enough memory. xstrdup also implements strdup on systems that do
|
enough memory. xstrdup also implements strdup on systems that do
|
||||||
not have it. */
|
not have it. xfree is provided to make leak-tracking easier.
|
||||||
|
Currently it's a no-op. */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xmalloc (size_t size)
|
xmalloc (size_t size)
|
||||||
{
|
{
|
||||||
@ -92,6 +94,12 @@ xmalloc (size_t size)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xfree (void *ptr)
|
||||||
|
{
|
||||||
|
free (ptr);
|
||||||
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xrealloc (void *obj, size_t size)
|
xrealloc (void *obj, size_t size)
|
||||||
{
|
{
|
||||||
@ -488,7 +496,7 @@ unique_name_1 (const char *fileprefix, int count)
|
|||||||
return filename;
|
return filename;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free (filename);
|
xfree (filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -730,7 +738,7 @@ read_whole_line (FILE *fp)
|
|||||||
}
|
}
|
||||||
if (length == 0 || ferror (fp))
|
if (length == 0 || ferror (fp))
|
||||||
{
|
{
|
||||||
free (line);
|
xfree (line);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (length + 1 < bufsize)
|
if (length + 1 < bufsize)
|
||||||
@ -858,13 +866,13 @@ read_file (const char *file)
|
|||||||
lose:
|
lose:
|
||||||
if (!inhibit_close)
|
if (!inhibit_close)
|
||||||
close (fd);
|
close (fd);
|
||||||
free (fm->content);
|
xfree (fm->content);
|
||||||
free (fm);
|
xfree (fm);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the resources held by FM. Specifically, this calls
|
/* Release the resources held by FM. Specifically, this calls
|
||||||
munmap() or free() on fm->content, depending whether mmap or
|
munmap() or xfree() on fm->content, depending whether mmap or
|
||||||
malloc/read were used to read in the file. It also frees the
|
malloc/read were used to read in the file. It also frees the
|
||||||
memory needed to hold the FM structure itself. */
|
memory needed to hold the FM structure itself. */
|
||||||
|
|
||||||
@ -879,9 +887,9 @@ read_file_free (struct file_memory *fm)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
free (fm->content);
|
xfree (fm->content);
|
||||||
}
|
}
|
||||||
free (fm);
|
xfree (fm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the pointers in a NULL-terminated vector of pointers, then
|
/* Free the pointers in a NULL-terminated vector of pointers, then
|
||||||
@ -893,8 +901,8 @@ free_vec (char **vec)
|
|||||||
{
|
{
|
||||||
char **p = vec;
|
char **p = vec;
|
||||||
while (*p)
|
while (*p)
|
||||||
free (*p++);
|
xfree (*p++);
|
||||||
free (vec);
|
xfree (vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,7 +921,7 @@ merge_vecs (char **v1, char **v2)
|
|||||||
if (!*v2)
|
if (!*v2)
|
||||||
{
|
{
|
||||||
/* To avoid j == 0 */
|
/* To avoid j == 0 */
|
||||||
free (v2);
|
xfree (v2);
|
||||||
return v1;
|
return v1;
|
||||||
}
|
}
|
||||||
/* Count v1. */
|
/* Count v1. */
|
||||||
@ -923,7 +931,7 @@ merge_vecs (char **v1, char **v2)
|
|||||||
/* Reallocate v1. */
|
/* Reallocate v1. */
|
||||||
v1 = (char **)xrealloc (v1, (i + j + 1) * sizeof (char **));
|
v1 = (char **)xrealloc (v1, (i + j + 1) * sizeof (char **));
|
||||||
memcpy (v1 + i, v2, (j + 1) * sizeof (char *));
|
memcpy (v1 + i, v2, (j + 1) * sizeof (char *));
|
||||||
free (v2);
|
xfree (v2);
|
||||||
return v1;
|
return v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,8 +1014,8 @@ slist_free (slist *l)
|
|||||||
while (l)
|
while (l)
|
||||||
{
|
{
|
||||||
slist *n = l->next;
|
slist *n = l->next;
|
||||||
free (l->string);
|
xfree (l->string);
|
||||||
free (l);
|
xfree (l);
|
||||||
l = n;
|
l = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1044,7 +1052,7 @@ string_set_exists (struct hash_table *ht, const char *s)
|
|||||||
static int
|
static int
|
||||||
string_set_free_mapper (void *key, void *value_ignored, void *arg_ignored)
|
string_set_free_mapper (void *key, void *value_ignored, void *arg_ignored)
|
||||||
{
|
{
|
||||||
free (key);
|
xfree (key);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1058,8 +1066,8 @@ string_set_free (struct hash_table *ht)
|
|||||||
static int
|
static int
|
||||||
free_keys_and_values_mapper (void *key, void *value, void *arg_ignored)
|
free_keys_and_values_mapper (void *key, void *value, void *arg_ignored)
|
||||||
{
|
{
|
||||||
free (key);
|
xfree (key);
|
||||||
free (value);
|
xfree (value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,3 +1199,78 @@ long_to_string (char *buffer, long number)
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
#endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
|
#endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This should probably be at a better place, but it doesn't really
|
||||||
|
fit into html-parse.c. */
|
||||||
|
|
||||||
|
/* The function returns the pointer to the malloc-ed quoted version of
|
||||||
|
string s. It will recognize and quote numeric and special graphic
|
||||||
|
entities, as per RFC1866:
|
||||||
|
|
||||||
|
`&' -> `&'
|
||||||
|
`<' -> `<'
|
||||||
|
`>' -> `>'
|
||||||
|
`"' -> `"'
|
||||||
|
SP -> ` '
|
||||||
|
|
||||||
|
No other entities are recognized or replaced. */
|
||||||
|
char *
|
||||||
|
html_quote_string (const char *s)
|
||||||
|
{
|
||||||
|
const char *b = s;
|
||||||
|
char *p, *res;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Pass through the string, and count the new size. */
|
||||||
|
for (i = 0; *s; s++, i++)
|
||||||
|
{
|
||||||
|
if (*s == '&')
|
||||||
|
i += 4; /* `amp;' */
|
||||||
|
else if (*s == '<' || *s == '>')
|
||||||
|
i += 3; /* `lt;' and `gt;' */
|
||||||
|
else if (*s == '\"')
|
||||||
|
i += 5; /* `quot;' */
|
||||||
|
else if (*s == ' ')
|
||||||
|
i += 4; /* #32; */
|
||||||
|
}
|
||||||
|
res = (char *)xmalloc (i + 1);
|
||||||
|
s = b;
|
||||||
|
for (p = res; *s; s++)
|
||||||
|
{
|
||||||
|
switch (*s)
|
||||||
|
{
|
||||||
|
case '&':
|
||||||
|
*p++ = '&';
|
||||||
|
*p++ = 'a';
|
||||||
|
*p++ = 'm';
|
||||||
|
*p++ = 'p';
|
||||||
|
*p++ = ';';
|
||||||
|
break;
|
||||||
|
case '<': case '>':
|
||||||
|
*p++ = '&';
|
||||||
|
*p++ = (*s == '<' ? 'l' : 'g');
|
||||||
|
*p++ = 't';
|
||||||
|
*p++ = ';';
|
||||||
|
break;
|
||||||
|
case '\"':
|
||||||
|
*p++ = '&';
|
||||||
|
*p++ = 'q';
|
||||||
|
*p++ = 'u';
|
||||||
|
*p++ = 'o';
|
||||||
|
*p++ = 't';
|
||||||
|
*p++ = ';';
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
*p++ = '&';
|
||||||
|
*p++ = '#';
|
||||||
|
*p++ = '3';
|
||||||
|
*p++ = '2';
|
||||||
|
*p++ = ';';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*p++ = *s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*p = '\0';
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
@ -82,4 +82,6 @@ char *legible_very_long PARAMS ((VERY_LONG_TYPE));
|
|||||||
int numdigit PARAMS ((long));
|
int numdigit PARAMS ((long));
|
||||||
void long_to_string PARAMS ((char *, long));
|
void long_to_string PARAMS ((char *, long));
|
||||||
|
|
||||||
|
char *html_quote_string PARAMS ((const char *));
|
||||||
|
|
||||||
#endif /* UTILS_H */
|
#endif /* UTILS_H */
|
||||||
|
@ -99,6 +99,7 @@ void logputs PARAMS ((enum log_options, const char *));
|
|||||||
|
|
||||||
/* Defined in `utils.c', but used literally everywhere. */
|
/* Defined in `utils.c', but used literally everywhere. */
|
||||||
void *xmalloc PARAMS ((size_t));
|
void *xmalloc PARAMS ((size_t));
|
||||||
|
void xfree PARAMS ((void *));
|
||||||
void *xrealloc PARAMS ((void *, size_t));
|
void *xrealloc PARAMS ((void *, size_t));
|
||||||
char *xstrdup PARAMS ((const char *));
|
char *xstrdup PARAMS ((const char *));
|
||||||
|
|
||||||
@ -197,7 +198,7 @@ char *xstrdup PARAMS ((const char *));
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Free FOO if it is non-NULL. */
|
/* Free FOO if it is non-NULL. */
|
||||||
#define FREE_MAYBE(foo) do { if (foo) free (foo); } while (0)
|
#define FREE_MAYBE(foo) do { if (foo) xfree (foo); } while (0)
|
||||||
|
|
||||||
/* #### Hack: OPTIONS_DEFINED_HERE is defined in main.c. */
|
/* #### Hack: OPTIONS_DEFINED_HERE is defined in main.c. */
|
||||||
/* [Is this weird hack really necessary on any compilers? No ANSI C compiler
|
/* [Is this weird hack really necessary on any compilers? No ANSI C compiler
|
||||||
|
Loading…
Reference in New Issue
Block a user