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 | |
parent | 68c3f1308db0fd8a62855d812fbd34c0a80fb35d (diff) | |
download | fetchmail-b2cf82ab2b395215a0214833a77f46b871fc5114.tar.gz fetchmail-b2cf82ab2b395215a0214833a77f46b871fc5114.tar.bz2 fetchmail-b2cf82ab2b395215a0214833a77f46b871fc5114.zip |
Abstract out host allocation.
svn path=/trunk/; revision=229
-rw-r--r-- | fetchmail.c | 32 | ||||
-rw-r--r-- | fetchmail.h | 2 |
2 files changed, 9 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 */ diff --git a/fetchmail.h b/fetchmail.h index caa6fee2..cc25f178 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -127,6 +127,7 @@ int doPOP2 (struct hostrec *); int doPOP3 (struct hostrec *); int doIMAP (struct hostrec *); +struct hostrec *hostalloc(struct hostrec *); int parsecmdline (int, char **, struct hostrec *); void optmerge(struct hostrec *, struct hostrec *); char *MD5Digest (char *); @@ -135,6 +136,7 @@ int daemonize(const char *, void (*)(int)); #else +struct hostrec *hostinit(); char *MD5Digest (); void optmerge(); |