home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * WRITE.C
- *
- * (c)Copyright 1990, Matthew Dillon, All Rights Reserved
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <ioctl.h>
- #include <errno.h>
-
- unsigned int
- write(fd, buf, bytes)
- int fd;
- const void *buf;
- unsigned int bytes;
- {
- _IOFDS *d;
- int n = -1;
-
- chkabort();
- if (d = __getfh(fd)) {
- if (d->fd_Flags & (O_WRONLY|O_RDWR|O_APPEND)) {
- if (d->fd_Exec)
- return((*d->fd_Exec)(d->fd_Fh, IOC_WRITE, buf, bytes));
-
- if (d->fd_Flags & O_APPEND)
- Seek(d->fd_Fh, 0L, 1);
- n = Write(d->fd_Fh, buf, bytes);
- } else {
- errno = ENOPERM;
- }
- }
- return(n);
- }
-
-