winpr-comm: cleaning up code, focused on indentation and whitespaces

This commit is contained in:
Emmanuel Ledoux 2014-06-16 19:18:45 +02:00 committed by Emmanuel Ledoux
parent 50efce67f5
commit 0db3d9dbb0
22 changed files with 320 additions and 361 deletions

View File

@ -108,12 +108,12 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
#ifndef _WIN32
/* Windows 2012 server sends on a first call :
/* Windows 2012 server sends on a first call :
* DesiredAccess = 0x00100080: SYNCHRONIZE | FILE_READ_ATTRIBUTES
* SharedAccess = 0x00000007: FILE_SHARE_DELETE | FILE_SHARE_WRITE | FILE_SHARE_READ
* CreateDisposition = 0x00000001: CREATE_NEW
*
* then Windows 2012 sends :
* then Windows 2012 sends :
* DesiredAccess = 0x00120089: SYNCHRONIZE | READ_CONTROL | FILE_READ_ATTRIBUTES | FILE_READ_EA | FILE_READ_DATA
* SharedAccess = 0x00000007: FILE_SHARE_DELETE | FILE_SHARE_WRITE | FILE_SHARE_READ
* CreateDisposition = 0x00000001: CREATE_NEW
@ -133,12 +133,12 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
#endif
serial->hComm = CreateFile(serial->device.name,
DesiredAccess,
SharedAccess,
NULL, /* SecurityAttributes */
CreateDisposition,
0, /* FlagsAndAttributes */
NULL); /* TemplateFile */
DesiredAccess,
SharedAccess,
NULL, /* SecurityAttributes */
CreateDisposition,
0, /* FlagsAndAttributes */
NULL); /* TemplateFile */
if (!serial->hComm || (serial->hComm == INVALID_HANDLE_VALUE))
{
@ -214,11 +214,11 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
goto error_handle;
}
/* MS-RDPESP 3.2.5.1.4: If the Offset field is not set to 0, the value MUST be ignored
* assert(Offset == 0);
*/
DEBUG_SVC("reading %lu bytes from %s", Length, serial->device.name);
@ -240,7 +240,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
case ERROR_NOT_SUPPORTED:
irp->IoStatus = STATUS_NOT_SUPPORTED;
break;
case ERROR_INVALID_PARAMETER:
irp->IoStatus = STATUS_INVALID_PARAMETER;
break;
@ -269,7 +269,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
}
DEBUG_SVC("%lu bytes read from %s", nbRead, serial->device.name);
error_handle:
Stream_Write_UINT32(irp->output, nbRead); /* Length (4 bytes) */
@ -320,7 +320,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
case ERROR_NOT_SUPPORTED:
irp->IoStatus = STATUS_NOT_SUPPORTED;
break;
case ERROR_INVALID_PARAMETER:
irp->IoStatus = STATUS_INVALID_PARAMETER;
break;
@ -386,7 +386,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
Stream_Read(irp->input, InputBuffer, InputBufferLength);
DEBUG_SVC("CommDeviceIoControl: CompletionId=%d, IoControlCode=[0x%X] %s", irp->CompletionId, IoControlCode, _comm_serial_ioctl_name(IoControlCode));
/* FIXME: CommDeviceIoControl to be replaced by DeviceIoControl() */
if (CommDeviceIoControl(serial->hComm, IoControlCode, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength, &BytesReturned, NULL))
{
@ -396,8 +396,8 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
}
else
{
DEBUG_SVC("CommDeviceIoControl failure: IoControlCode=[0x%0.8x] %s, last-error: 0x%X",
IoControlCode, _comm_serial_ioctl_name(IoControlCode), GetLastError());
DEBUG_SVC("CommDeviceIoControl failure: IoControlCode=[0x%0.8x] %s, last-error: 0x%X",
IoControlCode, _comm_serial_ioctl_name(IoControlCode), GetLastError());
// TMP: TODO: Status codes to be reviewed according: http://msdn.microsoft.com/en-us/library/ff547466%28v=vs.85%29.aspx#generic_status_values_for_serial_device_control_requests
@ -472,7 +472,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
static void serial_process_irp(SERIAL_DEVICE* serial, IRP* irp)
{
WLog_Print(serial->log, WLOG_DEBUG, "IRP MajorFunction: 0x%04X MinorFunction: 0x%04X\n",
irp->MajorFunction, irp->MinorFunction);
irp->MajorFunction, irp->MinorFunction);
switch (irp->MajorFunction)
{
@ -590,7 +590,7 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
}
/* pending thread (but not yet terminating thread) if waitResult == WAIT_TIMEOUT */
}
if (serial->IrpThreadToBeTerminatedCount > 0)
{
@ -612,7 +612,7 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
*/
previousIrpThread = ListDictionary_GetItemValue(serial->IrpThreads, (void*)irp->CompletionId);
if (previousIrpThread)
if (previousIrpThread)
{
/* Thread still alived <=> Request still pending */
@ -643,7 +643,7 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
if (ListDictionary_Count(serial->IrpThreads) >= MAX_IRP_THREADS)
{
DEBUG_WARN("Number of IRP threads threshold reached: %d, keep on anyway", ListDictionary_Count(serial->IrpThreads));
assert(FALSE); /* unimplemented */
/* TODO: MAX_IRP_THREADS has been thought to avoid a
@ -668,12 +668,12 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
/* data freed by irp_thread_func */
irpThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)irp_thread_func,
(void*)data,
0,
NULL);
irpThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)irp_thread_func,
(void*)data,
0,
NULL);
if (irpThread == INVALID_HANDLE_VALUE)
{
@ -711,7 +711,7 @@ static void terminate_pending_irp_threads(SERIAL_DEVICE *serial)
HANDLE irpThread;
ULONG_PTR id = ids[i];
irpThread = ListDictionary_GetItemValue(serial->IrpThreads, (void*)id);
irpThread = ListDictionary_GetItemValue(serial->IrpThreads, (void*)id);
TerminateThread(irpThread, 0);
@ -777,7 +777,7 @@ static void serial_irp_request(DEVICE* device, IRP* irp)
static void serial_free(DEVICE* device)
{
SERIAL_DEVICE* serial = (SERIAL_DEVICE*) device;
WLog_Print(serial->log, WLOG_DEBUG, "freeing");
MessageQueue_PostQuit(serial->MainIrpQueue, 0);
@ -821,7 +821,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
if ((name && name[0]) && (path && path[0]))
{
DEBUG_SVC("Defining %s as %s", name, path);
if (!DefineCommDevice(name /* eg: COM1 */, path /* eg: /dev/ttyS0 */))
{
DEBUG_SVC("Could not define %s as %s", name, path);
@ -846,7 +846,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
serial->MainIrpQueue = MessageQueue_New(NULL);
/* IrpThreads content only modified by create_irp_thread() */
serial->IrpThreads = ListDictionary_New(FALSE);
serial->IrpThreads = ListDictionary_New(FALSE);
serial->IrpThreadToBeTerminatedCount = 0;
InitializeCriticalSection(&serial->TerminatingIrpThreadsLock);
@ -856,12 +856,12 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) serial);
serial->MainThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) serial_thread_func,
(void*) serial,
0,
NULL);
serial->MainThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) serial_thread_func,
(void*) serial,
0,
NULL);
}
return 0;

View File

@ -401,7 +401,7 @@ WINPR_API BOOL IsCommDevice(LPCTSTR lpDeviceName);
* RegisterHandleCreator().
*/
WINPR_API HANDLE CommCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
@ -546,19 +546,19 @@ BOOL _comm_set_permissive(HANDLE hDevice, BOOL permissive);
* FIXME: to be moved in comm_ioctl.h
*/
BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
/**
* FIXME: to be moved in comm_io.h
*/
BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
/**
* FIXME: to be moved in comm_io.h
*/
BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
#ifdef __cplusplus
}

View File

@ -353,4 +353,3 @@ WINPR_API char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName);
#endif
#endif /* WINPR_FILE_H */

View File

@ -5,7 +5,7 @@
* Copyright 2011 O.S. Systems Software Ltda.
* Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br>
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2014 Hewlett-Packard Development Company, L.P.
* Copyright 2014 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -158,7 +158,7 @@ BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp)
/**
*
*
*
* ERRORS:
* ERROR_INVALID_HANDLE
@ -205,7 +205,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
}
/* error_handle */
lpLocalDcb->DCBlength = lpDCB->DCBlength;
SERIAL_BAUD_RATE baudRate;
@ -215,14 +215,14 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
goto error_handle;
}
lpLocalDcb->BaudRate = baudRate.BaudRate;
lpLocalDcb->fBinary = (currentState.c_cflag & ICANON) == 0;
if (!lpLocalDcb->fBinary)
{
DEBUG_WARN("Unexpected nonbinary mode, consider to unset the ICANON flag.");
}
lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0;
lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0;
SERIAL_HANDFLOW handflow;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_HANDFLOW, NULL, 0, &handflow, sizeof(SERIAL_HANDFLOW), &bytesReturned, NULL))
@ -250,7 +250,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
lpLocalDcb->fDsrSensitivity = (handflow.ControlHandShake & SERIAL_DSR_SENSITIVITY) != 0;
lpLocalDcb->fTXContinueOnXoff = (handflow.FlowReplace & SERIAL_XOFF_CONTINUE) != 0;
lpLocalDcb->fTXContinueOnXoff = (handflow.FlowReplace & SERIAL_XOFF_CONTINUE) != 0;
lpLocalDcb->fOutX = (handflow.FlowReplace & SERIAL_AUTO_TRANSMIT) != 0;
@ -314,7 +314,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
lpLocalDcb->ErrorChar = serialChars.ErrorChar;
lpLocalDcb->EofChar = serialChars.EofChar;
lpLocalDcb->EvtChar = serialChars.EventChar;
@ -332,7 +332,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
/**
* @return TRUE on success, FALSE otherwise.
*
*
* As of today, SetCommState() can fail half-way with some settings
* applied and some others not. SetCommState() returns on the first
* failure met. FIXME: or is it correct?
@ -384,7 +384,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
serialChars.XoffChar = lpDCB->XoffChar;
serialChars.ErrorChar = lpDCB->ErrorChar;
serialChars.EofChar = lpDCB->EofChar;
serialChars.EventChar = lpDCB->EvtChar;
serialChars.EventChar = lpDCB->EvtChar;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_CHARS, &serialChars, sizeof(SERIAL_CHARS), NULL, 0, &bytesReturned, NULL))
{
DEBUG_WARN("SetCommState failure: could not set the serial chars.");
@ -409,7 +409,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
{
handflow.ControlHandShake |= SERIAL_CTS_HANDSHAKE;
}
if (lpDCB->fOutxDsrFlow)
{
@ -444,7 +444,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
{
handflow.FlowReplace |= SERIAL_XOFF_CONTINUE;
}
if (lpDCB->fOutX)
{
handflow.FlowReplace |= SERIAL_AUTO_TRANSMIT;
@ -551,13 +551,13 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
*
* TCSANOW matches the best this definition
*/
if (_comm_ioctl_tcsetattr(pComm->fd, TCSANOW, &upcomingTermios) < 0)
{
SetLastError(ERROR_IO_DEVICE);
return FALSE;
}
return TRUE;
}
@ -744,7 +744,7 @@ BOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOverlapped)
/* Extended API */
typedef struct _COMM_DEVICE
typedef struct _COMM_DEVICE
{
LPTSTR name;
LPTSTR path;
@ -760,11 +760,11 @@ static HANDLE_CREATOR *_CommHandleCreator = NULL;
static void _CommDevicesInit()
{
/*
/*
* TMP: FIXME: What kind of mutex should be used here?
* better have to let DefineCommDevice() and QueryCommDevice() thread unsafe ?
* use of a module_init() ?
*/
*/
if (_CommDevices == NULL)
{
@ -818,7 +818,7 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
/**
* Returns TRUE on success, FALSE otherwise. To get extended error
* information, call GetLastError.
*
*
* ERRORS:
* ERROR_OUTOFMEMORY was not possible to get mappings.
* ERROR_INVALID_DATA was not possible to add the device.
@ -912,12 +912,12 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
/**
* Returns the number of target paths in the buffer pointed to by
* lpTargetPath.
* lpTargetPath.
*
* The current implementation returns in any case 0 and 1 target
* path. A NULL lpDeviceName is not supported yet to get all the
* paths.
*
*
* ERRORS:
* ERROR_SUCCESS
* ERROR_OUTOFMEMORY was not possible to get mappings.
@ -961,7 +961,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
break;
}
if (storedTargetPath == NULL)
{
SetLastError(ERROR_INVALID_DATA);
@ -981,7 +981,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
}
/**
* Checks whether lpDeviceName is a valid and registered Communication device.
* Checks whether lpDeviceName is a valid and registered Communication device.
*/
BOOL IsCommDevice(LPCTSTR lpDeviceName)
{
@ -997,7 +997,7 @@ BOOL IsCommDevice(LPCTSTR lpDeviceName)
/**
* Sets
* Sets
*/
void _comm_setRemoteSerialDriver(HANDLE hComm, REMOTE_SERIAL_DRIVER_ID driverId)
{
@ -1026,10 +1026,10 @@ void _comm_setRemoteSerialDriver(HANDLE hComm, REMOTE_SERIAL_DRIVER_ID driverId)
*
* @param dwShareMode must be zero, INVALID_HANDLE_VALUE is returned
* otherwise and GetLastError() should return ERROR_SHARING_VIOLATION.
*
*
* @param lpSecurityAttributes NULL expected, a warning message is printed
* otherwise. TODO: better support.
*
*
* @param dwCreationDisposition must be OPEN_EXISTING. If the
* communication device doesn't exist INVALID_HANDLE_VALUE is returned
* and GetLastError() returns ERROR_FILE_NOT_FOUND.
@ -1039,16 +1039,16 @@ void _comm_setRemoteSerialDriver(HANDLE hComm, REMOTE_SERIAL_DRIVER_ID driverId)
*
* @param hTemplateFile must be NULL.
*
* @return INVALID_HANDLE_VALUE on error.
* @return INVALID_HANDLE_VALUE on error.
*/
HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
CHAR devicePath[MAX_PATH];
struct stat deviceStat;
WINPR_COMM* pComm = NULL;
struct termios upcomingTermios;
if (dwDesiredAccess != (GENERIC_READ | GENERIC_WRITE))
{
DEBUG_WARN("unexpected access to the device: 0x%lX", dwDesiredAccess);
@ -1073,7 +1073,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
SetLastError(ERROR_FILE_NOT_FOUND); /* FIXME: ERROR_NOT_SUPPORTED better? */
return INVALID_HANDLE_VALUE;
}
if (QueryCommDevice(lpDeviceName, devicePath, MAX_PATH) <= 0)
{
/* SetLastError(GetLastError()); */
@ -1194,7 +1194,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
* IGNBRK and IXON, see: IOCTL_SERIAL_SET_HANDFLOW
* CSIZE, PARENB and CS8, see: IOCTL_SERIAL_SET_LINE_CONTROL
*/
/* a few more settings required for the redirection */
upcomingTermios.c_cflag |= CLOCAL | CREAD;

View File

@ -3,7 +3,7 @@
* Serial Communication API
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2014 Hewlett-Packard Development Company, L.P.
* Copyright 2014 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -50,11 +50,11 @@ struct winpr_comm
int fd_read;
int fd_read_event; /* as of today, only used by _purge() */
int fd_write;
int fd_write_event; /* as of today, only used by _purge() */
/* permissive mode on errors if TRUE (default is FALSE).
/* permissive mode on errors if TRUE (default is FALSE).
*
* Since not all features are supported, some devices and applications
* can still be functional on such errors.
@ -67,7 +67,7 @@ struct winpr_comm
REMOTE_SERIAL_DRIVER_ID remoteSerialDriverId;
COMMTIMEOUTS timeouts;
CRITICAL_SECTION EventsLock; /* protects counters, WaitEventMask and PendingEvents */
struct serial_icounter_struct counters;
ULONG WaitEventMask;
@ -82,7 +82,7 @@ void _comm_setRemoteSerialDriver(HANDLE hComm, REMOTE_SERIAL_DRIVER_ID);
/* TMP: TODO: move all specific defines and types here? at least SERIAL_EV_* */
#define SERIAL_EV_FREERDP_WAITING 0x4000 /* bit unused by SERIAL_EV_* */
#define SERIAL_EV_FREERDP_STOP 0x8000 /* bit unused by SERIAL_EV_* */
#define SERIAL_EV_FREERDP_STOP 0x8000 /* bit unused by SERIAL_EV_* */
#define FREERDP_PURGE_TXABORT 0x00000001 /* abort pending transmission */
#define FREERDP_PURGE_RXABORT 0x00000002 /* abort pending reception */

View File

@ -82,7 +82,7 @@ static UCHAR _vtime(ULONG Ti)
* ERROR_BAD_DEVICE
*/
BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{
WINPR_COMM* pComm = (WINPR_COMM*) hDevice;
int biggestFd = -1;
@ -146,9 +146,9 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
* 0 | 0 | 0 | N | 0 | 0 | Blocks for N bytes available.
* 0< Ti <MAXULONG | 0 | 0 | N | Ti | 0 | Block on first byte, then use Ti between bytes.
* MAXULONG | 0 | 0 | 0 | 0 | 0 | Returns immediately with bytes available (don't block)
* MAXULONG | MAXULONG | 0< Tc <MAXULONG | N | 0 | Tc | Blocks on first byte during Tc or returns immediately whith bytes available
* MAXULONG | MAXULONG | 0< Tc <MAXULONG | N | 0 | Tc | Blocks on first byte during Tc or returns immediately whith bytes available
* MAXULONG | m | MAXULONG | | Invalid
* 0 | m | 0< Tc <MAXULONG | N | 0 | Tmax | Block on first byte during Tmax or returns immediately whith bytes available
* 0 | m | 0< Tc <MAXULONG | N | 0 | Tmax | Block on first byte during Tmax or returns immediately whith bytes available
* 0< Ti <MAXULONG | m | 0< Tc <MAXULONG | N | Ti | Tmax | Block on first byte, then use Ti between bytes. Tmax is use for the whole system call.
*/
@ -175,13 +175,13 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
{
/* N */
/* vmin = nNumberOfBytesToRead < 256 ? nNumberOfBytesToRead : 255;*/ /* 0xFF */
/* NB: we might wait endlessly with vmin=N, prefer to
* force vmin=1 and return with bytes
* available. FIXME: is a feature disarded here? */
* available. FIXME: is a feature disarded here? */
vmin = 1;
}
/* VTIME */
@ -193,7 +193,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
/* TMAX */
if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutMultiplier == MAXULONG))
{
/* Tc */
@ -204,7 +204,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
/* Tmax */
Tmax = nNumberOfBytesToRead * pTimeouts->ReadTotalTimeoutMultiplier + pTimeouts->ReadTotalTimeoutConstant;
}
if ((currentTermios.c_cc[VMIN] != vmin) || (currentTermios.c_cc[VTIME] != vtime))
{
currentTermios.c_cc[VMIN] = vmin;
@ -254,7 +254,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
SetLastError(ERROR_IO_DEVICE);
return FALSE;
}
if (nbFds == 0)
{
/* timeout */
@ -303,8 +303,8 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (nbRead < 0)
{
DEBUG_WARN("CommReadFile failed, ReadIntervalTimeout=%lu, ReadTotalTimeoutMultiplier=%lu, ReadTotalTimeoutConstant=%lu VMIN=%u, VTIME=%u",
pTimeouts->ReadIntervalTimeout, pTimeouts->ReadTotalTimeoutMultiplier, pTimeouts->ReadTotalTimeoutConstant,
currentTermios.c_cc[VMIN], currentTermios.c_cc[VTIME]);
pTimeouts->ReadIntervalTimeout, pTimeouts->ReadTotalTimeoutMultiplier, pTimeouts->ReadTotalTimeoutConstant,
currentTermios.c_cc[VMIN], currentTermios.c_cc[VTIME]);
DEBUG_WARN("CommReadFile failed, nNumberOfBytesToRead=%lu, errno=[%d] %s", nNumberOfBytesToRead, errno, strerror(errno));
if (errno == EAGAIN)
@ -331,7 +331,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
SetLastError(ERROR_TIMEOUT);
return FALSE;
}
*lpNumberOfBytesRead = nbRead;
return TRUE;
}
@ -350,7 +350,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
* ERROR_BAD_DEVICE
*/
BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
WINPR_COMM* pComm = (WINPR_COMM*) hDevice;
struct timeval tmaxTimeout, *pTmaxTimeout;
@ -409,7 +409,7 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
pTmaxTimeout = &tmaxTimeout;
}
while (*lpNumberOfBytesWritten < nNumberOfBytesToWrite)
{
int biggestFd = -1;
@ -444,7 +444,7 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
SetLastError(ERROR_TIMEOUT);
return FALSE;
}
/* event_set */
@ -479,15 +479,15 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
/* write_set */
if (FD_ISSET(pComm->fd_write, &write_set))
{
ssize_t nbWritten;
nbWritten = write(pComm->fd_write,
lpBuffer + (*lpNumberOfBytesWritten),
nNumberOfBytesToWrite - (*lpNumberOfBytesWritten));
nbWritten = write(pComm->fd_write,
lpBuffer + (*lpNumberOfBytesWritten),
nNumberOfBytesToWrite - (*lpNumberOfBytesWritten));
if (nbWritten < 0)
{
DEBUG_WARN("CommWriteFile failed after %lu bytes written, errno=[%d] %s\n", *lpNumberOfBytesWritten, errno, strerror(errno));
@ -509,7 +509,7 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
return FALSE;
}
}
*lpNumberOfBytesWritten += nbWritten;
}
@ -530,5 +530,5 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
return TRUE;
}
#endif /* _WIN32 */

View File

@ -73,7 +73,7 @@ const char* _comm_serial_ioctl_name(ULONG number)
static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
{
WINPR_COMM* pComm = (WINPR_COMM*) hDevice;
REMOTE_SERIAL_DRIVER* pRemoteSerialDriver = NULL;
@ -109,7 +109,7 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
DEBUG_MSG("CommDeviceIoControl: IoControlCode: 0x%0.8x", dwIoControlCode);
/* remoteSerialDriver to be use ...
/* remoteSerialDriver to be use ...
*
* FIXME: might prefer to use an automatic rather than static structure
*/
@ -188,12 +188,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_properties)
{
COMMPROP *pProperties = (COMMPROP*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(COMMPROP));
if (nOutBufferSize < sizeof(COMMPROP))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_properties(pComm, pProperties))
@ -226,12 +226,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_serial_chars)
{
SERIAL_CHARS *pSerialChars = (SERIAL_CHARS*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(SERIAL_CHARS));
if (nOutBufferSize < sizeof(SERIAL_CHARS))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_serial_chars(pComm, pSerialChars))
@ -264,12 +264,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_line_control)
{
SERIAL_LINE_CONTROL *pLineControl = (SERIAL_LINE_CONTROL*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(SERIAL_LINE_CONTROL));
if (nOutBufferSize < sizeof(SERIAL_LINE_CONTROL))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_line_control(pComm, pLineControl))
@ -302,12 +302,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_handflow)
{
SERIAL_HANDFLOW *pHandflow = (SERIAL_HANDFLOW*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(SERIAL_HANDFLOW));
if (nOutBufferSize < sizeof(SERIAL_HANDFLOW))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_handflow(pComm, pHandflow))
@ -340,12 +340,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_timeouts)
{
SERIAL_TIMEOUTS *pHandflow = (SERIAL_TIMEOUTS*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(SERIAL_TIMEOUTS));
if (nOutBufferSize < sizeof(SERIAL_TIMEOUTS))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_timeouts(pComm, pHandflow))
@ -393,12 +393,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_modemstatus)
{
ULONG *pRegister = (ULONG*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(ULONG));
if (nOutBufferSize < sizeof(ULONG))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_modemstatus(pComm, pRegister))
@ -431,12 +431,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_wait_mask)
{
ULONG *pWaitMask = (ULONG*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(ULONG));
if (nOutBufferSize < sizeof(ULONG))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_wait_mask(pComm, pWaitMask))
@ -452,12 +452,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->wait_on_mask)
{
ULONG *pOutputMask = (ULONG*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(ULONG));
if (nOutBufferSize < sizeof(ULONG))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->wait_on_mask(pComm, pOutputMask))
@ -510,12 +510,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_commstatus)
{
SERIAL_STATUS *pCommstatus = (SERIAL_STATUS*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(SERIAL_STATUS));
if (nOutBufferSize < sizeof(SERIAL_STATUS))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_commstatus(pComm, pCommstatus))
@ -563,12 +563,12 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
if (pRemoteSerialDriver->get_dtrrts)
{
ULONG *pMask = (ULONG*)lpOutBuffer;
assert(nOutBufferSize >= sizeof(ULONG));
if (nOutBufferSize < sizeof(ULONG))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
return FALSE;
}
if (!pRemoteSerialDriver->get_dtrrts(pComm, pMask))
@ -578,15 +578,15 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
return TRUE;
}
break;
}
}
DEBUG_WARN(_T("unsupported IoControlCode=[0x%lX] %s (remote serial driver: %s)"),
dwIoControlCode, _comm_serial_ioctl_name(dwIoControlCode), pRemoteSerialDriver->name);
DEBUG_WARN(_T("unsupported IoControlCode=[0x%lX] %s (remote serial driver: %s)"),
dwIoControlCode, _comm_serial_ioctl_name(dwIoControlCode), pRemoteSerialDriver->name);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
@ -603,7 +603,7 @@ static BOOL _CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
* ERROR_CALL_NOT_IMPLEMENTED unimplemented ioctl
*/
BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
{
WINPR_COMM* pComm = (WINPR_COMM*) hDevice;
BOOL result;
@ -621,14 +621,14 @@ BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffe
}
result = _CommDeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize,
lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
if (pComm->permissive)
{
if (!result)
{
DEBUG_WARN("[permissive]: whereas it failed, made to succeed IoControlCode=[0x%lX] %s, last-error: 0x%lX",
dwIoControlCode, _comm_serial_ioctl_name(dwIoControlCode), GetLastError());
dwIoControlCode, _comm_serial_ioctl_name(dwIoControlCode), GetLastError());
}
return TRUE; /* always! */

View File

@ -37,22 +37,22 @@
* Ntddpar.h http://msdn.microsoft.com/en-us/cc308431.aspx
*/
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
#endif
/* TODO: defines and types below are very similar to those in comm.h, keep only
* those that differ more than the names */
#define STOP_BIT_1 0
#define STOP_BITS_1_5 1
#define STOP_BITS_2 2
#define NO_PARITY 0
#define ODD_PARITY 1
#define EVEN_PARITY 2
#define MARK_PARITY 3
#define SPACE_PARITY 4
#define STOP_BIT_1 0
#define STOP_BITS_1_5 1
#define STOP_BITS_2 2
#define NO_PARITY 0
#define ODD_PARITY 1
#define EVEN_PARITY 2
#define MARK_PARITY 3
#define SPACE_PARITY 4
typedef struct _SERIAL_BAUD_RATE
@ -90,51 +90,51 @@ typedef struct _SERIAL_HANDFLOW
#define SERIAL_DTR_MASK ((ULONG)0x03)
#define SERIAL_DTR_CONTROL ((ULONG)0x01)
#define SERIAL_DTR_HANDSHAKE ((ULONG)0x02)
#define SERIAL_CTS_HANDSHAKE ((ULONG)0x08)
#define SERIAL_DSR_HANDSHAKE ((ULONG)0x10)
#define SERIAL_DCD_HANDSHAKE ((ULONG)0x20)
#define SERIAL_OUT_HANDSHAKEMASK ((ULONG)0x38)
#define SERIAL_DSR_SENSITIVITY ((ULONG)0x40)
#define SERIAL_ERROR_ABORT ((ULONG)0x80000000)
#define SERIAL_CONTROL_INVALID ((ULONG)0x7fffff84)
#define SERIAL_AUTO_TRANSMIT ((ULONG)0x01)
#define SERIAL_AUTO_RECEIVE ((ULONG)0x02)
#define SERIAL_ERROR_CHAR ((ULONG)0x04)
#define SERIAL_NULL_STRIPPING ((ULONG)0x08)
#define SERIAL_BREAK_CHAR ((ULONG)0x10)
#define SERIAL_RTS_MASK ((ULONG)0xc0)
#define SERIAL_RTS_CONTROL ((ULONG)0x40)
#define SERIAL_RTS_HANDSHAKE ((ULONG)0x80)
#define SERIAL_TRANSMIT_TOGGLE ((ULONG)0xc0)
#define SERIAL_XOFF_CONTINUE ((ULONG)0x80000000)
#define SERIAL_FLOW_INVALID ((ULONG)0x7fffff20)
#define SERIAL_DTR_CONTROL ((ULONG)0x01)
#define SERIAL_DTR_HANDSHAKE ((ULONG)0x02)
#define SERIAL_CTS_HANDSHAKE ((ULONG)0x08)
#define SERIAL_DSR_HANDSHAKE ((ULONG)0x10)
#define SERIAL_DCD_HANDSHAKE ((ULONG)0x20)
#define SERIAL_OUT_HANDSHAKEMASK ((ULONG)0x38)
#define SERIAL_DSR_SENSITIVITY ((ULONG)0x40)
#define SERIAL_ERROR_ABORT ((ULONG)0x80000000)
#define SERIAL_CONTROL_INVALID ((ULONG)0x7fffff84)
#define SERIAL_AUTO_TRANSMIT ((ULONG)0x01)
#define SERIAL_AUTO_RECEIVE ((ULONG)0x02)
#define SERIAL_ERROR_CHAR ((ULONG)0x04)
#define SERIAL_NULL_STRIPPING ((ULONG)0x08)
#define SERIAL_BREAK_CHAR ((ULONG)0x10)
#define SERIAL_RTS_MASK ((ULONG)0xc0)
#define SERIAL_RTS_CONTROL ((ULONG)0x40)
#define SERIAL_RTS_HANDSHAKE ((ULONG)0x80)
#define SERIAL_TRANSMIT_TOGGLE ((ULONG)0xc0)
#define SERIAL_XOFF_CONTINUE ((ULONG)0x80000000)
#define SERIAL_FLOW_INVALID ((ULONG)0x7fffff20)
#define SERIAL_SP_SERIALCOMM ((ULONG)0x00000001)
#define SERIAL_SP_UNSPECIFIED ((ULONG)0x00000000)
#define SERIAL_SP_RS232 ((ULONG)0x00000001)
#define SERIAL_SP_PARALLEL ((ULONG)0x00000002)
#define SERIAL_SP_RS422 ((ULONG)0x00000003)
#define SERIAL_SP_RS423 ((ULONG)0x00000004)
#define SERIAL_SP_RS449 ((ULONG)0x00000005)
#define SERIAL_SP_MODEM ((ULONG)0X00000006)
#define SERIAL_SP_FAX ((ULONG)0x00000021)
#define SERIAL_SP_SCANNER ((ULONG)0x00000022)
#define SERIAL_SP_BRIDGE ((ULONG)0x00000100)
#define SERIAL_SP_LAT ((ULONG)0x00000101)
#define SERIAL_SP_TELNET ((ULONG)0x00000102)
#define SERIAL_SP_X25 ((ULONG)0x00000103)
#define SERIAL_SP_SERIALCOMM ((ULONG)0x00000001)
#define SERIAL_SP_UNSPECIFIED ((ULONG)0x00000000)
#define SERIAL_SP_RS232 ((ULONG)0x00000001)
#define SERIAL_SP_PARALLEL ((ULONG)0x00000002)
#define SERIAL_SP_RS422 ((ULONG)0x00000003)
#define SERIAL_SP_RS423 ((ULONG)0x00000004)
#define SERIAL_SP_RS449 ((ULONG)0x00000005)
#define SERIAL_SP_MODEM ((ULONG)0X00000006)
#define SERIAL_SP_FAX ((ULONG)0x00000021)
#define SERIAL_SP_SCANNER ((ULONG)0x00000022)
#define SERIAL_SP_BRIDGE ((ULONG)0x00000100)
#define SERIAL_SP_LAT ((ULONG)0x00000101)
#define SERIAL_SP_TELNET ((ULONG)0x00000102)
#define SERIAL_SP_X25 ((ULONG)0x00000103)
typedef struct _SERIAL_TIMEOUTS
{
ULONG ReadIntervalTimeout;
ULONG ReadTotalTimeoutMultiplier;
ULONG ReadTotalTimeoutConstant;
ULONG WriteTotalTimeoutMultiplier;
ULONG WriteTotalTimeoutConstant;
ULONG ReadIntervalTimeout;
ULONG ReadTotalTimeoutMultiplier;
ULONG ReadTotalTimeoutConstant;
ULONG WriteTotalTimeoutMultiplier;
ULONG WriteTotalTimeoutConstant;
} SERIAL_TIMEOUTS,*PSERIAL_TIMEOUTS;
@ -148,19 +148,19 @@ typedef struct _SERIAL_TIMEOUTS
#define SERIAL_MSR_DCD 0x80
#define SERIAL_EV_RXCHAR 0x0001
#define SERIAL_EV_RXFLAG 0x0002
#define SERIAL_EV_TXEMPTY 0x0004
#define SERIAL_EV_CTS 0x0008
#define SERIAL_EV_DSR 0x0010
#define SERIAL_EV_RLSD 0x0020
#define SERIAL_EV_BREAK 0x0040
#define SERIAL_EV_ERR 0x0080
#define SERIAL_EV_RING 0x0100
#define SERIAL_EV_PERR 0x0200
#define SERIAL_EV_RX80FULL 0x0400
#define SERIAL_EV_EVENT1 0x0800
#define SERIAL_EV_EVENT2 0x1000
#define SERIAL_EV_RXCHAR 0x0001
#define SERIAL_EV_RXFLAG 0x0002
#define SERIAL_EV_TXEMPTY 0x0004
#define SERIAL_EV_CTS 0x0008
#define SERIAL_EV_DSR 0x0010
#define SERIAL_EV_RLSD 0x0020
#define SERIAL_EV_BREAK 0x0040
#define SERIAL_EV_ERR 0x0080
#define SERIAL_EV_RING 0x0100
#define SERIAL_EV_PERR 0x0200
#define SERIAL_EV_RX80FULL 0x0400
#define SERIAL_EV_EVENT1 0x0800
#define SERIAL_EV_EVENT2 0x1000
typedef struct _SERIAL_QUEUE_SIZE
{
@ -169,41 +169,41 @@ typedef struct _SERIAL_QUEUE_SIZE
} SERIAL_QUEUE_SIZE, *PSERIAL_QUEUE_SIZE;
#define SERIAL_PURGE_TXABORT 0x00000001
#define SERIAL_PURGE_RXABORT 0x00000002
#define SERIAL_PURGE_TXCLEAR 0x00000004
#define SERIAL_PURGE_RXCLEAR 0x00000008
#define SERIAL_PURGE_TXABORT 0x00000001
#define SERIAL_PURGE_RXABORT 0x00000002
#define SERIAL_PURGE_TXCLEAR 0x00000004
#define SERIAL_PURGE_RXCLEAR 0x00000008
typedef struct _SERIAL_STATUS
{
ULONG Errors;
ULONG HoldReasons;
ULONG AmountInInQueue;
ULONG AmountInOutQueue;
{
ULONG Errors;
ULONG HoldReasons;
ULONG AmountInInQueue;
ULONG AmountInOutQueue;
BOOLEAN EofReceived;
BOOLEAN WaitForImmediate;
} SERIAL_STATUS, *PSERIAL_STATUS;
BOOLEAN WaitForImmediate;
} SERIAL_STATUS, *PSERIAL_STATUS;
#define SERIAL_TX_WAITING_FOR_CTS ((ULONG)0x00000001)
#define SERIAL_TX_WAITING_FOR_DSR ((ULONG)0x00000002)
#define SERIAL_TX_WAITING_FOR_DCD ((ULONG)0x00000004)
#define SERIAL_TX_WAITING_FOR_XON ((ULONG)0x00000008)
#define SERIAL_TX_WAITING_XOFF_SENT ((ULONG)0x00000010)
#define SERIAL_TX_WAITING_ON_BREAK ((ULONG)0x00000020)
#define SERIAL_RX_WAITING_FOR_DSR ((ULONG)0x00000040)
#define SERIAL_ERROR_BREAK ((ULONG)0x00000001)
#define SERIAL_ERROR_FRAMING ((ULONG)0x00000002)
#define SERIAL_ERROR_OVERRUN ((ULONG)0x00000004)
#define SERIAL_ERROR_QUEUEOVERRUN ((ULONG)0x00000008)
#define SERIAL_ERROR_PARITY ((ULONG)0x00000010)
#define SERIAL_TX_WAITING_FOR_CTS ((ULONG)0x00000001)
#define SERIAL_TX_WAITING_FOR_DSR ((ULONG)0x00000002)
#define SERIAL_TX_WAITING_FOR_DCD ((ULONG)0x00000004)
#define SERIAL_TX_WAITING_FOR_XON ((ULONG)0x00000008)
#define SERIAL_TX_WAITING_XOFF_SENT ((ULONG)0x00000010)
#define SERIAL_TX_WAITING_ON_BREAK ((ULONG)0x00000020)
#define SERIAL_RX_WAITING_FOR_DSR ((ULONG)0x00000040)
#define SERIAL_DTR_STATE ((ULONG)0x00000001)
#define SERIAL_RTS_STATE ((ULONG)0x00000002)
#define SERIAL_CTS_STATE ((ULONG)0x00000010)
#define SERIAL_DSR_STATE ((ULONG)0x00000020)
#define SERIAL_RI_STATE ((ULONG)0x00000040)
#define SERIAL_DCD_STATE ((ULONG)0x00000080)
#define SERIAL_ERROR_BREAK ((ULONG)0x00000001)
#define SERIAL_ERROR_FRAMING ((ULONG)0x00000002)
#define SERIAL_ERROR_OVERRUN ((ULONG)0x00000004)
#define SERIAL_ERROR_QUEUEOVERRUN ((ULONG)0x00000008)
#define SERIAL_ERROR_PARITY ((ULONG)0x00000010)
#define SERIAL_DTR_STATE ((ULONG)0x00000001)
#define SERIAL_RTS_STATE ((ULONG)0x00000002)
#define SERIAL_CTS_STATE ((ULONG)0x00000010)
#define SERIAL_DSR_STATE ((ULONG)0x00000020)
#define SERIAL_RI_STATE ((ULONG)0x00000040)
#define SERIAL_DCD_STATE ((ULONG)0x00000080)
/**
* A function might be NULL if not supported by the underlying remote driver.

View File

@ -56,12 +56,12 @@ static BOOL _get_serial_chars(WINPR_COMM* pComm, SERIAL_CHARS* pSerialChars)
/* http://msdn.microsoft.com/en-us/library/windows/hardware/hh439605%28v=vs.85%29.aspx */
/* FIXME: only using the Serial.sys' events, complete the support of the remaining events */
static const ULONG _SERCX2_SYS_SUPPORTED_EV_MASK =
static const ULONG _SERCX2_SYS_SUPPORTED_EV_MASK =
SERIAL_EV_RXCHAR |
SERIAL_EV_RXFLAG |
SERIAL_EV_TXEMPTY |
SERIAL_EV_CTS |
SERIAL_EV_DSR |
SERIAL_EV_DSR |
SERIAL_EV_RLSD |
SERIAL_EV_BREAK |
SERIAL_EV_ERR |
@ -96,7 +96,7 @@ static BOOL _set_wait_mask(WINPR_COMM *pComm, const ULONG *pWaitMask)
static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
{
REMOTE_SERIAL_DRIVER* pSerialSys = SerialSys_s();
/* http://msdn.microsoft.com/en-us/library/windows/hardware/ff546655%28v=vs.85%29.aspx */
if ((*pPurgeMask & SERIAL_PURGE_RXCLEAR) && !(*pPurgeMask & SERIAL_PURGE_RXABORT))
@ -120,8 +120,8 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
/* specific functions only */
static REMOTE_SERIAL_DRIVER _SerCx2Sys =
{
static REMOTE_SERIAL_DRIVER _SerCx2Sys =
{
.id = RemoteSerialDriverSerCx2Sys,
.name = _T("SerCx2.sys"),
.set_baud_rate = NULL,

View File

@ -24,13 +24,13 @@
#include "comm_ioctl.h"
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
#endif
REMOTE_SERIAL_DRIVER* SerCx2Sys_s();
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif

View File

@ -177,7 +177,7 @@ static BOOL _set_baud_rate(WINPR_COMM *pComm, const SERIAL_BAUD_RATE *pBaudRate)
{
if (_SERCX_SYS_BAUD_TABLE[i][1] == pBaudRate->BaudRate)
{
newSpeed = _SERCX_SYS_BAUD_TABLE[i][0];
newSpeed = _SERCX_SYS_BAUD_TABLE[i][0];
if (cfsetspeed(&futureState, newSpeed) < 0)
{
DEBUG_WARN("failed to set speed 0x%x (%lu)", newSpeed, pBaudRate->BaudRate);
@ -239,7 +239,7 @@ static BOOL _set_handflow(WINPR_COMM *pComm, const SERIAL_HANDFLOW *pHandflow)
memcpy(&SerCxHandflow, pHandflow, sizeof(SERIAL_HANDFLOW));
/* filter out unsupported bits by SerCx.sys
/* filter out unsupported bits by SerCx.sys
*
* http://msdn.microsoft.com/en-us/library/windows/hardware/jj680685%28v=vs.85%29.aspx
*/
@ -303,7 +303,7 @@ static BOOL _set_handflow(WINPR_COMM *pComm, const SERIAL_HANDFLOW *pHandflow)
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
result = FALSE;
}
if (!pSerialSys->set_handflow(pComm, &SerCxHandflow))
return FALSE;
@ -318,7 +318,7 @@ static BOOL _get_handflow(WINPR_COMM *pComm, SERIAL_HANDFLOW *pHandflow)
result = pSerialSys->get_handflow(pComm, pHandflow);
/* filter out unsupported bits by SerCx.sys
/* filter out unsupported bits by SerCx.sys
*
* http://msdn.microsoft.com/en-us/library/windows/hardware/jj680685%28v=vs.85%29.aspx
*/
@ -331,12 +331,12 @@ static BOOL _get_handflow(WINPR_COMM *pComm, SERIAL_HANDFLOW *pHandflow)
/* http://msdn.microsoft.com/en-us/library/windows/hardware/hh439605%28v=vs.85%29.aspx */
static const ULONG _SERCX_SYS_SUPPORTED_EV_MASK =
static const ULONG _SERCX_SYS_SUPPORTED_EV_MASK =
SERIAL_EV_RXCHAR |
/* SERIAL_EV_RXFLAG | */
SERIAL_EV_TXEMPTY |
SERIAL_EV_CTS |
SERIAL_EV_DSR |
SERIAL_EV_DSR |
SERIAL_EV_RLSD |
SERIAL_EV_BREAK |
SERIAL_EV_ERR |
@ -369,7 +369,7 @@ static BOOL _set_wait_mask(WINPR_COMM *pComm, const ULONG *pWaitMask)
/* specific functions only */
static REMOTE_SERIAL_DRIVER _SerCxSys =
static REMOTE_SERIAL_DRIVER _SerCxSys =
{
.id = RemoteSerialDriverSerCxSys,
.name = _T("SerCx.sys"),

View File

@ -24,13 +24,13 @@
#include "comm_ioctl.h"
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
#endif
REMOTE_SERIAL_DRIVER* SerCxSys_s();
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif

View File

@ -44,7 +44,7 @@
/*
* Linux, Windows speeds
*
*
*/
static const speed_t _SERIAL_SYS_BAUD_TABLE[][2] = {
#ifdef B0
@ -105,47 +105,8 @@ static const speed_t _SERIAL_SYS_BAUD_TABLE[][2] = {
#ifdef B115200
{B115200, SERIAL_BAUD_115200}, /* _SERIAL_MAX_BAUD */
#endif
/* undefined by serial.sys:
#ifdef B230400
{B230400, },
#endif
#ifdef B460800
{B460800, },
#endif
#ifdef B500000
{B500000, },
#endif
#ifdef B576000
{B576000, },
#endif
#ifdef B921600
{B921600, },
#endif
#ifdef B1000000
{B1000000, },
#endif
#ifdef B1152000
{B1152000, },
#endif
#ifdef B1500000
{B1500000, },
#endif
#ifdef B2000000
{B2000000, },
#endif
#ifdef B2500000
{B2500000, },
#endif
#ifdef B3000000
{B3000000, },
#endif
#ifdef B3500000
{B3500000, },
#endif
#ifdef B4000000
{B4000000, }, __MAX_BAUD
#endif
*/
/* no greater speed defined by serial.sys */
};
#define _SERIAL_MAX_BAUD B115200
@ -185,7 +146,7 @@ static BOOL _get_properties(WINPR_COMM *pComm, COMMPROP *pProperties)
pProperties->dwProvSubType = PST_UNSPECIFIED;
/* TMP: TODO: to be finalized */
pProperties->dwProvCapabilities =
pProperties->dwProvCapabilities =
/*PCF_16BITMODE | PCF_DTRDSR |*/ PCF_INTTIMEOUTS | PCF_PARITY_CHECK | /*PCF_RLSD | */
PCF_RTSCTS | PCF_SETXCHAR | /*PCF_SPECIALCHARS | PCF_TOTALTIMEOUTS |*/ PCF_XONXOFF;
@ -330,7 +291,7 @@ static BOOL _set_serial_chars(WINPR_COMM *pComm, const SERIAL_CHARS *pSerialChar
/* According the Linux's n_tty discipline, charaters with a
* parity error can only be let unchanged, replaced by \0 or
* get the prefix the prefix \377 \0
* get the prefix the prefix \377 \0
*/
/* FIXME: see also: _set_handflow() */
@ -384,13 +345,13 @@ static BOOL _get_serial_chars(WINPR_COMM *pComm, SERIAL_CHARS *pSerialChars)
}
ZeroMemory(pSerialChars, sizeof(SERIAL_CHARS));
/* EofChar unsupported */
/* ErrorChar unsupported */
/* BreakChar unsupported */
/* TMP: FIXME: see also: _set_serial_chars() */
/* EventChar */
@ -436,7 +397,7 @@ static BOOL _set_line_control(WINPR_COMM *pComm, const SERIAL_LINE_CONTROL *pLin
case STOP_BITS_1_5:
DEBUG_WARN("Unsupported one and a half stop bits.");
break;
case STOP_BITS_2:
upcomingTermios.c_cflag |= CSTOPB;
break;
@ -445,7 +406,7 @@ static BOOL _set_line_control(WINPR_COMM *pComm, const SERIAL_LINE_CONTROL *pLin
DEBUG_WARN("unexpected number of stop bits: %d\n", pLineControl->StopBits);
result = FALSE; /* but keep on */
break;
}
}
switch (pLineControl->Parity)
@ -580,11 +541,11 @@ static BOOL _set_handflow(WINPR_COMM *pComm, const SERIAL_HANDFLOW *pHandflow)
/* logical XOR */
if ((!(pHandflow->ControlHandShake & SERIAL_DTR_CONTROL) && (pHandflow->FlowReplace & SERIAL_RTS_CONTROL)) ||
((pHandflow->ControlHandShake & SERIAL_DTR_CONTROL) && !(pHandflow->FlowReplace & SERIAL_RTS_CONTROL)))
((pHandflow->ControlHandShake & SERIAL_DTR_CONTROL) && !(pHandflow->FlowReplace & SERIAL_RTS_CONTROL)))
{
DEBUG_WARN("SERIAL_DTR_CONTROL:%s and SERIAL_RTS_CONTROL:%s cannot be different, HUPCL will be set since it is claimed for one of the both lines.",
(pHandflow->ControlHandShake & SERIAL_DTR_CONTROL) ? "ON" : "OFF",
(pHandflow->FlowReplace & SERIAL_RTS_CONTROL) ? "ON" : "OFF");
(pHandflow->ControlHandShake & SERIAL_DTR_CONTROL) ? "ON" : "OFF",
(pHandflow->FlowReplace & SERIAL_RTS_CONTROL) ? "ON" : "OFF");
}
if ((pHandflow->ControlHandShake & SERIAL_DTR_CONTROL) || (pHandflow->FlowReplace & SERIAL_RTS_CONTROL))
@ -604,11 +565,11 @@ static BOOL _set_handflow(WINPR_COMM *pComm, const SERIAL_HANDFLOW *pHandflow)
/* logical XOR */
if ((!(pHandflow->ControlHandShake & SERIAL_CTS_HANDSHAKE) && (pHandflow->FlowReplace & SERIAL_RTS_HANDSHAKE)) ||
((pHandflow->ControlHandShake & SERIAL_CTS_HANDSHAKE) && !(pHandflow->FlowReplace & SERIAL_RTS_HANDSHAKE)))
((pHandflow->ControlHandShake & SERIAL_CTS_HANDSHAKE) && !(pHandflow->FlowReplace & SERIAL_RTS_HANDSHAKE)))
{
DEBUG_WARN("SERIAL_CTS_HANDSHAKE:%s and SERIAL_RTS_HANDSHAKE:%s cannot be different, CRTSCTS will be set since it is claimed for one of the both lines.",
(pHandflow->ControlHandShake & SERIAL_CTS_HANDSHAKE) ? "ON" : "OFF",
(pHandflow->FlowReplace & SERIAL_RTS_HANDSHAKE) ? "ON" : "OFF");
(pHandflow->ControlHandShake & SERIAL_CTS_HANDSHAKE) ? "ON" : "OFF",
(pHandflow->FlowReplace & SERIAL_RTS_HANDSHAKE) ? "ON" : "OFF");
}
if ((pHandflow->ControlHandShake & SERIAL_CTS_HANDSHAKE) || (pHandflow->FlowReplace & SERIAL_RTS_HANDSHAKE))
@ -724,13 +685,13 @@ static BOOL _set_handflow(WINPR_COMM *pComm, const SERIAL_HANDFLOW *pHandflow)
}
/* XonLimit */
// FIXME: could be implemented during read/write I/O
if (pHandflow->XonLimit != TTY_THRESHOLD_UNTHROTTLE)
{
DEBUG_WARN("Attempt to set XonLimit with an unsupported value: %lu", pHandflow->XonLimit);
SetLastError(ERROR_NOT_SUPPORTED);
result = FALSE; /* but keep on */
result = FALSE; /* but keep on */
}
/* XoffChar */
@ -740,7 +701,7 @@ static BOOL _set_handflow(WINPR_COMM *pComm, const SERIAL_HANDFLOW *pHandflow)
{
DEBUG_WARN("Attempt to set XoffLimit with an unsupported value: %lu", pHandflow->XoffLimit);
SetLastError(ERROR_NOT_SUPPORTED);
result = FALSE; /* but keep on */
result = FALSE; /* but keep on */
}
@ -774,7 +735,7 @@ static BOOL _get_handflow(WINPR_COMM *pComm, SERIAL_HANDFLOW *pHandflow)
pHandflow->ControlHandShake |= SERIAL_DTR_CONTROL;
/* SERIAL_DTR_HANDSHAKE unsupported */
if (currentTermios.c_cflag & CRTSCTS)
pHandflow->ControlHandShake |= SERIAL_CTS_HANDSHAKE;
@ -782,7 +743,7 @@ static BOOL _get_handflow(WINPR_COMM *pComm, SERIAL_HANDFLOW *pHandflow)
/* SERIAL_DCD_HANDSHAKE unsupported */
/* SERIAL_DSR_SENSITIVITY unsupported */
/* SERIAL_DSR_SENSITIVITY unsupported */
/* SERIAL_ERROR_ABORT unsupported */
@ -964,7 +925,7 @@ static BOOL _get_modemstatus(WINPR_COMM *pComm, ULONG *pRegister)
}
ZeroMemory(pRegister, sizeof(ULONG));
/* FIXME: Is the last read of the MSR register available or
* cached somewhere? Not quite sure we need to return the 4
* LSBits anyway. A direct access to the register -- which
@ -990,12 +951,12 @@ static BOOL _get_modemstatus(WINPR_COMM *pComm, ULONG *pRegister)
}
/* http://msdn.microsoft.com/en-us/library/windows/hardware/hh439605%28v=vs.85%29.aspx */
static const ULONG _SERIAL_SYS_SUPPORTED_EV_MASK =
static const ULONG _SERIAL_SYS_SUPPORTED_EV_MASK =
SERIAL_EV_RXCHAR |
SERIAL_EV_RXFLAG |
SERIAL_EV_TXEMPTY |
SERIAL_EV_CTS |
SERIAL_EV_DSR |
SERIAL_EV_DSR |
SERIAL_EV_RLSD |
SERIAL_EV_BREAK |
SERIAL_EV_ERR |
@ -1113,7 +1074,7 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
/* FIXME: currently relying too much on the fact the server
* sends a single IRP_MJ_WRITE or IRP_MJ_READ at a time
* (taking care though that one IRP_MJ_WRITE and one
@ -1144,7 +1105,7 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
{
DEBUG_WARN("eventfd_write failed, errno=[%d] %s", errno, strerror(errno));
}
assert(errno == EAGAIN); /* no reader <=> no pending IRP_MJ_READ */
}
}
@ -1152,7 +1113,7 @@ static BOOL _purge(WINPR_COMM *pComm, const ULONG *pPurgeMask)
if (*pPurgeMask & SERIAL_PURGE_TXCLEAR)
{
/* Purges the transmit buffer, if one exists. */
if (tcflush(pComm->fd, TCOFLUSH) < 0)
{
DEBUG_WARN("tcflush(TCOFLUSH) failure, errno=[%d] %s", errno, strerror(errno));
@ -1185,7 +1146,7 @@ static BOOL _get_commstatus(WINPR_COMM *pComm, SERIAL_STATUS *pCommstatus)
{
/* http://msdn.microsoft.com/en-us/library/jj673022%28v=vs.85%29.aspx */
struct serial_icounter_struct currentCounters;
struct serial_icounter_struct currentCounters;
/* NB: ensure to leave the critical section before to return */
EnterCriticalSection(&pComm->EventsLock);
@ -1238,7 +1199,7 @@ static BOOL _get_commstatus(WINPR_COMM *pComm, SERIAL_STATUS *pCommstatus)
/* HoldReasons */
/* TODO: SERIAL_TX_WAITING_FOR_CTS */
/* TODO: SERIAL_TX_WAITING_FOR_DSR */
@ -1280,7 +1241,7 @@ static BOOL _get_commstatus(WINPR_COMM *pComm, SERIAL_STATUS *pCommstatus)
/* BOOLEAN WaitForImmediate; TMP: TODO: once IOCTL_SERIAL_IMMEDIATE_CHAR supported */
/* other events based on counters */
@ -1290,7 +1251,7 @@ static BOOL _get_commstatus(WINPR_COMM *pComm, SERIAL_STATUS *pCommstatus)
}
if ((currentCounters.tx != pComm->counters.tx) && /* at least a transmission occurred AND ...*/
(pCommstatus->AmountInOutQueue == 0)) /* output bufer is now empty */
(pCommstatus->AmountInOutQueue == 0)) /* output bufer is now empty */
{
pComm->PendingEvents |= SERIAL_EV_TXEMPTY;
}
@ -1386,7 +1347,7 @@ static BOOL _wait_on_mask(WINPR_COMM *pComm, ULONG *pOutputMask)
/* NB: ensure to leave the critical section before to return */
EnterCriticalSection(&pComm->EventsLock);
if (pComm->PendingEvents & SERIAL_EV_FREERDP_STOP)
{
pComm->PendingEvents &= ~SERIAL_EV_FREERDP_STOP;
@ -1460,7 +1421,7 @@ static BOOL _set_break_on(WINPR_COMM *pComm)
return TRUE;
}
static BOOL _set_break_off(WINPR_COMM *pComm)
{
@ -1512,17 +1473,17 @@ BOOL _get_dtrrts(WINPR_COMM *pComm, ULONG *pMask)
}
*pMask = 0;
if (!(lines & TIOCM_DTR))
*pMask |= SERIAL_DTR_STATE;
if (!(lines & TIOCM_RTS))
*pMask |= SERIAL_RTS_STATE;
return TRUE;
}
static REMOTE_SERIAL_DRIVER _SerialSys =
static REMOTE_SERIAL_DRIVER _SerialSys =
{
.id = RemoteSerialDriverSerialSys,
.name = _T("Serial.sys"),

View File

@ -24,13 +24,13 @@
#include "comm_ioctl.h"
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
#endif
REMOTE_SERIAL_DRIVER* SerialSys_s();
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif

View File

@ -33,8 +33,8 @@ int TestCommConfig(int argc, char* argv[])
COMMPROP commProp;
hComm = CreateFileA(lpFileName,
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm && (hComm != INVALID_HANDLE_VALUE))
{
@ -51,12 +51,12 @@ int TestCommConfig(int argc, char* argv[])
}
hComm = CreateFileA(lpFileName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_WRITE, /* invalid parmaeter */
NULL,
CREATE_NEW, /* invalid parameter */
0,
(HANDLE)1234); /* invalid parmaeter */
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_WRITE, /* invalid parmaeter */
NULL,
CREATE_NEW, /* invalid parameter */
0,
(HANDLE)1234); /* invalid parmaeter */
if (hComm != INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: could create a handle with some invalid parameters %s\n", lpFileName);
@ -65,8 +65,8 @@ int TestCommConfig(int argc, char* argv[])
hComm = CreateFileA(lpFileName,
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (!hComm || (hComm == INVALID_HANDLE_VALUE))
{
@ -139,4 +139,3 @@ int TestCommConfig(int argc, char* argv[])
return 0;
}

View File

@ -32,9 +32,9 @@ static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
if ((!expectedResult && result) || (expectedResult && !result)) /* logical XOR */
{
_tprintf(_T("DefineCommDevice failure: device name: %s, expected result: %s, result: %s\n"),
lpDeviceName,
(expectedResult ? "TRUE" : "FALSE"),
(result ? "TRUE" : "FALSE"));
lpDeviceName,
(expectedResult ? "TRUE" : "FALSE"),
(result ? "TRUE" : "FALSE"));
return FALSE;
}
@ -43,9 +43,9 @@ static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
if ((!expectedResult && result) || (expectedResult && !result)) /* logical XOR */
{
_tprintf(_T("IsCommDevice failure: device name: %s, expected result: %s, result: %s\n"),
lpDeviceName,
(expectedResult ? "TRUE" : "FALSE"),
(result ? "TRUE" : "FALSE"));
lpDeviceName,
(expectedResult ? "TRUE" : "FALSE"),
(result ? "TRUE" : "FALSE"));
return FALSE;
}
@ -61,8 +61,8 @@ static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
if (_tcscmp(_T("/dev/test"), lpTargetPath) != 0)
{
_tprintf(_T("QueryCommDevice failure: device name: %s, expected result: %s, result: %s\n"),
lpDeviceName, _T("/dev/test"), lpTargetPath);
_tprintf(_T("QueryCommDevice failure: device name: %s, expected result: %s, result: %s\n"),
lpDeviceName, _T("/dev/test"), lpTargetPath);
return FALSE;
}
@ -77,8 +77,8 @@ static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
{
if (tcslen > 0)
{
_tprintf(_T("QueryCommDevice failure: device name: %s, expected result: <none>, result: %d %s\n"),
lpDeviceName, tcslen, lpTargetPath);
_tprintf(_T("QueryCommDevice failure: device name: %s, expected result: <none>, result: %d %s\n"),
lpDeviceName, tcslen, lpTargetPath);
return FALSE;
}

View File

@ -39,15 +39,15 @@ int TestControlSettings(int argc, char* argv[])
}
hComm = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
return EXIT_FAILURE;
}
ZeroMemory(&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
@ -55,7 +55,7 @@ int TestControlSettings(int argc, char* argv[])
{
fprintf(stderr, "GetCommState failure; GetLastError(): %0.8x\n", GetLastError());
return FALSE;
}
}
/* Test 1 */
@ -67,7 +67,7 @@ int TestControlSettings(int argc, char* argv[])
{
fprintf(stderr, "SetCommState failure; GetLastError(): %0.8x\n", GetLastError());
return FALSE;
}
}
ZeroMemory(&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
@ -75,13 +75,13 @@ int TestControlSettings(int argc, char* argv[])
{
fprintf(stderr, "GetCommState failure; GetLastError(): %0.8x\n", GetLastError());
return FALSE;
}
}
if ((dcb.ByteSize != 5) || (dcb.StopBits != ONESTOPBIT) || (dcb.Parity != MARKPARITY))
{
fprintf(stderr, "test1 failed.\n");
return FALSE;
}
}
/* Test 2 */
@ -94,7 +94,7 @@ int TestControlSettings(int argc, char* argv[])
{
fprintf(stderr, "SetCommState failure; GetLastError(): %0.8x\n", GetLastError());
return FALSE;
}
}
ZeroMemory(&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
@ -102,13 +102,13 @@ int TestControlSettings(int argc, char* argv[])
{
fprintf(stderr, "GetCommState failure; GetLastError(): %0.8x\n", GetLastError());
return FALSE;
}
}
if ((dcb.ByteSize != 8) || (dcb.StopBits != ONESTOPBIT) || (dcb.Parity != NOPARITY))
{
fprintf(stderr, "test2 failed.\n");
return FALSE;
}
}
if (!CloseHandle(hComm))

View File

@ -55,7 +55,7 @@ static BOOL test_generic(HANDLE hComm)
printf("GetCommState failure: Ox%x, with adjusted DCBlength\n", GetLastError());
return FALSE;
}
pDcb = (DCB*)calloc(1, sizeof(DCB) * 2);
pDcb->DCBlength = sizeof(DCB) * 2;
result = GetCommState(hComm, pDcb);
@ -84,8 +84,8 @@ int TestGetCommState(int argc, char* argv[])
}
hComm = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
printf("CreateFileA failure: 0x%x\n", GetLastError());

View File

@ -46,8 +46,8 @@ int TestHandflow(int argc, char* argv[])
}
hComm = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());

View File

@ -46,7 +46,7 @@ static BOOL test_SerCxSys(HANDLE hComm)
{
fprintf(stderr, "GetCommState failure, GetLastError(): 0x%0.8x\n", GetLastError());
return FALSE;
}
}
if ((dcb.XonChar == '\0') || (dcb.XoffChar == '\0'))
{
@ -115,7 +115,7 @@ static BOOL test_SerCx2Sys(HANDLE hComm)
{
fprintf(stderr, "GetCommState failure; GetLastError(): %0.8x\n", GetLastError());
return FALSE;
}
}
if ((dcb.ErrorChar != '\0') || (dcb.EofChar != '\0') || (dcb.EvtChar != '\0') || (dcb.XonChar != '\0') || (dcb.XoffChar != '\0'))
{
@ -140,8 +140,8 @@ int TestSerialChars(int argc, char* argv[])
}
hComm = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());

View File

@ -269,7 +269,7 @@ static BOOL test_generic(HANDLE hComm)
{
DCB dcb, dcb2;
BOOL result;
init_empty_dcb(&dcb);
result = GetCommState(hComm, &dcb);
if (!result)
@ -329,8 +329,8 @@ int TestSetCommState(int argc, char* argv[])
}
hComm = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());

View File

@ -87,8 +87,8 @@ int TestTimeouts(int argc, char* argv[])
}
hComm = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());