|
|
1.1 ! root 1: /* ! 2: * $Source: /mit/kerberos/src/lib/krb/RCS/netread.c,v $ ! 3: * $Author: jtkohl $ ! 4: * ! 5: * Copyright 1987, 1988 by the Massachusetts Institute of Technology. ! 6: * ! 7: * For copying and distribution information, please see the file ! 8: * <mit-copyright.h>. ! 9: */ ! 10: ! 11: #ifndef lint ! 12: static char rcsid_netread_c[] = ! 13: "$Header: netread.c,v 4.1 88/11/15 16:47:21 jtkohl Exp $"; ! 14: #endif lint ! 15: ! 16: #include <mit-copyright.h> ! 17: ! 18: /* ! 19: * krb_net_read() reads from the file descriptor "fd" to the buffer ! 20: * "buf", until either 1) "len" bytes have been read or 2) cannot ! 21: * read anymore from "fd". It returns the number of bytes read ! 22: * or a read() error. (The calling interface is identical to ! 23: * read(2).) ! 24: * ! 25: * XXX must not use non-blocking I/O ! 26: */ ! 27: ! 28: int ! 29: krb_net_read(fd, buf, len) ! 30: int fd; ! 31: register char *buf; ! 32: register int len; ! 33: { ! 34: int cc, len2 = 0; ! 35: ! 36: do { ! 37: cc = read(fd, buf, len); ! 38: if (cc < 0) ! 39: return(cc); /* errno is already set */ ! 40: else if (cc == 0) { ! 41: return(len2); ! 42: } else { ! 43: buf += cc; ! 44: len2 += cc; ! 45: len -= cc; ! 46: } ! 47: } while (len > 0); ! 48: return(len2); ! 49: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.