X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Finit.c;h=9e11944551dbd18cc2ead4e2175672627eccea9f;hp=b1169b23d8fd8ecce1b6daa0adbac15e00680de3;hb=1396b300550d9b5ca3b4b3e4e3776a1456024f73;hpb=2fbb4936a0f1bb4c79eb0a896115e1d8f495aad5 diff --git a/src/init.c b/src/init.c index b1169b23..9e119445 100644 --- a/src/init.c +++ b/src/init.c @@ -33,6 +33,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #endif #include +#ifdef WINDOWS +# include +#else +# include +# include +# include +#endif + #ifdef HAVE_PWD_H #include #endif @@ -52,6 +60,7 @@ extern int errno; #define CMD_DECLARE(func) static int func \ PARAMS ((const char *, const char *, void *)) +CMD_DECLARE (cmd_address); CMD_DECLARE (cmd_boolean); CMD_DECLARE (cmd_bytes); CMD_DECLARE (cmd_directory_vector); @@ -87,6 +96,7 @@ static struct { { "background", &opt.background, cmd_boolean }, { "backupconverted", &opt.backup_converted, cmd_boolean }, { "backups", &opt.backups, cmd_number }, + { "bindaddress", &opt.bind_address, cmd_address }, { "base", &opt.base_href, cmd_string }, { "cache", &opt.proxy_cache, cmd_boolean }, { "continue", &opt.always_rest, cmd_boolean }, @@ -475,6 +485,35 @@ setval (const char *com, const char *val) static int myatoi PARAMS ((const char *s)); +/* Store the address (specified as hostname or dotted-quad IP address) from VAL + to CLOSURE. COM is ignored, except for error messages. */ +static int +cmd_address (const char *com, const char *val, void *closure) +{ + struct sockaddr_in *sin; + + sin = (struct sockaddr_in *) malloc(sizeof *sin); + if (sin == NULL) + { + fprintf (stderr, _("%s: Out of memory.\n"), exec_name); + return 0; + } + + if (!store_hostaddress ((unsigned char *)&sin->sin_addr, val)) + { + fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"), + exec_name, com, val); + return 0; + } + + sin->sin_family = AF_INET; + sin->sin_port = 0; + + * (struct sockaddr_in **) closure = sin; + + return 1; +} + /* Store the boolean value from VAL to CLOSURE. COM is ignored, except for error messages. */ static int