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