home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / krb / netwrite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-15  |  912 b   |  46 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/netwrite.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_netwrite_c[] =
  13. "$Header: netwrite.c,v 4.1 88/11/15 16:48:58 jtkohl Exp $";
  14. #endif    lint
  15.  
  16. #include <mit-copyright.h>
  17.  
  18. /*
  19.  * krb_net_write() writes "len" bytes from "buf" to the file
  20.  * descriptor "fd".  It returns the number of bytes written or
  21.  * a write() error.  (The calling interface is identical to
  22.  * write(2).)
  23.  *
  24.  * XXX must not use non-blocking I/O
  25.  */
  26.  
  27. int
  28. krb_net_write(fd, buf, len)
  29. int fd;
  30. register char *buf;
  31. int len;
  32. {
  33.     int cc;
  34.     register int wrlen = len;
  35.     do {
  36.     cc = write(fd, buf, wrlen);
  37.     if (cc < 0)
  38.         return(cc);
  39.     else {
  40.         buf += cc;
  41.         wrlen -= cc;
  42.     }
  43.     } while (wrlen > 0);
  44.     return(len);
  45. }
  46.