-/* Interpret VAL as an Internet address (a hostname or a dotted-quad
- IP address), and write it (in network order) to a malloc-allocated
- address. That address gets stored to the memory pointed to by
- CLOSURE. COM is ignored, except for error messages.
-
- #### IMHO it's a mistake to do this kind of work so early in the
- process (before any download even started!) opt.bind_address
- should simply remember the provided value as a string. Another
- function should do the lookup, when needed, and cache the
- result. --hniksic */
-static int
-cmd_address (const char *com, const char *val, void *closure)
-{
- struct address_list *al;
- struct sockaddr_in sin;
- struct sockaddr_in **target = (struct sockaddr_in **)closure;
-
- memset (&sin, '\0', sizeof (sin));
-
- al = lookup_host (val, 1);
- if (!al)
- {
- fprintf (stderr, _("%s: %s: Cannot convert `%s' to an IP address.\n"),
- exec_name, com, val);
- return 0;
- }
- address_list_copy_one (al, 0, (unsigned char *)&sin.sin_addr);
- address_list_release (al);
-
- sin.sin_family = AF_INET;
- sin.sin_port = 0;
-
- FREE_MAYBE (*target);
-
- *target = xmalloc (sizeof (sin));
- memcpy (*target, &sin, sizeof (sin));
-
- return 1;
-}
-