/* Reading/parsing the initialization file.
- Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2003
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2003, 2004
Free Software Foundation, Inc.
This file is part of GNU Wget.
cleanup() function below. */
static struct {
- char *name;
+ const char *name;
void *closure;
int (*action) PARAMS ((const char *, const char *, void *));
} commands[] = {
{ "followftp", &opt.follow_ftp, cmd_boolean },
{ "followtags", &opt.follow_tags, cmd_vector },
{ "forcehtml", &opt.force_html, cmd_boolean },
+ { "ftppasswd", &opt.ftp_pass, cmd_string },
{ "ftpproxy", &opt.ftp_proxy, cmd_string },
{ "glob", &opt.ftp_glob, cmd_boolean },
{ "header", &opt.user_headers, cmd_spec_header },
{ "outputdocument", &opt.output_document, cmd_file },
{ "pagerequisites", &opt.page_requisites, cmd_boolean },
{ "passiveftp", &opt.ftp_pasv, cmd_lockable_boolean },
- { "passwd", &opt.ftp_pass, cmd_string },
{ "postdata", &opt.post_data, cmd_string },
{ "postfile", &opt.post_file_name, cmd_file },
{ "preservepermissions", &opt.preserve_perm, cmd_boolean },
{ "progress", &opt.progress_type, cmd_spec_progress },
+ { "protocoldirectories", &opt.protocol_directories, cmd_boolean },
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
{ "proxyuser", &opt.proxy_user, cmd_string },
{ "quiet", &opt.quiet, cmd_boolean },
opt.dots_in_line = 50;
opt.dns_cache = 1;
+ opt.ftp_pasv = 1;
/* The default for file name restriction defaults to the OS type. */
#if !defined(WINDOWS) && !defined(__CYGWIN__)
return NULL;
home = pwd->pw_dir;
#else /* WINDOWS */
- home = "C:\\";
- /* #### Maybe I should grab home_dir from registry, but the best
- that I could get from there is user's Start menu. It sucks! */
+ /* Under Windows, if $HOME isn't defined, use the directory where
+ `wget.exe' resides. */
+ home = ws_mypath ();
#endif /* WINDOWS */
}
return xstrdup (env);
}
-#ifndef WINDOWS
/* If that failed, try $HOME/.wgetrc. */
home = home_dir ();
if (home)
- {
- file = (char *)xmalloc (strlen (home) + 1 + strlen (".wgetrc") + 1);
- sprintf (file, "%s/.wgetrc", home);
- }
+ file = aprintf ("%s/.wgetrc", 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
- as file name. SYSTEM_WGETRC should not be defined under WINDOWS.
- It is not as trivial as I assumed, because on 95 argv[0] is full
- path, but on NT you get what you typed in command line. --dbudor */
- home = ws_mypath ();
- if (home)
+#ifdef WINDOWS
+ /* Under Windows, if we still haven't found .wgetrc, look for the file
+ `wget.ini' in the directory where `wget.exe' resides; we do this for
+ backward compatibility with previous versions of Wget.
+ SYSTEM_WGETRC should not be defined under WINDOWS. */
+ if (!file || !file_exists_p (file))
{
- file = (char *)xmalloc (strlen (home) + strlen ("wget.ini") + 1);
- sprintf (file, "%swget.ini", home);
+ xfree_null (file);
+ file = NULL;
+ home = ws_mypath ();
+ if (home)
+ file = aprintf ("%s/wget.ini", home);
}
#endif /* WINDOWS */
}
enable_tilde_expansion = 1;
ln = 1;
- while ((line = read_whole_line (fp)))
+ while ((line = read_whole_line (fp)) != NULL)
{
char *com, *val;
int comind, status;
static int simple_atof PARAMS ((const char *, const char *, double *));
-/* Enginge for cmd_bytes and cmd_bytes_large: converts a string such
- as "100k" or "2.5G" to a floating point number. */
+/* Engine for cmd_bytes and cmd_bytes_large: converts a string such as
+ "100k" or "2.5G" to a floating point number. */
static int
parse_bytes_helper (const char *val, double *result)
}
/* Parse VAL as a number and set its value to CLOSURE (which should
- point to a long int).
+ point to a wgint).
By default, the value is assumed to be in bytes. If "K", "M", or
"G" are appended, the value is multiplied with 1<<10, 1<<20, or
exec_name, com, val);
return 0;
}
- *(long *)closure = (long)byte_value;
+ *(wgint *)closure = (wgint)byte_value;
return 1;
}
{
/* Free external resources, close files, etc. */
- if (opt.dfp)
- fclose (opt.dfp);
+ {
+ extern FILE *output_stream;
+ if (output_stream)
+ fclose (output_stream);
+ /* No need to check for error because Wget flushes its output (and
+ checks for errors) after any data arrives. */
+ }
/* We're exiting anyway so there's no real need to call free()
hundreds of times. Skipping the frees will make Wget exit