home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 387b.lha / dice_v2.02 / lib / fd / ioctl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  1.1 KB  |  66 lines

  1.  
  2. /*
  3.  *  IOCTL.C
  4.  *
  5.  *  (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <fcntl.h>
  11. #include <errno.h>
  12. #include <ioctl.h>
  13.  
  14. long
  15. ioctl(fd, req, arg1, arg2)
  16. int fd;
  17. int req;
  18. int *arg1;
  19. int *arg2;
  20. {
  21.     _IOFDS *d;
  22.  
  23.     if (d = __getfh(fd)) {
  24.     switch(req) {
  25.     case IOC_MODES|IOF_GET:
  26.         if (arg1)
  27.         *arg1 = d->fd_Flags & ~O_INTERNAL;
  28.         break;
  29.     case IOC_MODES|IOF_SET:
  30.         d->fd_Flags = (d->fd_Flags & O_INTERNAL) | (*arg1 & ~O_INTERNAL);
  31.         break;
  32.     case IOC_GETDESC:
  33.         return((long)d->fd_Fh);
  34.     }
  35.  
  36.     if (d->fd_Exec)
  37.         return((*d->fd_Exec)(d->fd_Fh, req, arg1, arg2));
  38.  
  39.     /*
  40.      *  normal file descriptor
  41.      */
  42.  
  43.     switch(req) {
  44.     case IOC_CEXEC|IOF_GET:
  45.         if (arg1)
  46.         *arg1 = (d->fd_Flags & O_CEXEC) ? 1 : 0;
  47.         return(0);
  48.     case IOC_CEXEC|IOF_SET:
  49.         if (*arg1)
  50.         d->fd_Flags |= O_CEXEC;
  51.         else
  52.         d->fd_Flags &= ~O_CEXEC;
  53.         return(0);
  54.     case IOC_MODES|IOF_GET:
  55.         return(0);
  56.     case IOC_MODES|IOF_SET:
  57.         return(0);
  58.     case IOC_DOMAIN:
  59.         return(IODOM_AMIGADOS);
  60.     }
  61.     errno = EINVAL;
  62.     }
  63.     return(-1);
  64. }
  65.  
  66.