home *** CD-ROM | disk | FTP | other *** search
-
- #define NOCCARGC
- #include clib.def
- extern int _status[];
- /*
- ** Item-stream write to fd.
- ** Entry: buf = address of target buffer
- ** sz = size of items in bytes
- ** n = number of items to read
- ** fd = file descriptor
- ** Returns a count of items actually read
- ** or zero if an error occured.
- ** Use ferror() to determine file status.
- */
- fwrite(buf, sz, n, fd) char *buf; int sz, n, fd; {
- int cnt;
- if((cnt = write(fd, buf, n*sz)) == -1) return (0);
- return (cnt);
- }
-
- /*
- ** Binary-stream write to fd.
- ** Entry: buf = address of target buffer
- ** n = number of items to read
- ** fd = file descriptor
- ** Returns a count of items actually read
- ** or -1 if an error occured.
- ** Use ferror() to determine file status.
- */
- write(fd, buf, n) int fd, n; char *buf; {
- char *cnt; /*fake unsigned*/
- cnt = 0;
- while(n--) {
- _write(*buf++, fd);
- if(_status[fd] & ERRBIT) return (-1);
- ++cnt;
- }
- return (cnt);
- }
-
-