Name
XtAddInput — register a new file as an input source for an application.
Synopsis
XtInputId XtAddInput(source, condition, proc, client_data)
int source;
XtPointer condition;
XtInputCallbackProc proc;
XtPointer client_data;
Arguments
sourceSpecifies the source file descriptor (on a POSIX-based system) or other operating-system-dependent device specification.
conditionSpecifies a mask that indicates a read, write, or exception condition or some operating-system-dependent condition.
procSpecifies the procedure that is to be called when input is available. See XtInputCallbackProc(2).
client_data
Specifies the argument to be passed to the specified procedure when input is available.
Description
XtAddInput has been superseded by XtAppAddInput.
While most applications are driven only by X events, some applications need to incorporate other sources of input. XtAppAddInput allows an application to integrate notification of pending file data into the event mechanism. The application uses XtAppAddInput to register a file with the Intrinsics read routine. When I/O is pending on the file source, the registered callback procedure proc is invoked. source is usually file input but can also be file output. (Note that "file" means any sink or source of data.)
XtAppAddInput also specifies the condition under which source can generate events. The legal values for condition are operating-system-dependent. On a POSIX-based system, the possible values are XtInputReadMask, XtInputWriteMask, or XtInputExceptMask. The masks cannot be ORed together. These limit the invocation of proc to either a pending read, write, or exception condition on the source file. See the POSIX system select call for discussion of these conditions.
Note that when reading from a socket, you should be careful not to close the end of the socket that is waiting before exiting the XtAppMainLoop. If you do this, you will get an infinite loop, in which the proc is called repeatedly, while the Intrinsics wait for an EOF to be read.
See Chapter 8, More Input Techniques, in Volume Four, X Toolkit Intrinsics Programming Manual, for a complete example using this function.