X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fnetrc.c;h=ba9fc3099d7d9d93564bcc0bab4937e954f4ef50;hb=4d7c5e087b2bc82c9f503dff003916d1047903ce;hp=9535472c469dabdafe373ad946e27c615fa11b20;hpb=1375a891411e22a82030d3597b4fa66a0097fd9d;p=wget diff --git a/src/netrc.c b/src/netrc.c index 9535472c..ba9fc309 100644 --- a/src/netrc.c +++ b/src/netrc.c @@ -5,7 +5,7 @@ This file is part of GNU Wget. GNU Wget is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or +the Free Software Foundation; either version 3 of the License, or (at your option) any later version. GNU Wget is distributed in the hope that it will be useful, @@ -14,8 +14,17 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +along with Wget. If not, see . + +In addition, as a special exception, the Free Software Foundation +gives permission to link the code of its release of Wget with the +OpenSSL project's "OpenSSL" library (or with modified versions of it +that use the same license as the "OpenSSL" library), and distribute +the linked executables. You must obey the GNU General Public License +in all respects for all of the code used other than "OpenSSL". If you +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 used to be kept in synch with the code in Fetchmail, but the latter has diverged since. */ @@ -26,12 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif -#include +#include #include #include "wget.h" @@ -39,15 +43,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "netrc.h" #include "init.h" -#ifndef errno -extern int errno; -#endif - #define NETRC_FILE_NAME ".netrc" acc_t *netrc_list; -static acc_t *parse_netrc PARAMS ((const char *)); +static acc_t *parse_netrc (const char *); /* Return the correct user and password, given the host, user (as given in the URL), and password (as given in the URL). May return @@ -74,7 +74,7 @@ search_netrc (const char *host, const char **acc, const char **passwd, if (home) { int err; - struct stat buf; + struct_stat buf; char *path = (char *)alloca (strlen (home) + 1 + strlen (NETRC_FILE_NAME) + 1); sprintf (path, "%s/%s", home, NETRC_FILE_NAME); @@ -163,7 +163,7 @@ read_whole_line (FILE *fp) { int length = 0; int bufsize = 81; - char *line = (char *)xmalloc (bufsize); + char *line = xmalloc (bufsize); while (fgets (line + length, bufsize - length, fp)) { @@ -205,9 +205,9 @@ maybe_add_to_list (acc_t **newentry, acc_t **list) if (a && ! a->acc) { /* Free any allocated space. */ - xfree (a->host); - xfree (a->acc); - xfree (a->passwd); + xfree_null (a->host); + xfree_null (a->acc); + xfree_null (a->passwd); } else { @@ -219,7 +219,7 @@ maybe_add_to_list (acc_t **newentry, acc_t **list) } /* Allocate a new acc_t structure. */ - a = (acc_t *)xmalloc (sizeof (acc_t)); + a = xmalloc (sizeof (acc_t)); } /* Zero the structure, so that it is ready to use. */ @@ -248,7 +248,8 @@ static acc_t * parse_netrc (const char *path) { FILE *fp; - char *line, *p, *tok, *premature_token; + char *line, *p, *tok; + const char *premature_token; acc_t *current, *retval; int ln, quote; @@ -273,7 +274,7 @@ parse_netrc (const char *path) premature_token = NULL; /* While there are lines in the file... */ - while ((line = read_whole_line (fp))) + while ((line = read_whole_line (fp)) != NULL) { ln ++; @@ -318,9 +319,13 @@ parse_netrc (const char *path) p ++; } - /* if field was quoted, squash the trailing quotation mark */ + /* If field was quoted, squash the trailing quotation mark + and reset quote flag. */ if (quote) - shift_left(p); + { + shift_left (p); + quote = 0; + } /* Null-terminate the token, if it isn't already. */ if (*p) @@ -441,9 +446,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; } @@ -456,7 +461,7 @@ free_netrc(acc_t *l) int main (int argc, char **argv) { - struct stat sb; + struct_stat sb; char *program_name, *file, *target; acc_t *head, *a;