From b067ff5c465a5d243ce5a19e562085a9a1a97215 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Fri, 7 Oct 2011 10:41:15 +0200 Subject: [PATCH] Removed unneeded sbr code. memmove() and strerror() removed again. ;-) Mmh takes C89, at least, for available. --- configure.ac | 2 +- h/addrsbr.h | 4 +- h/mf.h | 5 -- h/prototypes.h | 4 - sbr/Makefile.in | 11 +-- sbr/addrsbr.c | 64 +------------- sbr/client.c | 207 ---------------------------------------------- sbr/discard.c | 1 - sbr/ext_hook.c | 8 +- sbr/fmt_rfc2047.c | 3 +- sbr/m_getfld.c | 1 - sbr/m_scratch.c | 40 --------- sbr/m_tmpfil.c | 32 ------- sbr/memmove.c | 12 --- sbr/mf.c | 239 ++++------------------------------------------------- sbr/remdir.c | 23 ------ sbr/snprintf.c | 39 ++++++--- sbr/strcasecmp.c | 20 ----- sbr/strerror.c | 18 ---- sbr/utils.c | 6 +- uip/rmf.c | 10 ++- 21 files changed, 64 insertions(+), 685 deletions(-) delete mode 100644 sbr/client.c delete mode 100644 sbr/m_scratch.c delete mode 100644 sbr/m_tmpfil.c delete mode 100644 sbr/memmove.c delete mode 100644 sbr/remdir.c delete mode 100644 sbr/strerror.c diff --git a/configure.ac b/configure.ac index e9d2354..6a37f2f 100644 --- a/configure.ac +++ b/configure.ac @@ -395,7 +395,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [Define to 1 if you have the `sigsetjmp'.]) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) -AC_REPLACE_FUNCS(memmove snprintf strerror strdup) +AC_REPLACE_FUNCS(snprintf strdup) dnl Look for the initgroups() declaration. On AIX 4.[13], Solaris 4.1.3, and dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in diff --git a/h/addrsbr.h b/h/addrsbr.h index 9aaabd5..7c997f6 100644 --- a/h/addrsbr.h +++ b/h/addrsbr.h @@ -26,7 +26,6 @@ struct mailname { char *m_note; }; -#define adrformat(m) auxformat ((m), 1) /* * prototypes @@ -34,6 +33,5 @@ struct mailname { void mnfree(struct mailname *); int ismymbox(struct mailname *); char *getname(char *); -char *adrsprintf(char *, char *); -char *auxformat(struct mailname *, int); +char *adrformat(struct mailname *); struct mailname *getm(char *, char *, int, int, char *); diff --git a/h/mf.h b/h/mf.h index b84a626..7fd5ef5 100644 --- a/h/mf.h +++ b/h/mf.h @@ -68,10 +68,5 @@ struct adrx { /* * prototypes */ -int isfrom(char *); -int lequal (unsigned char *, unsigned char *); -int mfgets (FILE *, char **); char *legal_person (char *); -struct adrx *seekadrx (char *); struct adrx *getadrx (char *); -struct adrx *uucpadrx (char *); diff --git a/h/prototypes.h b/h/prototypes.h index 5ddd467..4907410 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -30,7 +30,6 @@ void ambigsw (char *, struct swit *); int atooi(char *); char **brkstring (char *, char *, char *); int check_charset (char *, int); -int client(char *, char *, char *, int, int); void closefds(int); char *concat (char *, ...); int context_del (char *); @@ -75,8 +74,6 @@ char *m_maildir (char *); char *m_mailpath (char *); char *m_name (int); int m_putenv (char *, char *); -char *m_scratch (char *, char *); -char *m_tmpfil (char *); char *m_mktemp(const char *, int *, FILE **); char *m_mktemp2(const char *, const char *, int *, FILE **); void m_unknown(FILE *); @@ -98,7 +95,6 @@ char *r1bindex(char *, int); void readconfig (struct node **, FILE *, char *, int); int refile (char **, char *); void ruserpass(char *, char **, char **); -int remdir (char *); int seq_addmsg (struct msgs *, char *, int, int, int); int seq_addsel (struct msgs *, char *, int, int); char *seq_bits (struct msgs *); diff --git a/sbr/Makefile.in b/sbr/Makefile.in index 9e69965..65a6261 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -51,7 +51,7 @@ SIGNAL_H = @SIGNAL_H@ # source for library functions SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c \ - check_charset.c client.c closefds.c concat.c context_del.c \ + check_charset.c closefds.c concat.c context_del.c \ context_find.c context_foil.c context_read.c \ context_replace.c context_save.c copy.c \ copyip.c cpydata.c cpydgst.c crawl_folders.c \ @@ -63,11 +63,11 @@ SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c \ fmt_addr.c fmt_compile.c fmt_new.c fmt_rfc2047.c \ fmt_scan.c lock_file.c m_atoi.c m_backup.c \ m_convert.c m_draft.c m_getfld.c m_gmprot.c \ - m_maildir.c m_name.c m_scratch.c m_tmpfil.c \ + m_maildir.c m_name.c \ makedir.c mts.c norm_charmap.c \ path.c peekc.c pidwait.c pidstatus.c \ print_help.c print_sw.c print_version.c push.c \ - putenv.c refile.c remdir.c r1bindex.c \ + putenv.c refile.c r1bindex.c \ readconfig.c ruserpass.c seq_add.c seq_bits.c \ seq_del.c seq_getnum.c seq_list.c seq_nameok.c \ seq_print.c seq_read.c seq_save.c seq_setcur.c \ @@ -77,7 +77,7 @@ SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c \ m_msgdef.c mf.c utils.c m_mktemp.c # source for compatibility functions -COMPAT = memmove.c snprintf.c strdup.c strerror.c +COMPAT = snprintf.c strdup.c OBJS = $(SRCS:.c=.o) $(LIBOBJS) @@ -105,9 +105,6 @@ lint: sigmsg.h dtimep.c: dtimep.lex $(LEX) -n -t $(srcdir)/dtimep.lex > dtimep.c -client.o: client.c - $(COMPILE2) $(srcdir)/client.c - mts.o: mts.c $(COMPILE2) $(srcdir)/mts.c diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index 4ab3fec..d8f6a12 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -262,7 +262,7 @@ mnfree (struct mailname *mp) #define empty(s) ((s) ? (s) : "") char * -auxformat (struct mailname *mp, int extras) +adrformat (struct mailname *mp) { static char addr[BUFSIZ]; static char buffer[BUFSIZ]; @@ -281,9 +281,6 @@ auxformat (struct mailname *mp, int extras) #endif /* not BANG */ snprintf (addr, sizeof(addr), "%s!%s", mp->m_host, mp->m_mbox); - if (!extras) - return addr; - if (mp->m_pers || mp->m_path) { if (mp->m_note) snprintf (buffer, sizeof(buffer), "%s %s <%s>", @@ -302,65 +299,6 @@ auxformat (struct mailname *mp, int extras) } -/* - * address specific "sprintf" - */ - -char * -adrsprintf (char *username, char *domain) -{ - int snprintf_return; - static char addr[BUFSIZ]; - - if (username == NULL) - username = getusername(); - - if (username_extension_masquerading) { - /* mts.conf contains "masquerade:[...]username_extension[...]", - * so tack on the value of the $USERNAME_EXTENSION environment - * variable, if set, to username. - */ - char* extension = getenv("USERNAME_EXTENSION"); - static char username_with_extension[BUFSIZ]; - - if (extension != NULL && *extension != '\0') { - snprintf_return = snprintf(username_with_extension, - sizeof(username_with_extension), - "%s%s", username, extension); - - if (snprintf_return < 0 || - snprintf_return >= sizeof(username_with_extension)) - adios(NULL, "snprintf() error writing username (%d chars) and" - " $USERNAME_EXTENSION (%d chars) to array of BUFSIZ (%d)" - " chars", - strlen(username), strlen(extension), BUFSIZ); - - username = username_with_extension; - } - } - -#ifdef REALLYDUMB - return username; -#endif - - if (domain == NULL) - domain = LocalName(); - -#ifndef BANG - snprintf_return = snprintf (addr, sizeof(addr), "%s@%s", username, domain); -#else /* BANG */ - snprintf_return = snprintf (addr, sizeof(addr), "%s!%s", domain, username); -#endif /* BANG */ - - if (snprintf_return < 0 || snprintf_return >= sizeof(addr)) - adios(NULL, "snprintf() error writing username (%d chars), domain (%d" - " chars), and 1 separator char to array of BUFSIZ (%d) chars", - strlen(username), strlen(domain), BUFSIZ); - - return addr; -} - - #define W_NIL 0x0000 #define W_MBEG 0x0001 #define W_MEND 0x0002 diff --git a/sbr/client.c b/sbr/client.c deleted file mode 100644 index 0dd4a67..0000000 --- a/sbr/client.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * client.c -- connect to a server - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ - -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#define TRUE 1 -#define FALSE 0 - -#define MAXARGS 1000 - -/* - * static prototypes - */ - -/* client's own static version of several nmh subroutines */ -static char **client_brkstring (char *, char *, char *); -static int client_brkany (char, char *); -static char **client_copyip (char **, char **, int); -static char *client_getcpy (char *); -static void client_freelist(char **); - - -int -client (char *args, char *service, char *response, int len_response, int debug) -{ - int sd, rc; - char **ap, *arguments[MAXARGS]; - struct addrinfo hints, *res, *ai; - - ap = arguments; - if (args != NULL && *args != 0) { - ap = client_copyip (client_brkstring (client_getcpy (args), " ", "\n"), - ap, MAXARGS); - } - if (ap == arguments) { - *ap++ = client_getcpy ("localhost"); - *ap = NULL; - } - - memset(&hints, 0, sizeof(hints)); -#ifdef AI_ADDRCONFIG - hints.ai_flags = AI_ADDRCONFIG; -#endif - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - - for (ap = arguments; *ap; ap++) { - - if (debug) { - fprintf(stderr, "Trying to connect to \"%s\" ...\n", *ap); - } - - rc = getaddrinfo(*ap, service, &hints, &res); - - if (rc) { - if (debug) { - fprintf(stderr, "Lookup of \"%s\" failed: %s\n", *ap, - gai_strerror(rc)); - } - continue; - } - - for (ai = res; ai != NULL; ai = ai->ai_next) { - if (debug) { - char address[NI_MAXHOST]; - - rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, address, - sizeof(address), NULL, 0, NI_NUMERICHOST); - - fprintf(stderr, "Connecting to %s...\n", - rc ? "unknown" : address); - } - - sd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - - if (sd < 0) { - if (debug) - fprintf(stderr, "socket() failed: %s\n", strerror(errno)); - continue; - } - - if (connect(sd, ai->ai_addr, ai->ai_addrlen) == 0) { - freeaddrinfo(res); - client_freelist(ap); - return sd; - } - - if (debug) { - fprintf(stderr, "Connection failed: %s\n", strerror(errno)); - } - - close(sd); - } - - freeaddrinfo(res); - } - - client_freelist(ap); - strncpy (response, "no servers available", len_response); - return NOTOK; -} - - -/* - * Free a list of strings - */ - -static void -client_freelist(char **list) -{ - while (*list++ != NULL) - free(*list); -} - - -/* - * static copies of three nmh subroutines - */ - -static char *broken[MAXARGS + 1]; - -static char ** -client_brkstring (char *strg, char *brksep, char *brkterm) -{ - register int bi; - register char c, *sp; - - sp = strg; - - for (bi = 0; bi < MAXARGS; bi++) { - while (client_brkany (c = *sp, brksep)) - *sp++ = 0; - if (!c || client_brkany (c, brkterm)) { - *sp = 0; - broken[bi] = 0; - return broken; - } - - broken[bi] = sp; - while ((c = *++sp) && !client_brkany (c, brksep) && !client_brkany (c, brkterm)) - continue; - } - broken[MAXARGS] = 0; - - return broken; -} - - -/* - * returns 1 if chr in strg, 0 otherwise - */ -static int -client_brkany (char chr, char *strg) -{ - register char *sp; - - if (strg) - for (sp = strg; *sp; sp++) - if (chr == *sp) - return 1; - return 0; -} - - -/* - * copy a string array and return pointer to end - */ -static char ** -client_copyip (char **p, char **q, int len_q) -{ - while (*p && --len_q > 0) - *q++ = *p++; - - *q = NULL; - - return q; -} - - -static char * -client_getcpy (char *str) -{ - char *cp; - size_t len; - - len = strlen(str) + 1; - cp = mh_xmalloc(len); - - memcpy (cp, str, len); - return cp; -} - diff --git a/sbr/discard.c b/sbr/discard.c index 21fc88f..496bb7a 100644 --- a/sbr/discard.c +++ b/sbr/discard.c @@ -63,4 +63,3 @@ discard (FILE *io) # endif #endif } - diff --git a/sbr/ext_hook.c b/sbr/ext_hook.c index 5ff9394..8986c03 100644 --- a/sbr/ext_hook.c +++ b/sbr/ext_hook.c @@ -3,8 +3,8 @@ * name of the hook to use, the second is the full path name of a mail message. * The third argument is also the full path name of a mail message, or a NULL * pointer if it isn't needed. Look in the context for an error message if - * something goes wrong; there is a built-in message in case one isn't specified. - * Only produce the error message once. + * something goes wrong; there is a built-in message in case one isn't + * specified. Only produce the error message once. */ #include @@ -53,8 +53,6 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2) } return (NOTOK); - } - - else + } else return (OK); } diff --git a/sbr/fmt_rfc2047.c b/sbr/fmt_rfc2047.c index 92e168b..debc81e 100644 --- a/sbr/fmt_rfc2047.c +++ b/sbr/fmt_rfc2047.c @@ -347,7 +347,8 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) return encoding_found; buffull: - /* q is currently just off the end of the buffer, so rewind to NUL terminate */ + /* q is currently just off the end of the buffer, + * so rewind to NUL terminate */ q--; *q = '\0'; return encoding_found; diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 97b2466..f2c2ffa 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -814,4 +814,3 @@ locc(int cnt, unsigned char *src, unsigned char term) return (cnt > 0 ? --src : (unsigned char *)0); } - diff --git a/sbr/m_scratch.c b/sbr/m_scratch.c deleted file mode 100644 index a929419..0000000 --- a/sbr/m_scratch.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * m_scratch.c -- construct a scratch file - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ - -#include - -/*************************************************************************** - * DO NOT USE THIS FUNCTION! IT WILL BE REMOVED IN THE FUTURE. - * THIS FUNCTION IS INSECURE. USE THE FUNCTIONS DEFINED IN m_mktemp.c. - ***************************************************************************/ -char * -m_scratch (char *file, char *template) -{ - char *cp; - static char buffer[BUFSIZ], tmpfil[BUFSIZ]; - - snprintf (tmpfil, sizeof(tmpfil), "%sXXXXXX", template); -/* - * Mkstemp work postponed until later -Doug - * #ifdef HAVE_MKSTEMP - * mkstemp (tmpfil); - * #else - */ - mktemp (tmpfil); -/* - * #endif - */ - /* nasty - this really means: if there is no '/' in the path */ - if ((cp = r1bindex (file, '/')) == file) - strncpy (buffer, tmpfil, sizeof(buffer)); - else - snprintf (buffer, sizeof(buffer), "%.*s%s", (int)(cp - file), file, tmpfil); - unlink (buffer); - - return buffer; -} diff --git a/sbr/m_tmpfil.c b/sbr/m_tmpfil.c deleted file mode 100644 index c0a60bc..0000000 --- a/sbr/m_tmpfil.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * m_tmpfil.c -- construct a temporary file - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ - -#include - -/*************************************************************************** - * DO NOT USE THIS FUNCTION! IT WILL BE REMOVED IN THE FUTURE. - * THIS FUNCTION IS INSECURE. USE THE FUNCTIONS DEFINED IN m_mktemp.c. - ***************************************************************************/ -char * -m_tmpfil (char *template) -{ - static char tmpfil[BUFSIZ]; - - snprintf (tmpfil, sizeof(tmpfil), "/tmp/%sXXXXXX", template); -/* - * Mkstemp work postponed until later -Doug - * #ifdef HAVE_MKSTEMP - * unlink(mkstemp(tmpfil)); - * #else - */ - unlink(mktemp(tmpfil)); -/* - * #endif - */ - return tmpfil; -} diff --git a/sbr/memmove.c b/sbr/memmove.c deleted file mode 100644 index fabe133..0000000 --- a/sbr/memmove.c +++ /dev/null @@ -1,12 +0,0 @@ -/* public domain function from Jan Wolter Unix Incompatibility Notes */ -/* http://unixpapa.com/incnote/ */ -char * -memmove(char *dst, char *src, int n) -{ - if (src > dst) - for ( ; n > 0; n--) - *(dst++)= *(src++); - else - for (dst+= n-1, src+= n-1; n > 0; n--) - *(dst--)= *(src--); -} diff --git a/sbr/mf.c b/sbr/mf.c index 063541b..fdad91e 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -15,7 +15,6 @@ * static prototypes */ static char *getcpy (char *); -static void compress (char *, unsigned char *); static int isat (char *); static int parse_address (void); static int phrase (char *); @@ -32,8 +31,10 @@ getcpy (char *s) register char *p; if (!s) { -/* causes compiles to blow up because the symbol _cleanup is undefined - * where did this ever come from? */ + /* + * causes compiles to blow up because the symbol _cleanup + * is undefined where did this ever come from? + */ /* _cleanup(); */ abort(); for(;;) @@ -45,175 +46,11 @@ getcpy (char *s) } -int -isfrom(char *string) -{ - return (strncmp (string, "From ", 5) == 0 - || strncmp (string, ">From ", 6) == 0); -} - - -int -lequal (unsigned char *a, unsigned char *b) -{ - for (; *a; a++, b++) - if (*b == 0) - return FALSE; - else { - char c1 = islower (*a) ? toupper (*a) : *a; - char c2 = islower (*b) ? toupper (*b) : *b; - if (c1 != c2) - return FALSE; - } - - return (*b == 0); -} - - -/* - * seekadrx() is tricky. We want to cover both UUCP-style and ARPA-style - * addresses, so for each list of addresses we see if we can find some - * character to give us a hint. - */ - - #define CHKADR 0 /* undertermined address style */ #define UNIXDR 1 /* UNIX-style address */ #define ARPADR 2 /* ARPAnet-style address */ -static char *punctuators = ";<>.()[]"; -static char *vp = NULL; -static char *tp = NULL; - -static struct adrx adrxs1; - - -struct adrx * -seekadrx (char *addrs) -{ - static int state = CHKADR; - register char *cp; - register struct adrx *adrxp; - - if (state == CHKADR) - for (state = UNIXDR, cp = addrs; *cp; cp++) - if (strchr(punctuators, *cp)) { - state = ARPADR; - break; - } - - switch (state) { - case UNIXDR: - adrxp = uucpadrx (addrs); - break; - - case ARPADR: - default: - adrxp = getadrx (addrs); - break; - } - - if (adrxp == NULL) - state = CHKADR; - - return adrxp; -} - - -/* - * uucpadrx() implements a partial UUCP-style address parser. It's based - * on the UUCP notion that addresses are separated by spaces or commas. - */ - - -struct adrx * -uucpadrx (char *addrs) -{ - register unsigned char *cp, *wp, *xp, *yp; - register char *zp; - register struct adrx *adrxp = &adrxs1; - - if (vp == NULL) { - vp = tp = getcpy (addrs); - compress (addrs, vp); - } else if (tp == NULL) { - free (vp); - vp = NULL; - return NULL; - } - - for (cp = tp; isspace (*cp); cp++) - continue; - if (*cp == 0) { - free (vp); - vp = tp = NULL; - return NULL; - } - - if ((wp = strchr(cp, ',')) == NULL) { - if ((wp = strchr(cp, ' ')) != NULL) { - xp = wp; - while (isspace (*xp)) - xp++; - if (*xp != 0 && isat (--xp)) { - yp = xp + 4; - while (isspace (*yp)) - yp++; - if (*yp != 0) { - if ((zp = strchr(yp, ' ')) != NULL) - *zp = 0, tp = ++zp; - else - tp = NULL; - } else - *wp = 0, tp = ++wp; - } else - *wp = 0, tp = ++wp; - } else - tp = NULL; - } else - *wp = 0, tp = ++wp; - - if (adrxp->text) - free (adrxp->text); - adrxp->text = getcpy (cp); - adrxp->mbox = cp; - adrxp->host = adrxp->path = NULL; - if ((wp = strrchr(cp, '@')) != NULL) { - *wp++ = 0; - adrxp->host = *wp ? wp : NULL; - } else - for (wp = cp + strlen (cp) - 4; wp >= cp; wp--) - if (isat (wp)) { - *wp++ = 0; - adrxp->host = wp + 3; - } - - adrxp->pers = adrxp->grp = adrxp->note = adrxp->err = NULL; - adrxp->ingrp = 0; - - return adrxp; -} - - -static void -compress (char *fp, unsigned char *tp) -{ - register char c; - register unsigned char *cp; - - for (c = ' ', cp = tp; (*tp = *fp++) != 0;) - if (isspace (*tp)) { - if (c != ' ') - *tp++ = c = ' '; - } else - c = *tp++; - - if (c == ' ' && cp < tp) - *--tp = 0; -} - - static int isat (char *p) { @@ -750,8 +587,16 @@ my_lex (char *buffer) register unsigned char c; register char *bp; -/* Add C to the buffer bp. After use of this macro *bp is guaranteed to be within the buffer. */ -#define ADDCHR(C) do { *bp++ = (C); if ((bp - buffer) == (BUFSIZ-1)) goto my_lex_buffull; } while (0) + /* + * Add C to the buffer bp. After use of this macro *bp is guaranteed + * to be within the buffer. + */ +#define ADDCHR(C) \ + do { \ + *bp++ = (C); \ + if ((bp - buffer) == (BUFSIZ-1)) \ + goto my_lex_buffull; \ + } while (0) bp = buffer; *bp = 0; @@ -898,59 +743,3 @@ legal_person (char *p) return p; } - - -int -mfgets (FILE *in, char **bp) -{ - int i; - register char *cp, *dp, *ep; - static int len = 0; - static char *pp = NULL; - - if (pp == NULL) - pp = mh_xmalloc ((size_t) (len = BUFSIZ)); - - for (ep = (cp = pp) + len - 2;;) { - switch (i = getc (in)) { - case EOF: - eol: ; - if (cp != pp) { - *cp = 0; - *bp = pp; - return OK; - } - eoh: ; - *bp = NULL; - free (pp); - pp = NULL; - return DONE; - - case 0: - continue; - - case '\n': - if (cp == pp) /* end of headers, gobble it */ - goto eoh; - switch (i = getc (in)) { - default: /* end of line */ - case '\n': /* end of headers, save for next call */ - ungetc (i, in); - goto eol; - - case ' ': /* continue headers */ - case '\t': - *cp++ = '\n'; - break; - } /* fall into default case */ - - default: - *cp++ = i; - break; - } - if (cp >= ep) { - dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ)); - cp += dp - pp, ep = (pp = cp) + len - 2; - } - } -} diff --git a/sbr/remdir.c b/sbr/remdir.c deleted file mode 100644 index 397a689..0000000 --- a/sbr/remdir.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * remdir.c -- remove a directory - * - * This code is Copyright (c) 2002, by the authors of nmh. See the - * COPYRIGHT file in the root directory of the nmh distribution for - * complete copyright information. - */ - -#include - - -int -remdir (char *dir) -{ - context_save(); /* save the context file */ - fflush(stdout); - - if (rmdir(dir) == -1) { - admonish (dir, "unable to remove directory"); - return 0; - } - return 1; -} diff --git a/sbr/snprintf.c b/sbr/snprintf.c index 9bc163a..2b19881 100644 --- a/sbr/snprintf.c +++ b/sbr/snprintf.c @@ -135,7 +135,8 @@ typedef int bool_int; #define NDIG 80 /* buf must have at least NDIG bytes */ -static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf) +static char * +ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf) { register int r2; double fi, fj; @@ -207,12 +208,14 @@ static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, c return (buf); } -static char *ap_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf) +static char * +ap_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf) { return (ap_cvt(arg, ndigits, decpt, sign, 1, buf)); } -static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) +static char * +ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) { return (ap_cvt(arg, ndigits, decpt, sign, 0, buf)); } @@ -222,7 +225,8 @@ static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) * minimal length string */ -static char *ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) +static char * +ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) { int sign, decpt; register char *p1, *p2; @@ -357,7 +361,8 @@ static char *ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) * which is a pointer to the END of the buffer + 1 (i.e. if the buffer * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) */ -static char *conv_10(register wide_int num, register bool_int is_unsigned, +static char * +conv_10(register wide_int num, register bool_int is_unsigned, register bool_int *is_negative, char *buf_end, register int *len) { @@ -404,7 +409,8 @@ static char *conv_10(register wide_int num, register bool_int is_unsigned, -static char *conv_in_addr(struct in_addr *ia, char *buf_end, int *len) +static char * +conv_in_addr(struct in_addr *ia, char *buf_end, int *len) { unsigned addr = ntohl(ia->s_addr); char *p = buf_end; @@ -425,7 +431,8 @@ static char *conv_in_addr(struct in_addr *ia, char *buf_end, int *len) -static char *conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len) +static char * +conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len) { char *p = buf_end; bool_int is_negative; @@ -447,7 +454,8 @@ static char *conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len) * The sign is returned in the is_negative argument (and is not placed * in buf). */ -static char *conv_fp(register char format, register double num, +static char * +conv_fp(register char format, register double num, boolean_e add_dp, int precision, bool_int *is_negative, char *buf, int *len) { @@ -539,7 +547,8 @@ static char *conv_fp(register char format, register double num, * which is a pointer to the END of the buffer + 1 (i.e. if the buffer * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) */ -static char *conv_p2(register u_wide_int num, register int nbits, +static char * +conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) { register int mask = (1 << nbits) - 1; @@ -562,7 +571,8 @@ static char *conv_p2(register u_wide_int num, register int nbits, /* * Do format conversion placing the output in buffer */ -int ap_vformatter(int (*flush_func)(ap_vformatter_buff *), +static int +ap_vformatter(int (*flush_func)(ap_vformatter_buff *), ap_vformatter_buff *vbuff, const char *fmt, va_list ap) { register char *sp; @@ -983,7 +993,8 @@ int ap_vformatter(int (*flush_func)(ap_vformatter_buff *), } -static int snprintf_flush(ap_vformatter_buff *vbuff) +static int +snprintf_flush(ap_vformatter_buff *vbuff) { /* if the buffer fills we have to abort immediately, there is no way * to "flush" a snprintf... there's nowhere to flush it to. @@ -992,7 +1003,8 @@ static int snprintf_flush(ap_vformatter_buff *vbuff) } -int snprintf(char *buf, size_t len, const char *format,...) +int +snprintf(char *buf, size_t len, const char *format,...) { int cc; va_list ap; @@ -1012,7 +1024,8 @@ int snprintf(char *buf, size_t len, const char *format,...) } -int vsnprintf(char *buf, size_t len, const char *format, va_list ap) +int +vsnprintf(char *buf, size_t len, const char *format, va_list ap) { int cc; ap_vformatter_buff vbuff; diff --git a/sbr/strcasecmp.c b/sbr/strcasecmp.c index c128f9b..79fc5a8 100644 --- a/sbr/strcasecmp.c +++ b/sbr/strcasecmp.c @@ -32,23 +32,3 @@ mh_strcasecmp (const char *s1, const char *s2) return (0); return (tolower(*us1) - tolower(*--us2)); } - - -int -mh_strncasecmp (const char *s1, const char *s2, size_t n) -{ - const unsigned char *us1, *us2; - - if (n != 0) { - us1 = (const unsigned char *) s1, - us2 = (const unsigned char *) s2; - - do { - if (tolower(*us1) != tolower(*us2++)) - return (tolower(*us1) - tolower(*--us2)); - if (*us1++ == '\0') - break; - } while (--n != 0); - } - return (0); -} diff --git a/sbr/strerror.c b/sbr/strerror.c deleted file mode 100644 index af8d58f..0000000 --- a/sbr/strerror.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * strerror.c -- get error message string - */ - -#include - -extern int sys_nerr; -extern char *sys_errlist[]; - - -char * -strerror (int errnum) -{ - if (errnum > 0 && errnum < sys_nerr) - return sys_errlist[errnum]; - else - return NULL; -} diff --git a/sbr/utils.c b/sbr/utils.c index 7d0158a..3bde778 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -125,7 +125,8 @@ add (char *s2, char *s1) * folder_exists * Check to see if a folder exists. */ -int folder_exists(char *folder) +int +folder_exists(char *folder) { struct stat st; int exists = 0; @@ -148,7 +149,8 @@ int folder_exists(char *folder) * create_folder * Check to see if a folder exists, if not, prompt the user to create it. */ -void create_folder(char *folder, int autocreate, void (*done_callback)(int)) +void +create_folder(char *folder, int autocreate, void (*done_callback)(int)) { struct stat st; extern int errno; diff --git a/uip/rmf.c b/uip/rmf.c index a53fe4c..f3c335e 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -204,8 +204,14 @@ rmf (char *folder) rma (folder); chdir (".."); - if (others == 0 && remdir (maildir)) - return OK; + if (others == 0) { + context_save(); /* Is this needed? meillo 2011-10 */ + fflush(stdout); /* Is this needed? meillo 2011-10 */ + if (rmdir(maildir) != -1) { + return OK; + } + admonish (maildir, "unable to remove directory"); + } advise (NULL, "folder +%s not removed", folder); return NOTOK; -- 1.7.10.4