The
IOCTL function provides a thin wrapper over the Unix
ioctl(2)
system call. IOTCL performs special functions on the specified
file. The set of functions actually available depends on your version of Unix and the type of file (tty, tape, disk file, etc.) referred to.
To use IOCTL, read the C programmer's documentation describing the
ioctl(2)
function for the desired device and convert all constants and data to their IDL equivalents.
The value returned by the system
ioctl
function is returned as the value of the IDL IOCTL function.
A longword integer that specifies the ioctl request code. These codes are usually contained in C language header files provided by the operating system, and are not generally portable between Unix versions. If one of the "MT" keywords is used, this argument can be omitted.
A named variable through which data if passed to and from ioctl. IOCTL requests usually request data from the system or supply the system with information. The user must make Arg the correct type and size. Errors in typing or sizing Arg can corrupt the IDL address space and/or make IDL crash. If one of the MT keywords is used, this argument can be omitted.
Note that the keyword below that start with "MT" can be used to issue commonly used magnetic tape ioctl() calls. When these keywords are used, the Request and Arg arguments are ignored and an be omitted. Magnetic tape operations not available via these keywords can still be executed by supplying the appropriate Request and Arg values. When issuing magnetic tape IOCTL calls, be aware that different devices have different rules for which ioctl calls are allowed, and when. The documentation for your computer system explains those rules.
If this keyword is set, Arg is converted to a scalar longword and this longword is passed by value. Normally, Arg is passed to ioctl by reference (i.e., by address).
Use this keyword to skip files on a tape. A positive value skips forward that number of files. A negative value skips backward.
The following example prints the size of the terminal being used by the current IDL session. It is known to work under SunOS 4.1.2. Changes may be necessary for other operating systems or even other versions of SunOS.
winsize = { row:0, col:0, xpixel:0, ypixel:0 }
;
Variable to receive result. This structure is described in Section 4 of the SunOS manual pages under termios(4).
TIOCGWINSZ = 1074295912L ; The request code for obtaining the tty size, as determined by reading the termios(4) documentation, and reading the system include files in the /usr/include/sys directory.
ret = ioctl(-1, TIOCGWINSZ, winsize)
;
Make the information request. -1 is the
IDL;
logical file unit for the standard output.
print,winsize.row, winsize.col, $
format='("TTY has ", I0," rows and ", I0," columns.")'
;
Output the results.
The following points should be noted in this example:
ioctl
in the winsize variable (as documented in the
termio(4)
manual page). Not providing a large enough result buffer would cause IDL's memory to be corrupted.
/usr/include/sys
directory. Such values are not always portable between major operating system releases.