aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-07-03 03:16:16 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-07-03 03:16:16 +0000
commit38a50aa15463362c59af69ac80e95f713bad27e3 (patch)
tree655d6852047f90c13b447b27572eba5ab2ea2035
parent9aafb07f141bbd1cae1395e34fe3d064918c6712 (diff)
downloadfetchmail-38a50aa15463362c59af69ac80e95f713bad27e3.tar.gz
fetchmail-38a50aa15463362c59af69ac80e95f713bad27e3.tar.bz2
fetchmail-38a50aa15463362c59af69ac80e95f713bad27e3.zip
Merged hostrec and option structures.
svn path=/trunk/; revision=27
-rw-r--r--fetchmail.c36
-rw-r--r--fetchmail.h6
-rw-r--r--pop2.c6
-rw-r--r--pop3.c8
4 files changed, 23 insertions, 33 deletions
diff --git a/fetchmail.c b/fetchmail.c
index 8918fe64..3c6a377c 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -41,19 +41,13 @@
/* release info */
#define RELEASE_TAG "3.0b6"
-struct hostrec {
- char *servername;
- struct optrec options;
- struct hostrec *next;
-};
-
#ifdef HAVE_PROTOTYPES
/* prototypes for internal functions */
int showoptions (struct optrec *options);
int parseMDAargs (struct optrec *options);
int showversioninfo (void);
int dump_options (struct optrec *options);
-int query_host(char *servername, struct optrec *options);
+int query_host(struct optrec *options);
#endif
/* Controls the detail of status/progress messages written to stderr */
@@ -91,10 +85,10 @@ int argc;
char **argv;
{
int mboxfd;
- struct optrec cmd_opts, def_opts, merged_opts;
+ struct optrec cmd_opts, def_opts;
int parsestatus;
char *servername;
- struct hostrec *hostp, *hostlist = (struct hostrec *)NULL;
+ struct optrec *hostp, *hostlist = (struct optrec *)NULL;
FILE *tmpfp;
pid_t pid;
@@ -118,12 +112,11 @@ char **argv;
if (strcmp(servername, "defaults") == 0)
continue;
- prc_mergeoptions(servername, &cmd_opts, &def_opts, &merged_opts);
- parseMDAargs(&merged_opts);
+ hostp = (struct optrec *)xmalloc(sizeof(struct optrec));
- hostp = (struct hostrec *)xmalloc(sizeof(struct hostrec));
- hostp->servername = strdup(servername);
- memcpy(&hostp->options, &merged_opts, sizeof(struct optrec));
+ prc_mergeoptions(servername, &cmd_opts, &def_opts, hostp);
+ strcpy(hostp->servername, servername);
+ parseMDAargs(hostp);
hostp->next = hostlist;
hostlist = hostp;
@@ -134,7 +127,7 @@ char **argv;
printf("Taking options from command line and %s\n", poprcfile);
for (hostp = hostlist; hostp; hostp = hostp->next) {
printf("Options for host %s:\n", hostp->servername);
- dump_options(&hostp->options);
+ dump_options(hostp);
}
if (hostlist == NULL)
(void) printf("No mailservers set up -- perhaps %s is missing?\n",
@@ -212,7 +205,7 @@ char **argv;
*/
do {
for (hostp = hostlist; hostp; hostp = hostp->next) {
- popstatus = query_host(hostp->servername, &hostp->options);
+ popstatus = query_host(hostp);
}
sleep(poll_interval);
@@ -229,23 +222,22 @@ void termhook()
exit(popstatus);
}
-int query_host(servername, options)
+int query_host(options)
/* perform fetch transaction with single host */
-char *servername;
struct optrec *options;
{
if (outlevel != O_SILENT)
- fprintf(stderr, "querying %s\n", servername);
+ fprintf(stderr, "popclient: querying %s\n", options->servername);
switch (options->whichpop) {
case P_POP2:
- return(doPOP2(servername, options));
+ return(doPOP2(options));
break;
case P_POP3:
case P_APOP:
- return(doPOP3(servername, options));
+ return(doPOP3(options));
break;
default:
- fprintf(stderr,"unsupported protocol selected.\n");
+ fprintf(stderr,"popclient: unsupported protocol selected.\n");
return(PS_PROTOCOL);
}
}
diff --git a/fetchmail.h b/fetchmail.h
index 1f8028f2..90b8ee63 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -55,6 +55,7 @@ struct optrec {
int fetchall;
int flush;
int output;
+ char servername [HOSTLEN];
char localname [USERNAMELEN];
char remotename [USERNAMELEN];
char password [PASSWORDLEN];
@@ -64,6 +65,7 @@ struct optrec {
char userfolder [FOLDERLEN];
char remotefolder [FOLDERLEN];
char mda [MDALEN];
+ struct optrec *next;
};
@@ -96,8 +98,8 @@ extern char *poprcfile; /* path name of rc file */
#ifdef HAVE_PROTOTYPES
/* prototypes for globally callable functions */
-int doPOP2 (char *servername, struct optrec *options);
-int doPOP3 (char *servername, struct optrec *options);
+int doPOP2 (struct optrec *options);
+int doPOP3 (struct optrec *options);
int parsecmdline (int argc, char **argv, struct optrec *options);
int setdefaults (struct optrec *options);
diff --git a/pop2.c b/pop2.c
index 57508693..9c7ae378 100644
--- a/pop2.c
+++ b/pop2.c
@@ -51,7 +51,6 @@ int POP2_stateXFER (int msgsize, int socket, int mboxfd, int topipe);
using Post Office Protocol 2.
arguments:
- servername name of the server to which we'll connect.
options fully-specified options (i.e. parsed, defaults invoked,
etc).
@@ -64,8 +63,7 @@ int POP2_stateXFER (int msgsize, int socket, int mboxfd, int topipe);
globals: reads outlevel.
*********************************************************************/
-int doPOP2 (servername,options)
-char *servername;
+int doPOP2 (options)
struct optrec *options;
{
int mboxfd;
@@ -90,7 +88,7 @@ struct optrec *options;
;
/* open the socket to the POP server */
- if ((socket = Socket(servername,POP2_PORT)) < 0) {
+ if ((socket = Socket(options->servername,POP2_PORT)) < 0) {
perror("doPOP2: socket");
return(PS_SOCKET);
}
diff --git a/pop3.c b/pop3.c
index ce1c2bea..5c6d7cdd 100644
--- a/pop3.c
+++ b/pop3.c
@@ -51,7 +51,6 @@ int POP3_BuildDigest (char *buf, struct optrec *options);
using Post Office Protocol 3.
arguments:
- servername name of server to which we'll connect.
options fully-specified options (i.e. parsed, defaults invoked,
etc).
@@ -61,8 +60,7 @@ int POP3_BuildDigest (char *buf, struct optrec *options);
globals: reads outlevel.
*********************************************************************/
-int doPOP3 (servername,options)
-char *servername;
+int doPOP3 (options)
struct optrec *options;
{
int ok;
@@ -78,7 +76,7 @@ struct optrec *options;
return(PS_IOERR);
/* open the socket and get the greeting */
- if ((socket = Socket(servername,POP3_PORT)) < 0) {
+ if ((socket = Socket(options->servername,POP3_PORT)) < 0) {
perror("doPOP3: socket");
ok = PS_SOCKET;
goto closeUp;
@@ -167,7 +165,7 @@ struct optrec *options;
goto cleanUp;
if (number >= first || options->fetchall)
- ok = POP3_readmsg(socket,mboxfd,servername,options->output == TO_MDA);
+ ok = POP3_readmsg(socket,mboxfd,options->servername,options->output == TO_MDA);
else
ok = 0;
if (ok != 0)