| 1 | /* $Id: notify.cpp,v 1.3 1999-08-16 20:18:39 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | *
|
|---|
| 5 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 6 | *
|
|---|
| 7 | * Winsock code
|
|---|
| 8 | *
|
|---|
| 9 | * Copyright 1998 Vince Vielhaber
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | /*****************************************************************************
|
|---|
| 15 | * Includes *
|
|---|
| 16 | *****************************************************************************/
|
|---|
| 17 |
|
|---|
| 18 | #include <os2win.h>
|
|---|
| 19 | //#include <wsock32.h>
|
|---|
| 20 | #include <misc.h>
|
|---|
| 21 | #include <odinwrap.h>
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | /*****************************************************************************
|
|---|
| 25 | * Structures *
|
|---|
| 26 | *****************************************************************************/
|
|---|
| 27 |
|
|---|
| 28 | typedef unsigned int u_int;
|
|---|
| 29 | typedef u_int SOCKET;
|
|---|
| 30 |
|
|---|
| 31 | typedef unsigned long TID;
|
|---|
| 32 |
|
|---|
| 33 | typedef struct AsyncStatus {
|
|---|
| 34 | HWND hwnd; // owner's hwindow
|
|---|
| 35 | u_int msg; // message to send when event occurs
|
|---|
| 36 | ULONG event; // event that may occur
|
|---|
| 37 | SOCKET socket; // the socket
|
|---|
| 38 | int status; // blocking yes/no
|
|---|
| 39 | TID threadID; // Thread ID for async
|
|---|
| 40 | int MsgStat; // has message been sent yet?
|
|---|
| 41 | struct AsyncStatus *Next; // pointer to next AsyncStatus in the list
|
|---|
| 42 | struct AsyncStatus *Prev; // pointer to previous AsyncStatus in the list
|
|---|
| 43 | } AsyncStatus;
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | /*****************************************************************************
|
|---|
| 48 | * Macros *
|
|---|
| 49 | *****************************************************************************/
|
|---|
| 50 |
|
|---|
| 51 | /*
|
|---|
| 52 | * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
|
|---|
| 53 | * when constructing the response to WSAAsyncSelect().
|
|---|
| 54 | */
|
|---|
| 55 |
|
|---|
| 56 | //#define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
|---|
| 57 | #ifdef MAKELONG
|
|---|
| 58 | #undef MAKELONG
|
|---|
| 59 | #endif
|
|---|
| 60 | #define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
|
|---|
| 61 | #define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | int Notify(AsyncStatus *as, int event)
|
|---|
| 67 | {
|
|---|
| 68 | int rc;
|
|---|
| 69 |
|
|---|
| 70 | #ifdef DEBUG
|
|---|
| 71 | WriteLog("WSOCK32: Open32 Notifying %x, %x, %d\n",
|
|---|
| 72 | (HWND)as->hwnd,as->msg,(int)as->socket);
|
|---|
| 73 | #endif
|
|---|
| 74 |
|
|---|
| 75 | rc = PostMessageA(as->hwnd,as->msg,as->socket,OS2WSAMAKESELECTREPLY(event,0));
|
|---|
| 76 |
|
|---|
| 77 | return rc;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | // WPARAM is UINT, LPARAM is LONG
|
|---|
| 81 |
|
|---|
| 82 | int NotifyWSA(HWND hw,u_int msg,UINT wp,LONG lp)
|
|---|
| 83 | {
|
|---|
| 84 | int rc;
|
|---|
| 85 |
|
|---|
| 86 | #ifdef DEBUG
|
|---|
| 87 | WriteLog("WSOCK32: Open32 WSA-Notifying %x, %x\n",
|
|---|
| 88 | (HWND)hw,msg);
|
|---|
| 89 | #endif
|
|---|
| 90 |
|
|---|
| 91 | rc = PostMessageA(hw,msg,(WPARAM)wp,(LPARAM)lp);
|
|---|
| 92 |
|
|---|
| 93 | return rc;
|
|---|
| 94 |
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|