X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/dffeac1b8759bbedb385d0d2003a6d4c6c008cd5..b34e10452c095a4a4f9d6e9978ddc6da41e44c99:/sbr/utils.c 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; +}