diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-10-05 18:06:48 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-10-05 18:06:48 +0000 |
commit | b2cf82ab2b395215a0214833a77f46b871fc5114 (patch) | |
tree | c1d1922c74b527381c7130db8d3c404335b42df8 /fetchmail.c | |
parent | 68c3f1308db0fd8a62855d812fbd34c0a80fb35d (diff) | |
download | fetchmail-b2cf82ab2b395215a0214833a77f46b871fc5114.tar.gz fetchmail-b2cf82ab2b395215a0214833a77f46b871fc5114.tar.bz2 fetchmail-b2cf82ab2b395215a0214833a77f46b871fc5114.zip |
Abstract out host allocation.
svn path=/trunk/; revision=229
Diffstat (limited to 'fetchmail.c')
-rw-r--r-- | fetchmail.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/fetchmail.c b/fetchmail.c index 42389932..f9f606dc 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -134,43 +134,25 @@ char **argv; if (implicitmode = (optind >= argc)) { for (hostp = hostlist; hostp; hostp = hostp->next) - hostp->active = 1; + hostp->active = TRUE; } else for (; optind < argc; optind++) { - int found; - /* * If hostname corresponds to a host known from the rc file, * simply declare it active. Otherwise synthesize a host * record from command line and defaults */ - found = FALSE; for (hostp = hostlist; hostp; hostp = hostp->next) if (strcmp(hostp->servername, argv[optind]) == 0) - { - found = TRUE; - break; - } + goto foundit; - if (found) - hostp->active = TRUE; - else - { - hostp = (struct hostrec *)xmalloc(sizeof(struct hostrec)); - - memcpy(hostp, &cmd_opts, sizeof(struct hostrec)); - strcpy(hostp->servername, argv[optind]); - hostp->active = TRUE; - - /* append to end of list */ - if (hosttail != (struct hostrec *) 0) - hosttail->next = hostp; - else - hostlist = hostp; - hosttail = hostp; - } + hostp = hostalloc(&cmd_opts); + strcpy(hostp->servername, argv[optind]); + + foundit: + hostp->active = TRUE; } /* merge in defaults for empty fields, then lose defaults record */ |