if (flags & SP_MODE_WRITE)
desired_access |= GENERIC_WRITE;
- port->hdl = CreateFile(escaped_port_name, desired_access, 0, 0,
+ port->hdl = CreateFileA(escaped_port_name, desired_access, 0, 0,
OPEN_EXISTING, flags_and_attributes, 0);
free(escaped_port_name);
{
TRACE("%p", port);
+#ifdef __CYGWIN__
+ /* TIOCOUTQ is not defined in Cygwin headers */
+ RETURN_ERROR(SP_ERR_SUPP,
+ "Getting output bytes waiting is not supported on Cygwin");
+#else
CHECK_OPEN_PORT();
DEBUG_FMT("Checking output bytes waiting on port %s", port->name);
RETURN_FAIL("TIOCOUTQ ioctl failed");
RETURN_INT(bytes_waiting);
#endif
+#endif
}
SP_API enum sp_return sp_new_event_set(struct sp_event_set **result_ptr)
DEBUG_FMT("Setting configuration for port %s", port->name);
#ifdef _WIN32
+ BYTE* new_buf;
TRY(await_write_completion(port));
/* Allocate write buffer for 50ms of data at baud rate. */
port->write_buf_size = max(config->baudrate / (8 * 20), 1);
- port->write_buf = realloc(port->write_buf,
- port->write_buf_size);
-
- if (!port->write_buf)
+ new_buf = realloc(port->write_buf, port->write_buf_size);
+ if (!new_buf)
RETURN_ERROR(SP_ERR_MEM, "Allocating write buffer failed");
+ port->write_buf = new_buf;
}
if (config->bits >= 0)
TRACE_VOID();
#ifdef _WIN32
- TCHAR *message;
+ char *message;
DWORD error = GetLastError();
- DWORD length = FormatMessage(
+ DWORD length = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &message,
+ (LPSTR) &message,
0, NULL );
if (length >= 2 && message[length - 2] == '\r')