2021-03-16 17:15:13 +03:00
|
|
|
/**
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2021-03-24 20:32:43 +03:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
2021-03-16 17:15:13 +03:00
|
|
|
#ifdef HAVE_POLL_H
|
|
|
|
#include <poll.h>
|
|
|
|
#else
|
|
|
|
#include <sys/select.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
ULONG mode;
|
|
|
|
} FdIndex;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct winpr_poll_set
|
|
|
|
{
|
|
|
|
#ifdef HAVE_POLL_H
|
|
|
|
struct pollfd* pollset;
|
|
|
|
struct pollfd staticSet[MAXIMUM_WAIT_OBJECTS];
|
|
|
|
BOOL isStatic;
|
|
|
|
#else
|
|
|
|
FdIndex* fdIndex;
|
2021-03-24 20:32:43 +03:00
|
|
|
fd_set rset_base;
|
2021-03-16 17:15:13 +03:00
|
|
|
fd_set rset;
|
2021-03-24 20:32:43 +03:00
|
|
|
fd_set wset_base;
|
2021-03-16 17:15:13 +03:00
|
|
|
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);
|
|
|
|
|
2021-03-24 20:32:43 +03:00
|
|
|
#endif
|
|
|
|
|
2021-03-16 17:15:13 +03:00
|
|
|
#endif /* WINPR_LIBWINPR_SYNCH_POLLSET_H_ */
|