#endif
#include <errno.h>
-#ifdef WINDOWS
-# include <winsock.h>
-#else
-# include <sys/socket.h>
-# include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#endif
-#endif
-
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
{ "forcehtml", &opt.force_html, cmd_boolean },
{ "ftpproxy", &opt.ftp_proxy, cmd_string },
{ "glob", &opt.ftp_glob, cmd_boolean },
- { "header", NULL, cmd_spec_header },
+ { "header", &opt.user_headers, cmd_spec_header },
{ "htmlextension", &opt.html_extension, cmd_boolean },
{ "htmlify", NULL, cmd_spec_htmlify },
{ "httpkeepalive", &opt.http_keep_alive, cmd_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 },
+ { "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.restrict_files_os = restrict_windows;
#endif
opt.restrict_files_ctrl = 1;
-
-#ifdef ENABLE_IPV6
-# ifndef HAVE_GETADDRINFO_AI_ADDRCONFIG
- /* If IPv6 is enabled, but AI_ADDRCONFIG is missing, check whether
- we can create AF_INET6 sockets. If we can't, turn on the
- --inet4-only setting. This is necessary because on some systems
- (e.g. RHL 9) getaddrinfo resolves AAAA records, but socket()
- can't even create an AF_INET6 socket, let alone connect to IPv6
- hosts. To avoid "address family not supported" error messages,
- we set ipv4_only.
-
- We do it as early as here, so that the user can revert the
- settingn using --no-inet4-only, in case he wants to see the error
- messages, for whatever reason. */
- {
- int sock = socket (AF_INET6, SOCK_STREAM, 0);
- if (sock < 0)
- opt.ipv4_only = -1; /* special value -1 because the option
- was not specified by the user. */
- else
- close (sock);
- }
-# endif /* not HAVE_GETADDRINFO_AI_ADDRCONFIG */
-#endif /* ENABLE_IPV6 */
}
\f
/* Return the user's home directory (strdup-ed), or NULL if none is
static int
cmd_spec_header (const char *com, const char *val, void *closure)
{
- if (!*val)
+ if (!check_user_specified_header (val))
{
- /* Empty header means reset headers. */
- xfree_null (opt.user_header);
- opt.user_header = NULL;
- }
- else
- {
- int i;
-
- if (!check_user_specified_header (val))
- {
- fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),
- exec_name, com, val);
- return 0;
- }
- i = opt.user_header ? strlen (opt.user_header) : 0;
- opt.user_header = (char *)xrealloc (opt.user_header, i + strlen (val)
- + 2 + 1);
- strcpy (opt.user_header + i, val);
- i += strlen (val);
- opt.user_header[i++] = '\r';
- opt.user_header[i++] = '\n';
- opt.user_header[i] = '\0';
+ fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),
+ exec_name, com, val);
+ return 0;
}
- return 1;
+ return cmd_vector (com, val, closure);
}
static int
{
/* 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