From: David Levine Date: Thu, 6 Oct 2016 21:53:00 +0000 (-0400) Subject: Moved scan_input() from uip/post.c to sbr/utils.c. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/e6d87a04919616cf2a6ea6cbda81d5fbc31cc8a2?hp=cefa77d7637d2581919715acc353b9203b949017 Moved scan_input() from uip/post.c to sbr/utils.c. --- diff --git a/h/utils.h b/h/utils.h index 00249be4..9e515989 100644 --- a/h/utils.h +++ b/h/utils.h @@ -58,6 +58,20 @@ char *nmh_strcasestr (const char *, const char *); */ int contains8bit(const char *start, const char *end); +/* + * See if file has any 8-bit bytes. + * Arguments include: + * + * fd - file descriptor + * eightbit - address of result, will be set to 1 if the file contains + * any 8-bit bytes, 0 otherwise. + * + * Returns OK on success, NOTOK on read failure. + * + */ +int scan_input (int fd, int *eightbit); + + /* * Compares prior version of nmh with current version. Returns 1 * if they compare the be the same, 0 if not. diff --git a/sbr/utils.c b/sbr/utils.c index cf920a39..e5ed66aa 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -484,3 +484,25 @@ contains8bit(const char *start, const char *end) return 0; } + + +/* + * See if input has any 8-bit bytes. + */ +int +scan_input (int fd, int *eightbit) { + int state; + char buf[BUFSIZ]; + + *eightbit = 0; + lseek (fd, (off_t) 0, SEEK_SET); + + while ((state = read (fd, buf, sizeof buf)) > 0) { + if (contains8bit (buf, buf + state)) { + *eightbit = 1; + return OK; + } + } + + return state == NOTOK ? NOTOK : OK; +} diff --git a/uip/post.c b/uip/post.c index d1e58ebf..d385219e 100644 --- a/uip/post.c +++ b/uip/post.c @@ -305,7 +305,6 @@ static void fcc (char *, char *); static void die (char *, char *, ...); static void post (char *, int, int, int, char *, int, char *); static void do_text (char *file, int fd); -static int scan_input (int, int *); static void do_an_address (struct mailname *, int); static void do_addresses (int, int); static int find_prefix (void); @@ -1855,27 +1854,6 @@ do_text (char *file, int fd) } -/* - * See if input has any 8-bit bytes. - */ -static int -scan_input (int fd, int *eightbit) { - int state; - char buf[BUFSIZ]; - - lseek (fd, (off_t) 0, SEEK_SET); - - while ((state = read (fd, buf, sizeof buf)) > 0) { - if (contains8bit (buf, buf + state)) { - *eightbit = 1; - return OK; - } - } - - return state == NOTOK ? NOTOK : OK; -} - - /* * SIGNAL HANDLING */