home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * IOCTL.C
- *
- * (c)Copyright 1990, Matthew Dillon, All Rights Reserved
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <ioctl.h>
-
- long
- ioctl(fd, req, arg1, arg2)
- int fd;
- int req;
- int *arg1;
- int *arg2;
- {
- _IOFDS *d;
-
- if (d = __getfh(fd)) {
- switch(req) {
- case IOC_MODES|IOF_GET:
- if (arg1)
- *arg1 = d->fd_Flags & ~O_INTERNAL;
- break;
- case IOC_MODES|IOF_SET:
- d->fd_Flags = (d->fd_Flags & O_INTERNAL) | (*arg1 & ~O_INTERNAL);
- break;
- case IOC_GETDESC:
- return((long)d->fd_Fh);
- }
-
- if (d->fd_Exec)
- return((*d->fd_Exec)(d->fd_Fh, req, arg1, arg2));
-
- /*
- * normal file descriptor
- */
-
- switch(req) {
- case IOC_CEXEC|IOF_GET:
- if (arg1)
- *arg1 = (d->fd_Flags & O_CEXEC) ? 1 : 0;
- return(0);
- case IOC_CEXEC|IOF_SET:
- if (*arg1)
- d->fd_Flags |= O_CEXEC;
- else
- d->fd_Flags &= ~O_CEXEC;
- return(0);
- case IOC_MODES|IOF_GET:
- return(0);
- case IOC_MODES|IOF_SET:
- return(0);
- case IOC_DOMAIN:
- return(IODOM_AMIGADOS);
- }
- errno = EINVAL;
- }
- return(-1);
- }
-
-