diff options
-rw-r--r-- | driver.c | 52 | ||||
-rw-r--r-- | fetchmail.c | 88 | ||||
-rw-r--r-- | fetchmail.h | 12 | ||||
-rw-r--r-- | options.c | 24 | ||||
-rw-r--r-- | pop3.c | 4 | ||||
-rw-r--r-- | rcfile_y.y | 81 | ||||
-rw-r--r-- | uid.c | 4 |
7 files changed, 132 insertions, 133 deletions
@@ -130,7 +130,7 @@ static int is_host_alias(const char *name, struct query *ctl) * name doesn't match either is it time to call the bind library. * If this happens odds are good we're looking at an MX name. */ - if (str_in_list(&ctl->lead_server->servernames, name)) + if (str_in_list(&ctl->lead_server->server.names, name)) return(TRUE); else if (strcmp(name, ctl->canonical_name) == 0) return(TRUE); @@ -162,7 +162,7 @@ static int is_host_alias(const char *name, struct query *ctl) putchar('\n'); /* terminate the progress message */ error(0, 0, "nameserver failure while looking for `%s' during poll of %s.", - name, ctl->servernames->id); + name, ctl->server.names->id); ctl->errcount++; longjmp(restart, 2); /* try again next poll cycle */ break; @@ -188,7 +188,7 @@ static int is_host_alias(const char *name, struct query *ctl) default: error(0, 0, "nameserver failure while looking for `%s' during poll of %s.", - name, ctl->servernames->id); + name, ctl->server.names->id); ctl->errcount++; longjmp(restart, 2); /* try again next poll cycle */ break; @@ -204,7 +204,7 @@ static int is_host_alias(const char *name, struct query *ctl) } /* add this name to relevant server's `also known as' list */ - save_str(&ctl->lead_server->servernames, -1, name); + save_str(&ctl->lead_server->server.names, -1, name); return(TRUE); } @@ -253,7 +253,7 @@ struct idlist **xmit_names; /* list of recipient names parsed out */ * on the localdomains list? If so, save the whole name * and keep going. */ - for (idp = ctl->localdomains; idp; idp = idp->next) + for (idp = ctl->server.localdomains; idp; idp = idp->next) { char *rhs; @@ -308,7 +308,7 @@ static FILE *smtp_open(struct query *ctl) if ((lead->smtp_sockfp = SockOpen(lead->smtphost, SMTP_PORT)) == (FILE *)NULL) return((FILE *)NULL); else if (SMTP_ok(lead->smtp_sockfp) != SM_OK - || SMTP_helo(lead->smtp_sockfp, ctl->servernames->id) != SM_OK) + || SMTP_helo(lead->smtp_sockfp, ctl->server.names->id) != SM_OK) { fclose(lead->smtp_sockfp); lead->smtp_sockfp = (FILE *)NULL; @@ -348,7 +348,7 @@ char *realname; /* real name of host */ if (!SockGets(buf,sizeof(buf),sockfp)) return(PS_SOCKET); n = strlen(buf); - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); /* squeeze out all carriage returns */ for (fromptr = toptr = buf; *fromptr; fromptr++) @@ -425,7 +425,7 @@ char *realname; /* real name of host */ tohdr = bufp; else if (!strncasecmp("Apparently-To:", bufp, 14)) envto = bufp; - else if (!strncasecmp(ctl->envelope, bufp, 14)) + else if (!strncasecmp(ctl->server.envelope, bufp, 14)) envto = bufp; else if (!strncasecmp("Cc:", bufp, 3)) cchdr = bufp; @@ -866,7 +866,7 @@ const struct method *proto; /* protocol method table */ void (*sigsave)(); #ifndef KERBEROS_V4 - if (ctl->authenticate == A_KERBEROS) + if (ctl->server.authenticate == A_KERBEROS) { error(0, 0, "Kerberos support not linked."); return(PS_ERROR); @@ -906,13 +906,13 @@ const struct method *proto; /* protocol method table */ /* set up the server-nonresponse timeout */ sigsave = signal(SIGVTALRM, vtalarm_handler); - vtalarm(mytimeout = ctl->timeout); + vtalarm(mytimeout = ctl->server.timeout); if ((js = setjmp(restart)) == 1) { error(0, 0, "timeout after %d seconds waiting for %s.", - ctl->timeout, ctl->servernames->id); + ctl->server.timeout, ctl->server.names->id); ok = PS_ERROR; } else if (js == 2) @@ -935,8 +935,8 @@ const struct method *proto; /* protocol method table */ } /* open a socket to the mail server */ - if ((sockfp = SockOpen(ctl->servernames->id, - ctl->port ? ctl->port : protocol->port)) == NULL) + if (!(sockfp = SockOpen(ctl->server.names->id, + ctl->server.port ? ctl->server.port : protocol->port))) { if (errno != EHOSTUNREACH) error(0, errno, "connecting to host"); @@ -950,7 +950,7 @@ const struct method *proto; /* protocol method table */ ok = kerberos_auth(fileno(sockfp), ctl->canonical_name); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); } #endif /* KERBEROS_V4 */ @@ -958,7 +958,7 @@ const struct method *proto; /* protocol method table */ ok = (protocol->parse_response)(sockfp, buf); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); /* * Try to parse the host's actual name out of the greeting @@ -1033,7 +1033,7 @@ const struct method *proto; /* protocol method table */ *tp = '\0'; } else - strcpy(realname, ctl->servernames->id); + strcpy(realname, ctl->server.names->id); /* try to get authorized to fetch mail */ shroud = ctl->password; @@ -1043,13 +1043,13 @@ const struct method *proto; /* protocol method table */ ok = PS_AUTHFAIL; if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); /* compute number of messages and number of new messages waiting */ ok = (protocol->getrange)(sockfp, ctl, &count, &new); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); /* show user how many messages we downloaded */ if (outlevel > O_SILENT) @@ -1079,7 +1079,7 @@ const struct method *proto; /* protocol method table */ ok = (proto->getsizes)(sockfp, count, msgsizes); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); } @@ -1141,7 +1141,7 @@ const struct method *proto; /* protocol method table */ ok = (protocol->fetch)(sockfp, ctl, num, &len); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); if (outlevel > O_SILENT) { @@ -1162,7 +1162,7 @@ const struct method *proto; /* protocol method table */ realname); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); /* tell the server we got it OK and resynchronize */ if (protocol->trail) @@ -1170,7 +1170,7 @@ const struct method *proto; /* protocol method table */ ok = (protocol->trail)(sockfp, ctl, num); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); } } @@ -1193,7 +1193,7 @@ const struct method *proto; /* protocol method table */ ok = (protocol->delete)(sockfp, ctl, num); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); delete_str(&ctl->newsaved, num); } else if (outlevel > O_SILENT) @@ -1210,7 +1210,7 @@ const struct method *proto; /* protocol method table */ ok = gen_transact(sockfp, protocol->expunge_cmd); if (ok != 0) goto cleanUp; - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); } ok = gen_transact(sockfp, protocol->exit_cmd); @@ -1230,7 +1230,7 @@ const struct method *proto; /* protocol method table */ } cleanUp: - vtalarm(ctl->timeout); + vtalarm(ctl->server.timeout); if (ok != 0 && ok != PS_SOCKET) gen_transact(sockfp, protocol->exit_cmd); vtalarm(0); @@ -1266,7 +1266,7 @@ const struct method *proto; /* protocol method table */ } if (ok==PS_SOCKET || ok==PS_AUTHFAIL || ok==PS_SYNTAX || ok==PS_IOERR || ok==PS_ERROR || ok==PS_PROTOCOL || ok==PS_SMTP) - error(0, 0, "%s error while fetching from %s", msg, ctl->servernames->id); + error(0, 0, "%s error while fetching from %s", msg, ctl->server.names->id); closeUp: signal(SIGVTALRM, sigsave); diff --git a/fetchmail.c b/fetchmail.c index 76fc0f15..c2169bfc 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -189,7 +189,7 @@ int main (int argc, char **argv) printf("No monitor interface specified.\n"); #endif for (ctl = querylist; ctl; ctl = ctl->next) { - if (ctl->active && !(implicitmode && ctl->skip)) + if (ctl->active && !(implicitmode && ctl->server.skip)) dump_params(ctl); } if (querylist == NULL) @@ -300,9 +300,9 @@ int main (int argc, char **argv) /* pick up interactively any passwords we need but don't have */ for (ctl = querylist; ctl; ctl = ctl->next) - if (ctl->active && !(implicitmode && ctl->skip) && !ctl->password[0]) + if (ctl->active && !(implicitmode && ctl->server.skip) && !ctl->password[0]) { - if (ctl->authenticate == A_KERBEROS) + if (ctl->server.authenticate == A_KERBEROS) /* Server won't care what the password is, but there must be some non-null string here. */ (void) strncpy(ctl->password, @@ -310,7 +310,7 @@ int main (int argc, char **argv) else { /* Look up the host and account in the .netrc file. */ - netrc_entry *p = search_netrc(netrc_list,ctl->servernames->id); + netrc_entry *p = search_netrc(netrc_list,ctl->server.names->id); while (p && strcmp (p->account, ctl->remotename)) p = search_netrc (p->next, ctl->remotename); @@ -325,7 +325,7 @@ int main (int argc, char **argv) if (!ctl->password[0]) { (void) sprintf(tmpbuf, "Enter password for %s@%s: ", - ctl->remotename, ctl->servernames->id); + ctl->remotename, ctl->server.names->id); (void) strncpy(ctl->password, (char *)getpassword(tmpbuf),PASSWORDLEN-1); } @@ -447,7 +447,7 @@ int main (int argc, char **argv) batchcount = 0; for (ctl = querylist; ctl; ctl = ctl->next) { - if (ctl->active && !(implicitmode && ctl->skip)) + if (ctl->active && !(implicitmode && ctl->server.skip)) { #ifdef HAVE_GETHOSTBYNAME /* @@ -455,18 +455,18 @@ int main (int argc, char **argv) * as a probe to make sure our nameserver is still up. * The multidrop case (especially) needs it. */ - if (ctl->authenticate == A_KERBEROS || MULTIDROP(ctl)) + if (ctl->server.authenticate == A_KERBEROS || MULTIDROP(ctl)) { struct hostent *namerec; /* compute the canonical name of the host */ errno = 0; - namerec = gethostbyname(ctl->servernames->id); + namerec = gethostbyname(ctl->server.names->id); if (namerec == (struct hostent *)NULL) { error(0, errno, "skipping %s poll, ", - ctl->servernames->id); + ctl->server.names->id); if (errno) { if (errno == ENETUNREACH) @@ -529,8 +529,8 @@ static int load_params(int argc, char **argv, int optind) memset(&def_opts, '\0', sizeof(struct query)); - def_opts.protocol = P_AUTO; - def_opts.timeout = CLIENT_TIMEOUT; + def_opts.server.protocol = P_AUTO; + def_opts.server.timeout = CLIENT_TIMEOUT; strcpy(def_opts.remotename, user); strcpy(def_opts.smtphost, "localhost"); @@ -552,18 +552,18 @@ static int load_params(int argc, char **argv, int optind) * record from command line and defaults */ for (ctl = querylist; ctl; ctl = ctl->next) - if (str_in_list(&ctl->servernames, argv[optind])) + if (str_in_list(&ctl->server.names, argv[optind])) goto foundit; ctl = hostalloc(&cmd_opts); - save_str(&ctl->servernames, -1, argv[optind]); + save_str(&ctl->server.names, -1, argv[optind]); foundit: ctl->active = TRUE; } /* if there's a defaults record, merge it and lose it */ - if (querylist && strcmp(querylist->servernames->id, "defaults") == 0) + if (querylist && strcmp(querylist->server.names->id, "defaults") == 0) { for (ctl = querylist->next; ctl; ctl = ctl->next) optmerge(ctl, querylist); @@ -572,13 +572,13 @@ static int load_params(int argc, char **argv, int optind) /* don't allow a defaults record after the first */ for (ctl = querylist; ctl; ctl = ctl->next) - if (ctl != querylist && strcmp(ctl->servernames->id, "defaults") == 0) + if (ctl != querylist && strcmp(ctl->server.names->id, "defaults") == 0) exit(PS_SYNTAX); /* merge in wired defaults, do sanity checks and prepare internal fields */ for (ctl = querylist; ctl; ctl = ctl->next) { - if (ctl->active && !(implicitmode && ctl->skip)) + if (ctl->active && !(implicitmode && ctl->server.skip)) { /* merge in defaults */ optmerge(ctl, &def_opts); @@ -640,7 +640,7 @@ static int load_params(int argc, char **argv, int optind) /* similarly, compute server leaders for queries */ for (mp = querylist; mp && mp != ctl; mp = mp->next) - if (strcmp(mp->servernames->id, ctl->servernames->id) == 0) + if (strcmp(mp->server.names->id, ctl->server.names->id) == 0) { ctl->lead_server = mp->lead_server; goto no_new_server; @@ -649,15 +649,15 @@ static int load_params(int argc, char **argv, int optind) no_new_server:; /* plug in the semi-standard way of indicating a mail address */ - if (ctl->envelope == (char *)NULL) - ctl->envelope = "X-Envelope-To:"; + if (ctl->server.envelope == (char *)NULL) + ctl->server.envelope = "X-Envelope-To:"; /* sanity checks */ - if (ctl->port < 0) + if (ctl->server.port < 0) { (void) fprintf(stderr, "%s configuration invalid, port number cannot be negative", - ctl->servernames->id); + ctl->server.names->id); exit(PS_SYNTAX); } } @@ -764,17 +764,17 @@ static int query_host(struct query *ctl) time(&now); fprintf(stderr, "Querying %s (protocol %s) at %s", - ctl->servernames->id, showproto(ctl->protocol), ctime(&now)); + ctl->server.names->id, showproto(ctl->server.protocol), ctime(&now)); } - switch (ctl->protocol) { + switch (ctl->server.protocol) { case P_AUTO: for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++) { - ctl->protocol = autoprobe[i]; + ctl->server.protocol = autoprobe[i]; if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL) break; } - ctl->protocol = P_AUTO; + ctl->server.protocol = P_AUTO; return(st); break; case P_POP2: @@ -797,55 +797,55 @@ void dump_params (struct query *ctl) /* display query parameters in English */ { printf("Options for retrieving from %s@%s:\n", - ctl->remotename, visbuf(ctl->servernames->id)); + ctl->remotename, visbuf(ctl->server.names->id)); #ifdef HAVE_GETHOSTBYNAME if (ctl->canonical_name) printf(" Canonical DNS name of server is %s.\n", ctl->canonical_name); #endif /* HAVE_GETHOSTBYNAME */ - if (ctl->servernames->next) + if (ctl->server.names->next) { struct idlist *idp; printf(" Predeclared mailserver aliases:"); - for (idp = ctl->servernames->next; idp; idp = idp->next) + for (idp = ctl->server.names->next; idp; idp = idp->next) printf(" %s", idp->id); putchar('\n'); } - if (ctl->skip || outlevel == O_VERBOSE) + if (ctl->server.skip || outlevel == O_VERBOSE) printf(" This host will%s be queried when no host is specified.\n", - ctl->skip ? " not" : ""); + ctl->server.skip ? " not" : ""); if (ctl->password[0] == '\0') printf(" Password will be prompted for.\n"); else if (outlevel == O_VERBOSE) - if (ctl->protocol == P_APOP) + if (ctl->server.protocol == P_APOP) printf(" APOP secret = '%s'.\n", visbuf(ctl->password)); else printf(" Password = '%s'.\n", visbuf(ctl->password)); - if (ctl->protocol == P_POP3 - && ctl->port == KPOP_PORT - && ctl->authenticate == A_KERBEROS) + if (ctl->server.protocol == P_POP3 + && ctl->server.port == KPOP_PORT + && ctl->server.authenticate == A_KERBEROS) printf(" Protocol is KPOP"); else - printf(" Protocol is %s", showproto(ctl->protocol)); - if (ctl->port) - printf(" (using port %d)", ctl->port); + printf(" Protocol is %s", showproto(ctl->server.protocol)); + if (ctl->server.port) + printf(" (using port %d)", ctl->server.port); else if (outlevel == O_VERBOSE) printf(" (using default port)"); putchar('.'); putchar('\n'); - if (ctl->authenticate == A_KERBEROS) + if (ctl->server.authenticate == A_KERBEROS) printf(" Kerberos authentication enabled.\n"); - printf(" Server nonresponse timeout is %d seconds", ctl->timeout); - if (ctl->timeout == CLIENT_TIMEOUT) + printf(" Server nonresponse timeout is %d seconds", ctl->server.timeout); + if (ctl->server.timeout == CLIENT_TIMEOUT) printf(" (default).\n"); else printf(".\n"); - if (ctl->localdomains) + if (ctl->server.localdomains) { struct idlist *idp; printf(" Local domains:"); - for (idp = ctl->localdomains; idp; idp = idp->next) + for (idp = ctl->server.localdomains; idp; idp = idp->next) printf(" %s", idp->id); putchar('\n'); } @@ -905,10 +905,10 @@ void dump_params (struct query *ctl) } if (count > 1) - printf(" Envelope header is assumed to be: %s\n", ctl->envelope); + printf(" Envelope header is assumed to be: %s\n", ctl->server.envelope); } - if (ctl->protocol > P_POP2) + if (ctl->server.protocol > P_POP2) if (!ctl->oldsaved) printf(" No UIDs saved from this host.\n"); else diff --git a/fetchmail.h b/fetchmail.h index 105275a0..56b146b1 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -59,10 +59,10 @@ struct idlist struct idlist *next; }; -struct query + +struct hostdata /* shared among all user connections to given server */ { - /* per-host data */ - struct idlist *servernames; /* servername first, then akas */ + struct idlist *names; /* server name first, then akas */ struct idlist *localdomains; /* list of pass-through domains */ int protocol; int port; @@ -70,6 +70,12 @@ struct query int timeout; char *envelope; int skip; +}; + +struct query +{ + /* mailserver connection controls */ + struct hostdata server; /* per-user data */ struct idlist *localnames; /* including calling user's name */ @@ -172,18 +172,18 @@ struct query *ctl; /* option record to be initialized */ case LA_PROTOCOL: /* XXX -- should probably use a table lookup here */ if (strcasecmp(optarg,"pop2") == 0) - ctl->protocol = P_POP2; + ctl->server.protocol = P_POP2; else if (strcasecmp(optarg,"pop3") == 0) - ctl->protocol = P_POP3; + ctl->server.protocol = P_POP3; else if (strcasecmp(optarg,"imap") == 0) - ctl->protocol = P_IMAP; + ctl->server.protocol = P_IMAP; else if (strcasecmp(optarg,"apop") == 0) - ctl->protocol = P_APOP; + ctl->server.protocol = P_APOP; else if (strcasecmp(optarg,"kpop") == 0) { - ctl->protocol = P_POP3; - ctl->port = KPOP_PORT; - ctl->authenticate = A_KERBEROS; + ctl->server.protocol = P_POP3; + ctl->server.port = KPOP_PORT; + ctl->server.authenticate = A_KERBEROS; } else { fprintf(stderr,"Invalid protocol `%s' specified.\n", optarg); @@ -192,14 +192,14 @@ struct query *ctl; /* option record to be initialized */ break; case 'P': case LA_PORT: - ctl->port = atoi(optarg); + ctl->server.port = atoi(optarg); break; case 'A': case LA_AUTHENTICATE: if (strcmp(optarg, "password") == 0) - ctl->authenticate = A_PASSWORD; + ctl->server.authenticate = A_PASSWORD; else if (strcmp(optarg, "kerberos") == 0) - ctl->authenticate = A_KERBEROS; + ctl->server.authenticate = A_KERBEROS; else { fprintf(stderr,"Invalid authentication `%s' specified.\n", optarg); errflag++; @@ -207,11 +207,11 @@ struct query *ctl; /* option record to be initialized */ break; case 't': case LA_TIMEOUT: - ctl->timeout = atoi(optarg); + ctl->server.timeout = atoi(optarg); break; case 'E': case LA_ENVELOPE: - ctl->envelope = xstrdup(optarg); + ctl->server.envelope = xstrdup(optarg); break; case 'u': @@ -68,7 +68,7 @@ int pop3_getauth(FILE *sockfp, struct query *ctl, char *greeting) /* apply for connection authorization */ { /* build MD5 digest from greeting timestamp + password */ - if (ctl->protocol == P_APOP) + if (ctl->server.protocol == P_APOP) { char *start,*end; char *msg; @@ -100,7 +100,7 @@ int pop3_getauth(FILE *sockfp, struct query *ctl, char *greeting) free(msg); } - switch (ctl->protocol) { + switch (ctl->server.protocol) { case P_POP3: if ((gen_transact(sockfp,"USER %s", ctl->remotename)) != 0) PROTOCOL_ERROR @@ -81,41 +81,41 @@ statement : SET BATCHLIMIT MAP NUMBER {batchlimit = $4;} | define_server serverspecs userspecs ; -define_server : POLL STRING {current.servernames = (struct idlist *)NULL; - save_str(¤t.servernames, -1, $2); - current.skip = FALSE;} - | SKIP STRING {current.servernames = (struct idlist *)NULL; - save_str(¤t.servernames, -1, $2); - current.skip = TRUE;} - | DEFAULTS {current.servernames = (struct idlist *)NULL; - save_str(¤t.servernames, -1,"defaults");} +define_server : POLL STRING {current.server.names = (struct idlist *)NULL; + save_str(¤t.server.names, -1,$2); + current.server.skip = FALSE;} + | SKIP STRING {current.server.names = (struct idlist *)NULL; + save_str(¤t.server.names, -1,$2); + current.server.skip = TRUE;} + | DEFAULTS {current.server.names = (struct idlist *)NULL; + save_str(¤t.server.names, -1,"defaults");} ; serverspecs : /* EMPTY */ | serverspecs serv_option ; -alias_list : STRING {save_str(¤t.servernames,-1,$1);} - | alias_list STRING {save_str(¤t.servernames,-1,$2);} +alias_list : STRING {save_str(¤t.server.names,-1,$1);} + | alias_list STRING {save_str(¤t.server.names,-1,$2);} ; -domain_list : STRING {save_str(¤t.localdomains,-1,$1);} - | domain_list STRING {save_str(¤t.localdomains,-1,$2);} +domain_list : STRING {save_str(¤t.server.localdomains,-1,$1);} + | domain_list STRING {save_str(¤t.server.localdomains,-1,$2);} ; serv_option : AKA alias_list | LOCALDOMAINS domain_list - | PROTOCOL PROTO {current.protocol = $2;} + | PROTOCOL PROTO {current.server.protocol = $2;} | PROTOCOL KPOP { - current.protocol = P_POP3; - current.authenticate = A_KERBEROS; - current.port = KPOP_PORT; + current.server.protocol = P_POP3; + current.server.authenticate = A_KERBEROS; + current.server.port = KPOP_PORT; } - | PORT NUMBER {current.port = $2;} - | AUTHENTICATE PASSWORD {current.authenticate = A_PASSWORD;} - | AUTHENTICATE KERBEROS {current.authenticate = A_KERBEROS;} - | TIMEOUT NUMBER {current.timeout = $2;} - | ENVELOPE STRING {current.envelope = xstrdup($2);} + | PORT NUMBER {current.server.port = $2;} + | AUTHENTICATE PASSWORD {current.server.authenticate = A_PASSWORD;} + | AUTHENTICATE KERBEROS {current.server.authenticate = A_KERBEROS;} + | TIMEOUT NUMBER {current.server.timeout = $2;} + | ENVELOPE STRING {current.server.envelope = xstrdup($2);} ; /* @@ -272,7 +272,7 @@ const char *pathname; /* pathname for the configuration file */ static void prc_reset(void) /* clear the global current record (server parameters) used by the parser */ { - struct query save; + struct hostdata save; /* * Purpose of this code is to initialize the new server block, but @@ -280,18 +280,11 @@ static void prc_reset(void) * preserve server options unless the command-line explicitly * overrides them. */ - save = current; + save = current.server; memset(¤t, '\0', sizeof(current)); - current.servernames = save.servernames; - current.localdomains = save.localdomains; - current.protocol = save.protocol; - current.port = save.port; - current.authenticate = save.authenticate; - current.timeout = save.timeout; - current.envelope = save.envelope; - current.skip = save.skip; + current.server = save; } struct query *hostalloc(init) @@ -329,12 +322,12 @@ static void prc_register(void) #undef STR_FORCE #define FLAG_FORCE(fld) if (cmd_opts.fld) current.fld = cmd_opts.fld - FLAG_FORCE(protocol); - FLAG_FORCE(port); - FLAG_FORCE(authenticate); - FLAG_FORCE(timeout); - FLAG_FORCE(envelope); /* yes, even though this is a string */ - FLAG_FORCE(skip); + FLAG_FORCE(server.protocol); + FLAG_FORCE(server.port); + FLAG_FORCE(server.authenticate); + FLAG_FORCE(server.timeout); + FLAG_FORCE(server.envelope); /* yes, even though this is a string */ + FLAG_FORCE(server.skip); FLAG_FORCE(keep); FLAG_FORCE(flush); @@ -350,8 +343,8 @@ static void prc_register(void) void optmerge(struct query *h2, struct query *h1) /* merge two options records; empty fields in h2 are filled in from h1 */ { + append_str_list(&h2->server.localdomains, &h1->server.localdomains); append_str_list(&h2->localnames, &h1->localnames); - append_str_list(&h2->localdomains, &h1->localdomains); #define STR_MERGE(fld, len) if (*(h2->fld) == '\0') strcpy(h2->fld, h1->fld) STR_MERGE(remotename, USERNAMELEN); @@ -363,12 +356,12 @@ void optmerge(struct query *h2, struct query *h1) #undef STR_MERGE #define FLAG_MERGE(fld) if (!h2->fld) h2->fld = h1->fld - FLAG_MERGE(protocol); - FLAG_MERGE(port); - FLAG_MERGE(authenticate); - FLAG_MERGE(timeout); - FLAG_MERGE(envelope); /* yes, even though this is a string */ - FLAG_MERGE(skip); + FLAG_MERGE(server.protocol); + FLAG_MERGE(server.port); + FLAG_MERGE(server.authenticate); + FLAG_MERGE(server.timeout); + FLAG_MERGE(server.envelope); /* yes, even though this is a string */ + FLAG_MERGE(server.skip); FLAG_MERGE(keep); FLAG_MERGE(flush); @@ -84,7 +84,7 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile) { for (ctl = hostlist; ctl; ctl = ctl->next) { - if (strcmp(host, ctl->servernames->id) == 0 + if (strcmp(host, ctl->server.names->id) == 0 && strcmp(user, ctl->remotename) == 0) { save_str(&ctl->oldsaved, -1, id); @@ -256,7 +256,7 @@ void write_saved_lists(struct query *hostlist, const char *idfile) for (ctl = hostlist; ctl; ctl = ctl->next) { for (idp = ctl->oldsaved; idp; idp = idp->next) fprintf(tmpfp, "%s@%s %s\n", - ctl->remotename, ctl->servernames->id, idp->id); + ctl->remotename, ctl->server.names->id, idp->id); } for (idp = scratchlist; idp; idp = idp->next) fputs(idp->id, tmpfp); |