diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-10-26 22:21:16 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-10-26 22:21:16 +0000 |
commit | eabdfb5e1ebf83147017c57db3659e7b2e8ecad1 (patch) | |
tree | 338308dc0519869dd03d3ae33071d3ef6fa8cd67 | |
parent | d59e69783b91feb5d3ee5d2ba802c279ecf021c5 (diff) | |
download | fetchmail-eabdfb5e1ebf83147017c57db3659e7b2e8ecad1.tar.gz fetchmail-eabdfb5e1ebf83147017c57db3659e7b2e8ecad1.tar.bz2 fetchmail-eabdfb5e1ebf83147017c57db3659e7b2e8ecad1.zip |
gcc -Wall cleanup.
svn path=/trunk/; revision=396
-rw-r--r-- | daemon.c | 7 | ||||
-rw-r--r-- | driver.c | 22 | ||||
-rw-r--r-- | fetchmail.c | 14 | ||||
-rw-r--r-- | fetchmail.h | 12 | ||||
-rw-r--r-- | getpass.c | 4 | ||||
-rw-r--r-- | imap.c | 16 | ||||
-rw-r--r-- | options.c | 4 | ||||
-rw-r--r-- | pop2.c | 7 | ||||
-rw-r--r-- | pop3.c | 13 | ||||
-rw-r--r-- | rcfile_l.l | 4 | ||||
-rw-r--r-- | rcfile_y.y | 24 | ||||
-rw-r--r-- | socket.c | 138 | ||||
-rw-r--r-- | uid.c | 2 | ||||
-rw-r--r-- | xmalloc.c | 3 |
14 files changed, 158 insertions, 112 deletions
@@ -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> @@ -20,6 +21,10 @@ # 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 */ @@ -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"); } } diff --git a/fetchmail.c b/fetchmail.c index 9a0e38e6..f912cad9 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -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 */ { diff --git a/fetchmail.h b/fetchmail.h index 34df7079..2ceec1d8 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -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(); @@ -13,6 +13,10 @@ #include <config.h> #include <stdio.h> #include <signal.h> +#include <fcntl.h> +#if defined(HAVE_UNISTD_H) +#include <unistd.h> +#endif extern int optind; @@ -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; @@ -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" @@ -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; @@ -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; @@ -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; } @@ -12,6 +12,14 @@ #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) @@ -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, ...) { @@ -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; @@ -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) |