]> Pileus Git - ~andy/fetchmail/commitdiff
gcc -Wall cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 26 Oct 1996 22:21:16 +0000 (22:21 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 26 Oct 1996 22:21:16 +0000 (22:21 -0000)
svn path=/trunk/; revision=396

14 files changed:
daemon.c
driver.c
fetchmail.c
fetchmail.h
getpass.c
imap.c
options.c
pop2.c
pop3.c
rcfile_l.l
rcfile_y.y
socket.c
uid.c
xmalloc.c

index 27449e352b8833ae717a6867c6dc2b16dd8a8ab3..ead2364127bd102d712ceb42ef3b67dc5074f4c6 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -8,6 +8,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <sys/file.h>
 #include <signal.h>
 #include <fcntl.h>
 #  include <unistd.h>
 #endif
 
+#if defined(STDC_HEADERS)
+#include <stdlib.h>
+#endif
+
 #if defined(QNX)
 #  include <unix.h>
 #endif
@@ -174,6 +179,8 @@ nottyDetach:
 #if defined(SIGPWR)
   signal(SIGPWR, sigchld_handler); 
 #endif
+
+  return(0);
 }
 
 /* daemon.c ends here */
index 6cb18cd8a347362075f3614cc8b4c086647c4857..15d2da9a36496c48881b9f81657ca98a125db43a 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -9,10 +9,14 @@
 #include  <config.h>
 #include  <stdio.h>
 #include  <setjmp.h>
+#include  <ctype.h>
 #if defined(STDC_HEADERS)
 #include  <stdlib.h>
 #include  <string.h>
 #endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
 #if defined(HAVE_STDARG_H)
 #include  <stdarg.h>
 #else
@@ -38,7 +42,7 @@
 
 #define        SMTP_PORT       25      /* standard SMTP service port */
 
-static struct method *protocol;
+static const struct method *protocol;
 static jmp_buf restart;
 
 char tag[TAGLEN];
@@ -334,7 +338,7 @@ const char *name;
 struct query   *ctl;
 {
     struct hostent     *he;
-    int                        i, n;
+    int                        i;
 
     /*
      * The first two checks are optimizations that will catch a good
@@ -369,7 +373,6 @@ struct query        *ctl;
     for (i = 0; i < MX_RETRIES; i++)
     {
        struct mxentry *mxrecords, *mxp;
-       int j;
 
        mxrecords = getmxrecords(name);
 
@@ -439,12 +442,9 @@ int delimited;     /* does the protocol use a message delimiter? */
 struct query *ctl;     /* query control record */
 { 
     char buf [MSGBUFSIZE+1]; 
-    char fromBuf[MSGBUFSIZE+1];
     char *bufp, *headers, *unixfrom, *fromhdr, *tohdr, *cchdr, *bcchdr;
     int n, oldlen;
     int inheaders,lines,sizeticker;
-    /* This keeps the retrieved message count for display purposes */
-    static int msgnum = 0;  
 
     /* read the message content from the server */
     inheaders = 1;
@@ -725,8 +725,8 @@ char *canonical;    /* server name */
 
 int do_protocol(ctl, proto)
 /* retrieve messages from server using given protocol method table */
-struct query *ctl;     /* parsed options with merged-in defaults */
-struct method *proto;          /* protocol method table */
+struct query *ctl;             /* parsed options with merged-in defaults */
+const struct method *proto;    /* protocol method table */
 {
     int ok, mboxfd = -1;
     void (*sigsave)();
@@ -775,7 +775,7 @@ struct method *proto;               /* protocol method table */
                ctl->timeout, ctl->servername);
     else
     {
-       char buf [POPBUFSIZE+1], host[HOSTLEN+1];
+       char buf [POPBUFSIZE+1];
        int *msgsizes, socket, len, num, count, new, deletions = 0;
 
        /* set up the server-nonresponse timeout */
@@ -934,7 +934,7 @@ struct method *proto;               /* protocol method table */
                {
                    deletions++;
                    if (outlevel > O_SILENT) 
-                       fprintf(stderr, " flushed\n", num);
+                       fprintf(stderr, " flushed\n");
                    ok = (protocol->delete)(socket, ctl, num);
                    if (ok != 0)
                        goto cleanUp;
@@ -943,7 +943,7 @@ struct method *proto;               /* protocol method table */
                {
                    /* nuke it from the unseen-messages list */
                    delete_uid(&ctl->newsaved, num);
-                   fprintf(stderr, " not flushed\n", num);
+                   fprintf(stderr, " not flushed\n");
                }
            }
 
index 9a0e38e65c02f6a05e3557592191149243a83bf6..f912cad99972f3d672b64e0e4cfcd9ea3cda116f 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <config.h>
 #include <stdio.h>
+#include <ctype.h>
+#include <time.h>
 
 #if defined(STDC_HEADERS)
 #include <stdlib.h>
@@ -37,7 +39,7 @@
 
 #ifdef HAVE_PROTOTYPES
 /* prototypes for internal functions */
-static int dump_options (struct query *);
+static void dump_params (struct query *);
 static int query_host(struct query *);
 static char *visbuf(const char *);
 #endif
@@ -65,14 +67,14 @@ static struct query *ctl;
 
 RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing);}
 
-main (argc,argv)
+int main (argc,argv)
 int argc;
 char **argv;
 { 
-    int mboxfd, st, bkgd, lossage;
+    int st, bkgd, lossage;
     struct query def_opts;
     int parsestatus, implicitmode;
-    char *servername, *user, *home, *tmpdir, tmpbuf[BUFSIZ]; 
+    char *user, *home, *tmpdir, tmpbuf[BUFSIZ]; 
     struct passwd *pw;
     FILE       *lockfp;
     pid_t pid;
@@ -134,7 +136,7 @@ char **argv;
     if (prc_parse_file(rcfile) != 0)
        exit(PS_SYNTAX);
 
-    if (implicitmode = (optind >= argc))
+    if ((implicitmode = (optind >= argc)))
     {
        for (ctl = querylist; ctl; ctl = ctl->next)
            ctl->active = TRUE;
@@ -565,7 +567,7 @@ struct query *ctl;
     }
 }
 
-int dump_params (ctl)
+void dump_params (ctl)
 /* display query parameters in English */
 struct query *ctl;     /* query parameter block */
 {
index 34df7079ca0fa212adcaaca5c3e8b6f703a4da1a..2ceec1d8d2a7f68261b10745306c9e342571f77a 100644 (file)
@@ -155,6 +155,7 @@ int gen_transact ();
 void *xmalloc(int);
 char *xstrdup(char *);
 
+int do_protocol(struct query *, const struct method *);
 int doPOP2 (struct query *); 
 int doPOP3 (struct query *);
 int doIMAP (struct query *);
@@ -177,10 +178,21 @@ int parsecmdline (int, char **, struct query *);
 void optmerge(struct query *, struct query *);
 char *MD5Digest (char *);
 int openmailpipe (char **);
+int closemailpipe(int);
 int daemonize(const char *, void (*)(int));
 
+int prc_parse_file(const char *);
+int prc_filecheck(const char *);
+void prc_register();
+void prc_reset();
+
+char *getpassword(char *);
+
 void escapes(const char *, char *);
 
+void yyerror(const char *);
+int yylex();
+
 #else
 
 struct query *hostinit(); 
index ae6393285bd685a3e786d50291505837e275ea4b..e67ba670168e9147ecb38abba80ffa111f699dbb 100644 (file)
--- a/getpass.c
+++ b/getpass.c
 #include <config.h>
 #include <stdio.h>
 #include <signal.h>
+#include <fcntl.h>
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
 
 extern int optind;
 
diff --git a/imap.c b/imap.c
index fbacc3cb23ba7b0c783e5cac4cbe25d7c271a630..1b2d847d59a2a808eecdd76631f621eb99da05aa 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -9,6 +9,10 @@
 #include  <config.h>
 #include  <stdio.h>
 #include  <string.h>
+#include  <ctype.h>
+#if defined(STDC_HEADERS)
+#include  <stdlib.h>
+#endif
 #include  "socket.h"
 #include  "fetchmail.h"
 
@@ -19,10 +23,7 @@ int imap_ok (socket, argbuf)
 char *argbuf;
 int socket;
 {
-    int ok;
     char buf [POPBUFSIZE+1];
-    char *bufp;
-    int n;
 
     seen = 0;
     do {
@@ -83,7 +84,7 @@ char *buf;
                  ctl->remotename, ctl->password));
 }
 
-static imap_getrange(socket, ctl, countp, newp)
+static int imap_getrange(socket, ctl, countp, newp)
 /* get range of messages to be fetched */
 int socket;
 struct query *ctl;
@@ -137,13 +138,12 @@ int       *sizes;
     return(0);
 }
 
-static imap_is_old(socket, ctl, num)
+static int imap_is_old(socket, ctl, num)
 /* is the given message old? */
 int socket;
 struct query *ctl;
 int num;
 {
-    char buf [POPBUFSIZE+1];
     int ok;
 
     if ((ok = gen_transact(socket, "FETCH %d FLAGS", num)) != 0)
@@ -176,7 +176,7 @@ int *lenp;
        return(0);
 }
 
-static imap_trail(socket, ctl, number)
+static int imap_trail(socket, ctl, number)
 /* discard tail of FETCH response after reading message text */
 int socket;
 struct query *ctl;
@@ -190,7 +190,7 @@ int number;
        return(0);
 }
 
-static imap_delete(socket, ctl, number)
+static int imap_delete(socket, ctl, number)
 /* set delete flag for given message */
 int socket;
 struct query *ctl;
index 110af649c8b83b70556faa1892d07168ba09268e..f508849f09b96d695d32d90461ea62cf785e99dc 100644 (file)
--- a/options.c
+++ b/options.c
@@ -7,6 +7,10 @@
 #include <config.h>
 #include <stdio.h>
 #include <pwd.h>
+#include <string.h>
+#if defined(STDC_HEADERS)
+#include  <stdlib.h>
+#endif
 
 #include "getopt.h"
 #include "fetchmail.h"
diff --git a/pop2.c b/pop2.c
index 208a3f210ad29fc097fed525bf893e683ce47e36..e1804660a3a18e4db4ed21b140cda52b706613dc 100644 (file)
--- a/pop2.c
+++ b/pop2.c
@@ -8,6 +8,9 @@
 
 #include  <config.h>
 #include  <stdio.h>
+#if defined(STDC_HEADERS)
+#include <stdlib.h>
+#endif
 #include  "socket.h"
 #include  "fetchmail.h"
 
@@ -63,7 +66,7 @@ char *buf;
                  ctl->remotename, ctl->password));
 }
 
-static pop2_getrange(socket, ctl, countp, newp)
+static int pop2_getrange(socket, ctl, countp, newp)
 /* get range of messages to be fetched */
 int socket;
 struct query *ctl;
@@ -112,7 +115,7 @@ int *lenp;
     return(ok);
 }
 
-static pop2_trail(socket, ctl, number)
+static int pop2_trail(socket, ctl, number)
 /* send acknowledgement for message data */
 int socket;
 struct query *ctl;
diff --git a/pop3.c b/pop3.c
index a52838afab1d0e9a9abed0726438986635b4bf29..30430afb43bcf6353ed530dd5384fa7b56c54f99 100644 (file)
--- a/pop3.c
+++ b/pop3.c
@@ -7,6 +7,13 @@
 #include  <config.h>
 #include  <stdio.h>
 #include  <string.h>
+#include  <ctype.h>
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#if defined(STDC_HEADERS)
+#include  <stdlib.h>
+#endif
  
 #include  "socket.h"
 #include  "fetchmail.h"
@@ -60,8 +67,6 @@ int socket;
 struct query *ctl;
 char *greeting;
 {
-    char buf [POPBUFSIZE+1];
-
     /* build MD5 digest from greeting timestamp + password */
     if (ctl->protocol == P_APOP) 
     {
@@ -117,7 +122,7 @@ char *greeting;
     return(0);
 }
 
-static pop3_getrange(socket, ctl, countp, newp)
+static int pop3_getrange(socket, ctl, countp, newp)
 /* get range of messages to be fetched */
 int socket;
 struct query *ctl;
@@ -255,7 +260,7 @@ int *lenp;
     return(0);
 }
 
-static pop3_delete(socket, ctl, number)
+static int pop3_delete(socket, ctl, number)
 /* delete a given message */
 int socket;
 struct query *ctl;
index 6c71aedf7a8abe092a859a7dd0a08cd1f8655c05..1653826f05a58c802733534b464091af2152dcf1 100644 (file)
@@ -72,14 +72,14 @@ options             {/* EMPTY */}
 
                        yytext[strlen(yytext)-1] = '\0';
                        escapes(yytext+1, buf);
-                       yylval.sval = (char *) strdup(buf);
+                       yylval.sval = (char *) xstrdup(buf);
                        return STRING;
                }
 [^;:, \t\r\n]+ {
                        char buf[POPBUFSIZE];
 
                        escapes(yytext, buf);
-                       yylval.sval = (char *) strdup(buf);
+                       yylval.sval = (char *) xstrdup(buf);
                        return STRING;
                }
 
index b4c26ce8716075e6c3f68a7f437f91e63d145580..62ca5ef02003c114903a7e148dea867a6ce2ed65 100644 (file)
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <errno.h>
+#if defined(STDC_HEADERS)
+#include <stdlib.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <string.h>
+
 #include "fetchmail.h"
 
 struct query cmd_opts; /* where to put command-line info */
@@ -139,9 +147,9 @@ extern FILE *yyin;
 
 static struct query *hosttail; /* where to add new elements */
 
-int yyerror (s)
+void yyerror (s)
 /* report a syntax error */
-char *s;       /* error string */
+const char *s; /* error string */
 {
   fprintf(stderr,"%s line %d: %s at %s\n", rcfile, prc_lineno, s, yytext);
   prc_errflag++;
@@ -149,7 +157,7 @@ char *s;    /* error string */
 
 int prc_filecheck(pathname)
 /* check that a configuration file is secure */
-char *pathname;                /* pathname for the configuration file */
+const char *pathname;          /* pathname for the configuration file */
 {
     struct stat statbuf;
 
@@ -186,9 +194,9 @@ char *pathname;             /* pathname for the configuration file */
     return(0);
 }
 
-prc_parse_file (pathname)
+int prc_parse_file (pathname)
 /* digest the configuration into a linked list of host records */
-char *pathname;                /* pathname for the configuration file */
+const char *pathname;          /* pathname for the configuration file */
 {
     prc_errflag = 0;
     querylist = hosttail = (struct query *)NULL;
@@ -217,7 +225,7 @@ char *pathname;             /* pathname for the configuration file */
        return(0);
 }
 
-prc_reset()
+void prc_reset()
 /* clear the global current record (server parameters) used by the parser */
 {
     char       savename[HOSTLEN+1];
@@ -262,7 +270,7 @@ struct query *init; /* pointer to block containing initial values */
     return(node);
 }
 
-int prc_register()
+void prc_register()
 /* register current parameters and append to the host list */
 {
 #define STR_FORCE(fld, len) if (cmd_opts.fld[0]) \
@@ -295,8 +303,6 @@ void optmerge(h2, h1)
 struct query *h1;
 struct query *h2;
 {
-    struct idlist *idp;
-
     append_uid_list(&h2->localnames, &h1->localnames);
 
 #define STR_MERGE(fld, len) if (*(h2->fld) == '\0') strcpy(h2->fld, h1->fld)
index 1e209cacadc534888e1a86a97d28da42628a2f30..ba281a319a5f5954344090665fb7af4f256105c1 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -9,6 +9,7 @@
 
 #include <config.h>
 
+#include <stdio.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -70,36 +71,13 @@ int clientPort;
     return sock;
 }
 
-int SockGets(socket,buf,len)
-int socket;
-char *buf;
-int len;
-{
-    int rdlen = 0;
-    RETSIGTYPE (*sigsave)();
-
-    while (--len)
-    {
-        if (SockInternalRead(socket, buf, 1) != 1)
-            return -1;
-        else
-           rdlen++;
-        if (*buf == '\n')
-            break;
-        if (*buf != '\r') /* remove all CRs */
-            buf++;
-    }
-    *buf = 0;
-    return rdlen;
-}
-
 int SockPuts(socket,buf)
 int socket;
 char *buf;
 {
     int rc;
     
-    if (rc = SockWrite(socket, buf, strlen(buf)))
+    if ((rc = SockWrite(socket, buf, strlen(buf))) != 0)
         return rc;
     return SockWrite(socket, "\r\n", 2);
 }
@@ -122,28 +100,9 @@ int len;
     return 0;
 }
 
-int SockRead(socket,buf,len)
-int socket;
-char *buf;
-int len;
-{
-    int n;
-    
-    
-    while (len)
-    {
-        n = SockInternalRead(socket, buf, len);
-        if (n <= 0)
-            return -1;
-        len -= n;
-        buf += n;
-    }
-    return 0;
-}
-
 static int sbuflen = 0;
 
-int SockInternalRead (socket,buf,len)
+static int SockInternalRead (socket,buf,len)
 int socket;
 char *buf;
 int len;
@@ -154,7 +113,7 @@ int len;
    if (sbuflen <= 0) {
      /* buffer is empty; refresh. */
      if ((sbuflen = read(socket,sbuf,INTERNAL_BUFSIZE)) < 0) {
-       if (errno = EINTR)
+       if (errno == EINTR)
            return -1;
        perror("SockInternalRead: read");
        exit(9);
@@ -188,36 +147,47 @@ int len;
    return(len);
 }
 
-/* SockClearHeader: call this procedure in order to kill off any
-   forthcoming Header info from the socket that we no longer want.
-   */
-int SockClearHeader(socket)
+int SockRead(socket,buf,len)
 int socket;
+char *buf;
+int len;
 {
-   char *bufp;
-   static char sbuf[INTERNAL_BUFSIZE];
-   int nBytes;
-   int res;
+    int n;
+    
+    
+    while (len)
+    {
+        n = SockInternalRead(socket, buf, len);
+        if (n <= 0)
+            return -1;
+        len -= n;
+        buf += n;
+    }
+    return 0;
+}
 
-   if ((res = SockDataWaiting(socket))  <= 0)
-     return res;
+int SockGets(socket,buf,len)
+int socket;
+char *buf;
+int len;
+{
+    int rdlen = 0;
 
-   while (1) 
-     {
-        if (SockGets(socket,sbuf,INTERNAL_BUFSIZE) < 0)
-         return 0;
-       bufp = sbuf;
-       if (*bufp == '.') {
-         bufp++;
-         if (*bufp == 0)
-           break;
-       }
-     }
-   sbuflen = 0;
-   return 0;
+    while (--len)
+    {
+        if (SockInternalRead(socket, buf, 1) != 1)
+            return -1;
+        else
+           rdlen++;
+        if (*buf == '\n')
+            break;
+        if (*buf != '\r') /* remove all CRs */
+            buf++;
+    }
+    *buf = 0;
+    return rdlen;
 }
 
-
 /* SockDataWaiting: Return a non-zero value if this socket is waiting
   for data.   */
 int  SockDataWaiting(int socket)
@@ -245,6 +215,36 @@ int  SockDataWaiting(int socket)
   fcntl(socket,F_SETFL,flags);
   return res;
 }
+
+
+/* SockClearHeader: call this procedure in order to kill off any
+   forthcoming Header info from the socket that we no longer want.
+   */
+int SockClearHeader(socket)
+int socket;
+{
+   char *bufp;
+   static char sbuf[INTERNAL_BUFSIZE];
+   int res;
+
+   if ((res = SockDataWaiting(socket)) <= 0)
+     return res;
+
+   while (1) 
+     {
+        if (SockGets(socket,sbuf,INTERNAL_BUFSIZE) < 0)
+         return 0;
+       bufp = sbuf;
+       if (*bufp == '.') {
+         bufp++;
+         if (*bufp == 0)
+           break;
+       }
+     }
+   sbuflen = 0;
+   return 0;
+}
+
 #if defined(HAVE_STDARG_H)
 int SockPrintf(int socket, char* format, ...)
 {
diff --git a/uid.c b/uid.c
index 84311727b869b8fe7ba6abdb76bef9840b074507..25730390827514deb2af103716e7a9e9930647c2 100644 (file)
--- a/uid.c
+++ b/uid.c
@@ -249,7 +249,7 @@ void write_saved_lists(hostlist, idfile)
 struct query *hostlist;
 char *idfile;
 {
-    int        st, idcount;
+    int                idcount;
     FILE       *tmpfp;
     struct query *hostp;
     struct idlist *idp;
index 6fab5be1096d36966a65569c55041d5196c19eba..10b3d7e13d9bb73e7209f08eaf60b76a701861f3 100644 (file)
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -8,6 +8,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
+#if defined(STDC_HEADERS)
+#include  <stdlib.h>
+#endif
 #include "fetchmail.h"
 
 #if defined(HAVE_VOIDPOINTER)