blob: 6e478e6c7fdd39ddc20aa60b97b92167e279c8c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* pollset
*
* Copyright 2021 David Fort <contact@hardening-consulting.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WINPR_LIBWINPR_SYNCH_POLLSET_H_
#define WINPR_LIBWINPR_SYNCH_POLLSET_H_
#include <winpr/wtypes.h>
#include <winpr/synch.h>
#include <winpr/config.h>
#ifndef _WIN32
#ifdef WINPR_HAVE_POLL_H
#include <poll.h>
#else
#include <sys/select.h>
typedef struct
{
int fd;
ULONG mode;
} FdIndex;
#endif
struct winpr_poll_set
{
#ifdef WINPR_HAVE_POLL_H
struct pollfd* pollset;
struct pollfd staticSet[MAXIMUM_WAIT_OBJECTS];
BOOL isStatic;
#else
FdIndex* fdIndex;
fd_set rset_base;
fd_set rset;
fd_set wset_base;
fd_set wset;
int nread, nwrite;
int maxFd;
#endif
size_t fillIndex;
size_t size;
};
typedef struct winpr_poll_set WINPR_POLL_SET;
BOOL pollset_init(WINPR_POLL_SET* set, size_t nhandles);
void pollset_uninit(WINPR_POLL_SET* set);
void pollset_reset(WINPR_POLL_SET* set);
BOOL pollset_add(WINPR_POLL_SET* set, int fd, ULONG mode);
int pollset_poll(WINPR_POLL_SET* set, DWORD dwMilliseconds);
BOOL pollset_isSignaled(WINPR_POLL_SET* set, size_t idx);
BOOL pollset_isReadSignaled(WINPR_POLL_SET* set, size_t idx);
BOOL pollset_isWriteSignaled(WINPR_POLL_SET* set, size_t idx);
#endif
#endif /* WINPR_LIBWINPR_SYNCH_POLLSET_H_ */
|