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