home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / dpmi / clib / ioctl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-22  |  1.2 KB  |  55 lines

  1. //=====================================================================
  2. //
  3. //  ioctl.cpp
  4. //
  5. //  Control device I/O
  6. //
  7. //  Protected Mode version
  8. //
  9. //  Copyright (c) 1994, Kevin Morgan, All rights reserved.
  10. //
  11. //=====================================================================
  12.  
  13. #pragma inline
  14.  
  15. #define __IN_IOCTL
  16.  
  17. #include <asmrules.h>
  18. #include <io.h>
  19. #include <_io.h>
  20. #include <errno.h>
  21. #include "dpmish.h"
  22.  
  23. int ioctl (int fd, int func, void *argdx, int argcx)
  24. {
  25.         struct DPMI_Regs iregs;
  26.         struct DPMI_Regs *iregp = &iregs;
  27.         iregp->eax = 0x4400 + func;
  28.         iregp->ebx = fd;
  29.         iregp->ecx = argcx;
  30.         //
  31.         // this next arg might be a problem
  32.         // if it refers to a segment...
  33.         // We'll assume it doesn't
  34.         //
  35.         iregp->edx = (unsigned long) argdx;
  36.  
  37.         iregs.reserved = 0;
  38.         iregs.flags = _FLAGS;
  39.         //
  40.         // might need to allocate a stack
  41.         //iregs.ss = dosMemory->dosseg;
  42.         //iregs.sp = dosMemory->dossp;
  43.         iregs.ss = 0;
  44.         iregs.sp = 0;
  45.         Dpmi.simulateRealInterrupt(0x10, iregp);
  46.  
  47.         if (iregp->flags&1)
  48.             return __IOerror(_AX);
  49.         if (func==0)
  50.             return iregp->edx;
  51.         return iregp->eax;
  52. }
  53.  
  54.  
  55.