Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>ioctl() control i/0 device</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ioctl()                  Control I/0 Device

 #include   <io.h>

 int        ioctl(handle,cmd[,argdx,argcx]);
 int        handle;                      Handle associated with file/drive
 int        cmd;                         Function to be performed
 int        *argdx;
 int        argcx;

    ioctl() is used as a direct interface to the MS-DOS call 0x44
    (IOCTL).  The exact function performed depends on the value of 'cmd':

               0    Get device information
               1    Set device information (in 'argdx')
               2    Read 'argcx' bytes into the address pointed to
                    by 'argdx'
               3    Write 'argcx' bytes from the address pointed to
                    by 'argdx'
               4    Same as 2, except 'handle' is treated as a drive
                    number (0=default,1=A, etc)
               5    Same as 3, except 'handle' is a drive number
                    (0=default, 1=A, etc)
               6    Get input status
               7    Get output status
               8    Test removability; DOS 3.x only
              11    Set sharing conflict retry count; DOS 3.x only

    ioctl() can be used to get information about device channels. Regular
    files can also be used, but only 'cmd' values 0, 6, and 7 are defined
    for them.  All other calls return an EINVAL error for files.

    The arguments 'argdx' and 'argcx' are optional.

    Returns:    For 'cmd' 0 or 1, the return value is the device
                information (DX of the IOCTL call).

                For 'cmd' values of 2 through 5, the return value is the
                number of bytes actually transferred.

                For 'cmd' values of 6 or 7, the return value is the
                device status.

                On error, -1 is returned and 'errno' (defined in
                <stdlib.h>) is set to one of the following:

                   EINVAL          Invalid argument
                   EBADF           Bad file number
                   EINVDAT         Invalid data

      Notes:    ioctl() is available on UNIX systems, but not with these
                parameters or this functionality.  UNIX version 7 and
                System III differ from each other in their use of
                ioctl().  ioctl() calls are not portable to UNIX and are
                rarely portable across MS-DOS machines.

                DOS 3.0 extends ioctl() with 'cmd' values of 8 and 11.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson