Listening a file descriptor
[MiniGUI-Processes specific functions]

Defines

Functions


Detailed Description

Register/Unregister a listen fd to MiniGUI.

When you need to listen a file descriptor, you can use select(2) system call. In MiniGUI, you can also register it to MiniGUI to be a listened fd, and when there is a read/write/except event on the registered fd , MiniGUI will sent a notification message to the registered window.

Example:

    ...

    /* Register to listen the read event of the master pty. */
    RegisterListenFD (pConInfo->masterPty, POLLIN, hMainWnd, 0);

    /* Enter the message loop. */
    while (!pConInfo->terminate && GetMessage (&Msg, hMainWnd)) {
        DispatchMessage (&Msg);
    }
    /* Unregister the listening fd. */
    UnregisterListenFD (pConInfo->masterPty);

    ...

/* The window procedure. */
static int VCOnGUIMainWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    PCONINFO pConInfo;

    pConInfo = (PCONINFO)GetWindowAdditionalData (hWnd);
    switch (message) {

         ...

        /* MSG_FDEVENT sent by MiniGUI indicates that you should to read the data. */
        case MSG_FDEVENT:
            ReadMasterPty (pConInfo);
        break;

        ...
    }

    /* Calling default window procedure. */
    if (pConInfo->DefWinProc)
        return (*pConInfo->DefWinProc)(hWnd, message, wParam, lParam);
    else
        return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

Define Documentation

#define MAX_NR_LISTEN_FD   5

The max number of listen fd which user can use.

Definition at line 303 of file minigui.h.


Function Documentation

BOOL GUIAPI RegisterListenFD ( int  fd,
int  type,
HWND  hwnd,
void *  context 
)

Registers a listening file descriptor to MiniGUI-Lite.

This function registers the file desciptor fd to MiniGUI-Lite for listening.

When there is a read/write/except event on this fd, MiniGUI will post a MSG_FDEVENT message with wParam being equal to MAKELONG (fd, type), and the lParam being set to context to the target window hwnd.

Parameters:
fd The file descriptor to be listened.
type The type of the event to be listened, can be POLLIN, POLLOUT, or POLLERR.
hwnd The handle to the window will receive MSG_FDEVENT message.
context The value will be passed to the window as lParam of MSG_FDEVENT message.
Returns:
TRUE if all OK, and FALSE on error.
Note:
Only available on MiniGUI-Processes.
See also:
UnregisterListenFD, System messages
BOOL GUIAPI UnregisterListenFD ( int  fd  ) 

Unregisters a being listened file descriptor.

This function unregisters the being listened file descriptor fd.

Parameters:
fd The file descriptor to be unregistered, should be a being listened file descriptor.
Returns:
TRUE if all OK, and FALSE on error.
Note:
Only available on MiniGUI-Processes.
See also:
RegisterListenFD
Generated on Thu Apr 7 16:01:49 2011 for MiniGUI V3.0.12 API Reference by  doxygen 1.6.3