X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Futils.c;h=31f9b52356b20e5fd68bbefb72393df3992d662c;hb=93b2bde457ac91bd4a395dfafd6bd5eed670c85a;hp=8c7045298b7bf0546022fc25a8a705549df12659;hpb=f53a48eb9d74db3c71938e114b7f489c339bc003;p=ppp.git diff --git a/pppd/utils.c b/pppd/utils.c index 8c70452..31f9b52 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -33,7 +33,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: utils.c,v 1.20 2002/12/04 23:03:33 paulus Exp $" +#define RCSID "$Id: utils.c,v 1.22 2003/04/07 00:01:46 paulus Exp $" #include #include @@ -720,6 +720,7 @@ error __V((char *fmt, ...)) logit(LOG_ERR, fmt, pvar); va_end(pvar); + ++error_count; } /* @@ -832,6 +833,32 @@ dump_packet(const char *tag, unsigned char *p, int len) dbglog("%s %P", tag, p, len); } +/* + * complete_read - read a full `count' bytes from fd, + * unless end-of-file or an error other than EINTR is encountered. + */ +ssize_t +complete_read(int fd, void *buf, size_t count) +{ + size_t done; + ssize_t nb; + char *ptr = buf; + + for (done = 0; done < count; ) { + nb = read(fd, ptr, count - done); + if (nb < 0) { + if (errno == EINTR) + continue; + return -1; + } + if (nb == 0) + break; + done += nb; + ptr += nb; + } + return done; +} + /* Procedures for locking the serial device using a lock file. */ #ifndef LOCK_DIR #ifdef __linux__