X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8d5ea13e4ebdda303739921ede230ac4f7ec7d7d..6015bb1f7:/uip/slocal.c?ds=sidebyside diff --git a/uip/slocal.c b/uip/slocal.c index da879acf..e136f101 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -172,9 +172,9 @@ static int usr_folder (int, char *); static void alrmser (int); static void get_sender (char *, char **); static int copy_message (int, char *, int); -static void verbose_printf (char *fmt, ...); -static void adorn (char *, char *, ...); -static void debug_printf (char *fmt, ...); +static void verbose_printf (char *fmt, ...) CHECK_PRINTF(1, 2); +static void adorn (char *, char *, ...) CHECK_PRINTF(2, 3); +static void debug_printf (char *fmt, ...) CHECK_PRINTF(1, 2); static int suppress_duplicates (int, char *); static char *trim (char *); @@ -713,7 +713,7 @@ parse (int fd) char name[NAMESZ], field[NMH_BUFSIZ]; struct pair *p, *q; FILE *in; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if (parsed++) return 0; @@ -737,15 +737,16 @@ parse (int fd) * Scan the headers of the message and build * a lookup table. */ + gstate = m_getfld_state_init(in); for (i = 0;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: lp = mh_xstrdup(field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, in); + state = m_getfld2(&gstate, name, field, &fieldsz); lp = add (field, lp); } for (p = hdrs; p->p_name; p++) { @@ -786,7 +787,7 @@ parse (int fd) break; default: - inform("internal error in m_getfld"); + inform("internal error in m_getfld2"); fclose (in); return -1; } @@ -801,12 +802,12 @@ parse (int fd) p->p_value = getcpy (q ? q->p_value : ""); p->p_flags &= ~P_CHK; if (debug) - debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("vars[%ld]: name=\"%s\" value=\"%s\"\n", p - vars, p->p_name, trim(p->p_value)); } if (debug) { for (p = hdrs; p->p_name; p++) - debug_printf ("hdrs[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("hdrs[%ld]: name=\"%s\" value=\"%s\"\n", p - hdrs, p->p_name, p->p_value ? trim(p->p_value) : ""); } @@ -886,7 +887,7 @@ glob (int fd) if (debug) { for (p = vars; p->p_name; p++) - debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("vars[%ld]: name=\"%s\" value=\"%s\"\n", p - vars, p->p_name, trim(p->p_value)); } } @@ -985,7 +986,7 @@ usr_file (int fd, char *mailbox, int mbx_style) return -1; } - lseek (fd, (off_t) 0, SEEK_SET); + lseek(fd, 0, SEEK_SET); /* append message to file */ if (mbx_copy (mailbox, mbx_style, md, fd, NULL) == -1) { @@ -1051,7 +1052,7 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) if (verbose && !suppress) verbose_printf ("delivering to pipe \"%s\"", cmd); - lseek (fd, (off_t) 0, SEEK_SET); + lseek(fd, 0, SEEK_SET); for (i = 0; (child_id = fork()) == -1 && i < 5; i++) sleep (5); @@ -1117,11 +1118,10 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) if (verbose) { if (status == 0) verbose_printf (", success.\n"); - else - if ((status & 0xff00) == 0xff00) - verbose_printf (", system error\n"); - else - pidstatus (status, stdout, ", failed"); + else if ((status & 0xff00) == 0xff00) + verbose_printf (", system error\n"); + else + pidstatus (status, stdout, ", failed"); } return (status == 0 ? 0 : -1); } @@ -1212,7 +1212,7 @@ you_lose: } if (i == -1) goto you_lose; - lseek (fd1, (off_t) 0, SEEK_SET); + lseek(fd1, 0, SEEK_SET); return fd1; } @@ -1277,7 +1277,7 @@ you_lose: return -1; } fclose (qfp); - lseek (fd1, (off_t) 0, SEEK_SET); + lseek(fd1, 0, SEEK_SET); return fd1; @@ -1405,7 +1405,7 @@ suppress_duplicates (int fd, char *file) datum key, value; DBM *db; FILE *in; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; if ((fd1 = dup (fd)) == -1) return -1; @@ -1415,10 +1415,11 @@ suppress_duplicates (int fd, char *file) } rewind (in); + gstate = m_getfld_state_init(in); for (;;) { int failed_to_lock = 0; int bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); switch (state) { case FLD: case FLDPLUS: @@ -1426,7 +1427,7 @@ suppress_duplicates (int fd, char *file) if (strcasecmp (name, "Message-ID")) { while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); } continue; } @@ -1434,7 +1435,7 @@ suppress_duplicates (int fd, char *file) cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; - state = m_getfld (&gstate, name, buf, &bufsz, in); + state = m_getfld2(&gstate, name, buf, &bufsz); cp = add (buf, cp); } key.dptr = trimcpy (cp);