]> Pileus Git - ~andy/fetchmail/commitdiff
Merged hostrec and option structures.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 3 Jul 1996 03:16:16 +0000 (03:16 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 3 Jul 1996 03:16:16 +0000 (03:16 -0000)
svn path=/trunk/; revision=27

fetchmail.c
fetchmail.h
pop2.c
pop3.c

index 8918fe649864d5eb9cf4cad6ff340a8e4810159d..3c6a377c8a304b690b1c99547675f6d6b9180aea 100644 (file)
 /* 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);
   }
 }
index 1f8028f2f8399ef1f6adb14d8938d04c6d30c910..90b8ee634613e79038010f1badcd7ef009e3a7ff 100644 (file)
@@ -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 57508693d035d7fdddcb2a28636c33a22a930e41..9c7ae378845225505a5e82daf99f3ee0d36aba4d 100644 (file)
--- 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 ce1c2bea18e4f7298d025236e4d01a8b556478ca..5c6d7cddda52927ec26007a932cc82c37e288eee 100644 (file)
--- 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)