Blame winpr/libwinpr/comm/comm.h

Packit 1fb8d4
/**
Packit 1fb8d4
 * WinPR: Windows Portable Runtime
Packit 1fb8d4
 * Serial Communication API
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Packit 1fb8d4
 * Copyright 2014 Hewlett-Packard Development Company, L.P.
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifndef WINPR_COMM_PRIVATE_H
Packit 1fb8d4
#define WINPR_COMM_PRIVATE_H
Packit 1fb8d4
Packit 1fb8d4
#if defined __linux__ && !defined ANDROID
Packit 1fb8d4
Packit 1fb8d4
#include <linux/serial.h>
Packit 1fb8d4
#include <sys/eventfd.h>
Packit 1fb8d4
Packit 1fb8d4
#include <winpr/comm.h>
Packit 1fb8d4
Packit 1fb8d4
#include "../handle/handle.h"
Packit 1fb8d4
#include "config.h"
Packit 1fb8d4
Packit 1fb8d4
struct winpr_comm
Packit 1fb8d4
{
Packit 1fb8d4
	WINPR_HANDLE_DEF();
Packit 1fb8d4
Packit 1fb8d4
	int fd;
Packit 1fb8d4
Packit 1fb8d4
	int fd_read;
Packit 1fb8d4
	int fd_read_event; /* as of today, only used by _purge() */
Packit 1fb8d4
	CRITICAL_SECTION ReadLock;
Packit 1fb8d4
Packit 1fb8d4
	int fd_write;
Packit 1fb8d4
	int fd_write_event; /* as of today, only used by _purge() */
Packit 1fb8d4
	CRITICAL_SECTION WriteLock;
Packit 1fb8d4
Packit 1fb8d4
	/* permissive mode on errors. If TRUE (default is FALSE)
Packit 1fb8d4
	 * CommDeviceIoControl always return TRUE.
Packit 1fb8d4
	 *
Packit 1fb8d4
	 * Not all features are supported yet and an error is then returned when
Packit 1fb8d4
	 * an application turns them on (e.g: i/o buffers > 4096). It appeared
Packit 1fb8d4
	 * though that devices and applications can be still functional on such
Packit 1fb8d4
	 * errors.
Packit 1fb8d4
	 *
Packit 1fb8d4
	 * see also: comm_ioctl.c
Packit 1fb8d4
	 *
Packit 1fb8d4
	 * FIXME: getting rid of this flag once all features supported.
Packit 1fb8d4
	 */
Packit 1fb8d4
	BOOL permissive;
Packit 1fb8d4
Packit 1fb8d4
	SERIAL_DRIVER_ID serverSerialDriverId;
Packit 1fb8d4
Packit 1fb8d4
	COMMTIMEOUTS timeouts;
Packit 1fb8d4
Packit 1fb8d4
	CRITICAL_SECTION
Packit 1fb8d4
	EventsLock; /* protects counters, WaitEventMask and PendingEvents */
Packit 1fb8d4
	struct serial_icounter_struct counters;
Packit 1fb8d4
	ULONG WaitEventMask;
Packit 1fb8d4
	ULONG PendingEvents;
Packit 1fb8d4
Packit 1fb8d4
	char eventChar;
Packit 1fb8d4
	/* NB: CloseHandle() has to free resources */
Packit 1fb8d4
};
Packit 1fb8d4
Packit 1fb8d4
typedef struct winpr_comm WINPR_COMM;
Packit 1fb8d4
Packit Service 5a9772
#define SERIAL_EV_RXCHAR 0x0001
Packit Service 5a9772
#define SERIAL_EV_RXFLAG 0x0002
Packit Service 5a9772
#define SERIAL_EV_TXEMPTY 0x0004
Packit Service 5a9772
#define SERIAL_EV_CTS 0x0008
Packit Service 5a9772
#define SERIAL_EV_DSR 0x0010
Packit Service 5a9772
#define SERIAL_EV_RLSD 0x0020
Packit Service 5a9772
#define SERIAL_EV_BREAK 0x0040
Packit Service 5a9772
#define SERIAL_EV_ERR 0x0080
Packit Service 5a9772
#define SERIAL_EV_RING 0x0100
Packit Service 5a9772
#define SERIAL_EV_PERR 0x0200
Packit Service 5a9772
#define SERIAL_EV_RX80FULL 0x0400
Packit Service 5a9772
#define SERIAL_EV_EVENT1 0x0800
Packit Service 5a9772
#define SERIAL_EV_EVENT2 0x1000
Packit Service 5a9772
#define SERIAL_EV_FREERDP_WAITING 0x4000 /* bit today unused by other SERIAL_EV_* */
Packit Service 5a9772
#define SERIAL_EV_FREERDP_STOP 0x8000    /* bit today unused by other SERIAL_EV_* */
Packit Service 5a9772
Packit Service 5a9772
#define FREERDP_PURGE_TXABORT 0x00000001 /* abort pending transmission */
Packit Service 5a9772
#define FREERDP_PURGE_RXABORT 0x00000002 /* abort pending reception */
Packit 1fb8d4
Packit 1fb8d4
void CommLog_Print(DWORD wlog_level, ...);
Packit 1fb8d4
Packit 1fb8d4
BOOL CommIsHandled(HANDLE handle);
Packit 1fb8d4
BOOL CommCloseHandle(HANDLE handle);
Packit 1fb8d4
Packit 1fb8d4
#ifndef WITH_EVENTFD_READ_WRITE
Packit 1fb8d4
int eventfd_read(int fd, eventfd_t* value);
Packit 1fb8d4
int eventfd_write(int fd, eventfd_t value);
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#endif /* __linux__ */
Packit 1fb8d4
Packit 1fb8d4
#endif /* WINPR_COMM_PRIVATE_H */