source: trunk/src/wsock32/notify.cpp@ 1367

Last change on this file since 1367 was 1367, checked in by phaller, 26 years ago

Add: reimplementation of WSA sockets

File size: 2.5 KB
Line 
1/* $Id: notify.cpp,v 1.4 1999-10-20 01:18:30 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
28typedef unsigned int u_int;
29typedef u_int SOCKET;
30
31typedef unsigned long TID;
32
33typedef struct AsyncStatus
34{
35 HWND hwnd; // owner's hwindow
36 u_int msg; // message to send when event occurs
37 ULONG event; // event that may occur
38 SOCKET socket; // the socket
39 int status; // blocking yes/no
40 TID threadID; // Thread ID for async
41 int MsgStat; // has message been sent yet?
42 struct AsyncStatus *Next; // pointer to next AsyncStatus in the list
43 struct AsyncStatus *Prev; // pointer to previous AsyncStatus in the list
44} AsyncStatus;
45
46
47
48/*****************************************************************************
49 * Macros *
50 *****************************************************************************/
51
52/*
53 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
54 * when constructing the response to WSAAsyncSelect().
55 */
56
57//#define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
58#ifdef MAKELONG
59#undef MAKELONG
60#endif
61#define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
62#define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
63
64
65
66
67int Notify(AsyncStatus *as, int event)
68{
69 int rc;
70
71#ifdef DEBUG
72 WriteLog("WSOCK32: Open32 Notifying %x, %x, %d\n",
73 (HWND)as->hwnd,as->msg,(int)as->socket);
74#endif
75
76 rc = PostMessageA(as->hwnd,as->msg,as->socket,OS2WSAMAKESELECTREPLY(event,0));
77
78return rc;
79}
80
81// WPARAM is UINT, LPARAM is LONG
82
83int NotifyWSA(HWND hw,u_int msg,UINT wp,LONG lp)
84{
85int rc;
86
87#ifdef DEBUG
88 WriteLog("WSOCK32: Open32 WSA-Notifying %x, %x\n",
89 (HWND)hw,msg);
90#endif
91
92 rc = PostMessageA(hw,msg,(WPARAM)wp,(LPARAM)lp);
93
94return rc;
95
96}
97
98
99
Note: See TracBrowser for help on using the repository browser.