1 | /* $Id: asyncthread.h,v 1.5 2000-05-18 22:54:21 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Async thread help functions
|
---|
5 | *
|
---|
6 | * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | */
|
---|
10 | #ifndef __ASYNCTHREAD_H__
|
---|
11 | #define __ASYNCTHREAD_H__
|
---|
12 |
|
---|
13 | #include <vmutex.h>
|
---|
14 | #include <vsemaphore.h>
|
---|
15 |
|
---|
16 | #define ASYNCCNV _Optlink
|
---|
17 |
|
---|
18 | typedef void (* ASYNCCNV ASYNCTHREADPROC)(void *);
|
---|
19 |
|
---|
20 | enum AsyncRequestType {
|
---|
21 | ASYNC_GETHOSTBYNAME,
|
---|
22 | ASYNC_GETHOSTBYADDR,
|
---|
23 | ASYNC_GETPROTOBYNAME,
|
---|
24 | ASYNC_GETPROTOBYNUMBER,
|
---|
25 | ASYNC_GETSERVBYNAME,
|
---|
26 | ASYNC_GETSERVBYPORT,
|
---|
27 | ASYNC_SELECT
|
---|
28 | } ;
|
---|
29 |
|
---|
30 | typedef struct _ASYNCTHREADPARM
|
---|
31 | {
|
---|
32 | BOOL fActive;
|
---|
33 | BOOL fCancelled;
|
---|
34 | BOOL fConnected;
|
---|
35 | BOOL fWaitSelect;
|
---|
36 | BOOL fRemoved; //async select
|
---|
37 | AsyncRequestType request;
|
---|
38 | LHANDLE hAsyncTaskHandle;
|
---|
39 | HANDLE hThread; //handle of thread that started the async request
|
---|
40 | ASYNCTHREADPROC asyncProc;
|
---|
41 | VMutex *parmmutex;
|
---|
42 | HWND hwnd;
|
---|
43 | DWORD msg;
|
---|
44 | LPSTR buf;
|
---|
45 | DWORD buflen;
|
---|
46 | union {
|
---|
47 | struct {
|
---|
48 | LPSTR name;
|
---|
49 | } gethostbyname;
|
---|
50 | struct {
|
---|
51 | LPSTR addr;
|
---|
52 | int len;
|
---|
53 | int type;
|
---|
54 | } gethostbyaddr;
|
---|
55 | struct {
|
---|
56 | LPSTR name;
|
---|
57 | } getprotobyname;
|
---|
58 | struct {
|
---|
59 | int number;
|
---|
60 | } getprotobynumber;
|
---|
61 | struct {
|
---|
62 | LPSTR name;
|
---|
63 | LPSTR proto;
|
---|
64 | } getservbyname;
|
---|
65 | struct {
|
---|
66 | int port;
|
---|
67 | LPSTR proto;
|
---|
68 | } getservbyport;
|
---|
69 | struct {
|
---|
70 | VSemaphore *asyncSem;
|
---|
71 | DWORD lEvents;
|
---|
72 | DWORD lEventsPending;
|
---|
73 | SOCKET s;
|
---|
74 | } asyncselect;
|
---|
75 | } u;
|
---|
76 | _ASYNCTHREADPARM *next;
|
---|
77 | } ASYNCTHREADPARM, *PASYNCTHREADPARM;
|
---|
78 |
|
---|
79 | ULONG QueueAsyncJob(ASYNCTHREADPROC asyncproc, PASYNCTHREADPARM pThreadParm, BOOL fSetBlocking = FALSE);
|
---|
80 | void RemoveFromQueue(PASYNCTHREADPARM pThreadParm);
|
---|
81 |
|
---|
82 | void EnableAsyncEvent(SOCKET s, ULONG flags);
|
---|
83 | BOOL QueryAsyncEvent(SOCKET s, HWND *pHwnd, int *pMsg, ULONG *plEvent);
|
---|
84 | BOOL FindAndSetAsyncEvent(SOCKET s, HWND hwnd, int msg, ULONG lEvent);
|
---|
85 |
|
---|
86 | #endif //__ASYNCTHREAD_H__
|
---|