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 MAX_NR_LISTEN_FD 5 |
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.
| 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. |
| BOOL GUIAPI UnregisterListenFD | ( | int | fd | ) |
Unregisters a being listened file descriptor.
This function unregisters the being listened file descriptor fd.
| fd | The file descriptor to be unregistered, should be a being listened file descriptor. |
1.6.3