Remove native win32 support. We have no report that LCDproc can be natively
compiled and used with recent Windows systems (Windows Vista/7). Except for serial drivers (and those using USB->serial adapters) drivers are not expected to work with those systems.
This commit is contained in:
@@ -26,6 +26,7 @@ v.0.5dev (ongoing development)
|
||||
* shuttleVFD: Add support for devices with USB VID 0x1308 again
|
||||
* CFontzPacket: Add CFA-533. Use HD44780 character mapping for CFA533/633.
|
||||
* CFontz633: Deprecate this driver. Use CFontzPacket with Model=633 instead!
|
||||
- Remove native win32 support.
|
||||
|
||||
v0.5.3
|
||||
+ lcdexec: notification when called program finishes
|
||||
|
||||
+2
-32
@@ -14,12 +14,8 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#ifndef WIN32
|
||||
# include <errno.h>
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -219,20 +215,10 @@ driver_bind_module(Driver *driver)
|
||||
debug(RPT_DEBUG, "%s(driver=[%.40s])", __FUNCTION__, driver->name);
|
||||
|
||||
/* Load the module */
|
||||
#ifndef WIN32
|
||||
driver->module_handle = dlopen(driver->filename, RTLD_NOW);
|
||||
#else
|
||||
driver->module_handle = LoadLibraryEx((driver->filename), NULL, 0);
|
||||
#endif
|
||||
if (driver->module_handle == NULL) {
|
||||
#ifndef WIN32
|
||||
report(RPT_ERR, "Could not open driver module %.40s: %s",
|
||||
driver->filename, dlerror());
|
||||
#else
|
||||
/* REVISIT: replace dlerror() */
|
||||
report(RPT_ERR, "Could not open driver module %.40s.",
|
||||
driver->filename);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -249,21 +235,13 @@ driver_bind_module(Driver *driver)
|
||||
strcpy(s, *(driver->symbol_prefix));
|
||||
strcat(s, driver_symbols[i].name);
|
||||
debug(RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, s);
|
||||
#ifndef WIN32
|
||||
*p = dlsym(driver->module_handle, s);
|
||||
#else
|
||||
*p = (void(*)()) (GetProcAddress(driver->module_handle, s));
|
||||
#endif
|
||||
free(s);
|
||||
}
|
||||
/* 2) try to retrieve the symbol without the symbol prefix */
|
||||
if (*p == NULL) {
|
||||
debug(RPT_DEBUG, "%s: finding symbol: %s", __FUNCTION__, driver_symbols[i].name);
|
||||
#ifndef WIN32
|
||||
*p = dlsym(driver->module_handle, driver_symbols[i].name);
|
||||
#else
|
||||
*p = (void(*)()) (GetProcAddress(driver->module_handle, driver_symbols[i].name));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (*p != NULL) {
|
||||
@@ -283,11 +261,7 @@ driver_bind_module(Driver *driver)
|
||||
if (missing_symbols > 0) {
|
||||
report(RPT_ERR, "Driver [%.40s] misses %d required symbols",
|
||||
driver->name, missing_symbols);
|
||||
#ifndef WIN32
|
||||
dlclose(driver->module_handle);
|
||||
#else
|
||||
FreeLibrary(driver->module_handle);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -325,11 +299,7 @@ driver_unbind_module(Driver *driver)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(driver=[%.40s])", __FUNCTION__, driver->name);
|
||||
|
||||
#ifndef WIN32
|
||||
dlclose(driver->module_handle);
|
||||
#else
|
||||
FreeLibrary(driver->module_handle);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#define COMMAND_LRNLONG 12
|
||||
#define COMMAND_LRNRAWRPT 13
|
||||
#define COMMAND_RELOAD 14
|
||||
#define COMMAND_LCD 15
|
||||
#define COMMAND_LCD 15
|
||||
#define COMMAND_LEARNSTAT 16
|
||||
#define COMMAND_TEMP 17
|
||||
#define COMMAND_GETREMOTES 18
|
||||
@@ -306,18 +306,9 @@ typedef struct {
|
||||
}
|
||||
NETWORKCLIENT;
|
||||
|
||||
#define TCP_PORT 21000
|
||||
#define LIRC_PORT 8765
|
||||
#define UDP_PORT 6510
|
||||
#define WEB_PORT 80
|
||||
#define TCP_PORT 21000
|
||||
#define LIRC_PORT 8765
|
||||
#define UDP_PORT 6510
|
||||
#define WEB_PORT 80
|
||||
#define ALTERNATE_WEB 8080
|
||||
|
||||
#ifdef WIN32
|
||||
#define CLIENT_COUNT MAXIMUM_WAIT_OBJECTS - 3
|
||||
#endif /*
|
||||
*/
|
||||
|
||||
#ifdef LINUX
|
||||
#define CLIENT_COUNT 64
|
||||
#endif /*
|
||||
*/
|
||||
|
||||
+2
-58
@@ -20,7 +20,6 @@
|
||||
* 2001, Rene Wagner
|
||||
* 2002, Mike Patnode
|
||||
* 2002, Guillaume Filion
|
||||
* 2003, Benjamin Tse (Win32 support)
|
||||
* 2005-2006, Peter Marschall (cleanup)
|
||||
*/
|
||||
|
||||
@@ -34,10 +33,8 @@
|
||||
#include <strings.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#ifndef WIN32
|
||||
# include <pwd.h>
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
#include <pwd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
@@ -542,7 +539,6 @@ set_default_settings(void)
|
||||
static void
|
||||
install_signal_handlers(int allow_reload)
|
||||
{
|
||||
#ifndef WIN32
|
||||
/* Installs signal handlers so that the program does clean exit and
|
||||
* can also receive a reload signal.
|
||||
* sigaction() is favoured over signal() */
|
||||
@@ -574,15 +570,6 @@ install_signal_handlers(int allow_reload)
|
||||
/* Treat this signal just like INT and TERM */
|
||||
}
|
||||
sigaction(SIGHUP, &sa, NULL);
|
||||
#else
|
||||
/* Win32 does not support POSIX signals i.e. sigaction(). However, it does
|
||||
* support ANSI signals in mingw. */
|
||||
signal(SIGINT, exit_program); /* Ctrl-C will cause a clean exit...*/
|
||||
signal(SIGTERM, exit_program); /* and "kill"...*/
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
/* REVISIT: implement SIGHUP on windows */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -601,13 +588,6 @@ child_ok_func(int signal)
|
||||
static pid_t
|
||||
daemonize(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
/* WIN32 does not support fork() - CreateProcess() does not even have
|
||||
* similar functionality. Instead don't daemonize on WIN32.
|
||||
*/
|
||||
pid_t parent;
|
||||
parent = getpid();
|
||||
#else
|
||||
pid_t child;
|
||||
pid_t parent;
|
||||
int child_status;
|
||||
@@ -659,7 +639,6 @@ daemonize(void)
|
||||
|
||||
setsid(); /* Create a new session because otherwise we'll
|
||||
* catch a SIGHUP when the shell is closed. */
|
||||
#endif
|
||||
|
||||
return parent;
|
||||
}
|
||||
@@ -668,11 +647,9 @@ daemonize(void)
|
||||
static int
|
||||
wave_to_parent(pid_t parent_pid)
|
||||
{
|
||||
#ifndef WIN32
|
||||
debug(RPT_DEBUG, "%s(parent_pid=%d)", __FUNCTION__, parent_pid);
|
||||
|
||||
kill(parent_pid, SIGUSR1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -722,7 +699,6 @@ init_drivers(void)
|
||||
static int
|
||||
drop_privs(char *user)
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct passwd *pwent;
|
||||
|
||||
debug(RPT_DEBUG, "%s(user=\"%.40s\")", __FUNCTION__, user);
|
||||
@@ -738,9 +714,6 @@ drop_privs(char *user)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Don't alter privileges in WIN32 */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -782,14 +755,8 @@ static void
|
||||
do_mainloop(void)
|
||||
{
|
||||
Screen *s;
|
||||
#ifndef WIN32
|
||||
struct timeval t;
|
||||
struct timeval last_t;
|
||||
#else
|
||||
LARGE_INTEGER t;
|
||||
LARGE_INTEGER last_t;
|
||||
LARGE_INTEGER perf_freq; /* frequency of high perf counter (cycles per usec) */
|
||||
#endif
|
||||
int sleeptime;
|
||||
long int process_lag = 0;
|
||||
long int render_lag = 0;
|
||||
@@ -797,20 +764,11 @@ do_mainloop(void)
|
||||
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
#ifndef WIN32
|
||||
gettimeofday(&t, NULL); /* Get initial time */
|
||||
#else
|
||||
QueryPerformanceFrequency(&perf_freq);
|
||||
/* scale perf_freq to number of cycles per micro-sec */
|
||||
/* REVISIT: this causes rounding errors below but is more efficient */
|
||||
perf_freq.QuadPart /= 1e6;
|
||||
QueryPerformanceCounter(&t);
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
/* Get current time */
|
||||
last_t = t;
|
||||
#ifndef WIN32
|
||||
gettimeofday(&t, NULL);
|
||||
t_diff = t.tv_sec - last_t.tv_sec;
|
||||
if ( ((t_diff + 1) > (LONG_MAX / 1e6)) || (t_diff < 0) ) {
|
||||
@@ -822,15 +780,6 @@ do_mainloop(void)
|
||||
t_diff *= 1e6;
|
||||
t_diff += t.tv_usec - last_t.tv_usec;
|
||||
}
|
||||
#else
|
||||
QueryPerformanceCounter(&t);
|
||||
/*t_diff.HighPart = t.HighPart - last_t.HighPart;
|
||||
t_diff.LowPart = t.LowPart - last_t.LowPart;
|
||||
*/
|
||||
t_diff = t.QuadPart - last_t.QuadPart;
|
||||
t_diff /= perf_freq.QuadPart; /* scale to microseconds */
|
||||
/* REVISIT: assumes fits into long */
|
||||
#endif
|
||||
process_lag += t_diff;
|
||||
if (process_lag > 0) {
|
||||
/* Time for a processing stroke */
|
||||
@@ -870,12 +819,7 @@ do_mainloop(void)
|
||||
/* Sleep just as long as needed */
|
||||
sleeptime = min(0-process_lag, 0-render_lag);
|
||||
if (sleeptime > 0) {
|
||||
#ifndef WIN32
|
||||
usleep(sleeptime);
|
||||
#else
|
||||
/* Sleep in Windows takes milliseconds argument */
|
||||
Sleep(sleeptime / 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if a SIGHUP has been caught */
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*
|
||||
* Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
* 2003, Benjamin Tse (blt@ieee.org) - Winsock port
|
||||
* 2004, F5 Networks, Inc. - IP-address input
|
||||
* 2005, Peter Marschall - error checks, ...
|
||||
* 2009, Markus Dolze - input ring buffer
|
||||
@@ -24,15 +23,11 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef WINSOCK2
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif /* WINSOCK */
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
@@ -95,17 +90,6 @@ sock_init(char* bind_addr, int bind_port)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef WINSOCK2
|
||||
/* Initialize the Winsock dll */
|
||||
WSADATA wsaData;
|
||||
int startup = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (startup != 0) {
|
||||
report(RPT_ERR, "%s: Could not start Winsock library - %s",
|
||||
__FUNCTION__, sock_geterror());
|
||||
}
|
||||
/* REVISIT: call WSACleanup(); */
|
||||
#endif
|
||||
|
||||
debug(RPT_DEBUG, "%s(bind_addr=\"%s\", port=%d)", __FUNCTION__, bind_addr, bind_port);
|
||||
|
||||
/* Create the socket and set it up to accept connections. */
|
||||
@@ -198,14 +182,6 @@ sock_shutdown(void)
|
||||
free(freeClientSocketPool);
|
||||
sring_destroy(messageRing);
|
||||
|
||||
#ifdef WINSOCK2
|
||||
if (WSACleanup() != 0) {
|
||||
report(RPT_ERR, "%s: Error closing Winsock library - %s",
|
||||
__FUNCTION__, sock_geterror());
|
||||
retVal = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -227,11 +203,7 @@ sock_create_inet_socket(char *addr, unsigned int port)
|
||||
|
||||
/* Create the socket. */
|
||||
sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||
#ifdef WINSOCK2
|
||||
if (sock == INVALID_SOCKET)
|
||||
#else
|
||||
if (sock < 0)
|
||||
#endif
|
||||
{
|
||||
report(RPT_ERR, "%s: cannot create socket - %s",
|
||||
__FUNCTION__, sock_geterror());
|
||||
@@ -248,12 +220,7 @@ sock_create_inet_socket(char *addr, unsigned int port)
|
||||
memset(&name, 0, sizeof(name));
|
||||
name.sin_family = AF_INET;
|
||||
name.sin_port = htons(port);
|
||||
#ifndef WINSOCK2
|
||||
/* REVISIT: can probably use the same code as under winsock */
|
||||
inet_aton(addr, &name.sin_addr);
|
||||
#else
|
||||
name.sin_addr.S_un.S_addr = inet_addr(addr);
|
||||
#endif
|
||||
|
||||
if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) {
|
||||
report(RPT_ERR, "%s: cannot bind to port %d at address %s - %s",
|
||||
@@ -317,11 +284,7 @@ sock_poll_clients(void)
|
||||
socklen_t size = sizeof(clientname);
|
||||
|
||||
new_sock = accept(listening_fd, (struct sockaddr *) &clientname, &size);
|
||||
#ifdef WINSOCK2
|
||||
if (new_sock == INVALID_SOCKET) {
|
||||
#else
|
||||
if (new_sock < 0) {
|
||||
#endif
|
||||
report(RPT_ERR, "%s: Accept error - %s",
|
||||
__FUNCTION__, sock_geterror());
|
||||
return -1;
|
||||
@@ -330,14 +293,7 @@ sock_poll_clients(void)
|
||||
inet_ntoa(clientname.sin_addr), ntohs(clientname.sin_port), new_sock);
|
||||
FD_SET(new_sock, &active_fd_set);
|
||||
|
||||
#ifdef WINSOCK2
|
||||
{
|
||||
unsigned long tmp;
|
||||
ioctlsocket(new_sock, FIONBIO, &tmp);
|
||||
}
|
||||
#else
|
||||
fcntl(new_sock, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
/* Create new client */
|
||||
if ((c = client_create(new_sock)) == NULL) {
|
||||
|
||||
+1
-62
@@ -18,21 +18,13 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef WIN32
|
||||
# include <syslog.h>
|
||||
#else
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <syslog.h>
|
||||
|
||||
#include "report.h"
|
||||
|
||||
static int report_level = RPT_INFO;
|
||||
static int report_dest = RPT_DEST_STORE;
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE event_log_handle = NULL;
|
||||
#endif
|
||||
|
||||
#define MAX_STORED_MSGS 200
|
||||
|
||||
static char *stored_msgs[MAX_STORED_MSGS];
|
||||
@@ -64,43 +56,7 @@ void report( const int level, const char *format, .../*args*/ )
|
||||
fprintf( stderr, "\n" );
|
||||
break;
|
||||
case RPT_DEST_SYSLOG:
|
||||
{
|
||||
#ifndef WIN32
|
||||
vsyslog( LOG_USER|(level+2), format, ap );
|
||||
#else
|
||||
LPTSTR tmpArray[1];
|
||||
WORD eventType;
|
||||
switch (level)
|
||||
{
|
||||
case RPT_CRIT:
|
||||
case RPT_ERR:
|
||||
eventType = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case RPT_WARNING:
|
||||
eventType = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
case RPT_NOTICE:
|
||||
case RPT_INFO:
|
||||
case RPT_DEBUG:
|
||||
default:
|
||||
eventType = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
vsnprintf( buf, sizeof(buf), format, ap );
|
||||
tmpArray[0] = buf;
|
||||
ReportEvent(event_log_handle,
|
||||
eventType,
|
||||
0, /* category */
|
||||
0, /* event ID */
|
||||
NULL, /* user ID */
|
||||
1, /* number of strings */
|
||||
0, /* binary data size */
|
||||
(LPCTSTR*) tmpArray, /* error string */
|
||||
NULL /* binary data */
|
||||
);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case RPT_DEST_STORE:
|
||||
vsnprintf( buf, sizeof(buf), format, ap );
|
||||
@@ -121,27 +77,10 @@ int set_reporting( char *application_name, int new_level, int new_dest )
|
||||
}
|
||||
|
||||
if( report_dest != RPT_DEST_SYSLOG && new_dest == RPT_DEST_SYSLOG ) {
|
||||
#ifdef WIN32
|
||||
if (event_log_handle)
|
||||
{
|
||||
CloseEventLog(event_log_handle);
|
||||
} else {
|
||||
event_log_handle = RegisterEventSource(NULL, "LcdProc");
|
||||
}
|
||||
#else
|
||||
openlog( application_name, 0, LOG_USER );
|
||||
#endif
|
||||
}
|
||||
else if( report_dest == RPT_DEST_SYSLOG && new_dest != RPT_DEST_SYSLOG ) {
|
||||
#ifdef WIN32
|
||||
if (event_log_handle)
|
||||
{
|
||||
CloseEventLog(event_log_handle);
|
||||
event_log_handle = NULL;
|
||||
}
|
||||
#else
|
||||
closelog();
|
||||
#endif
|
||||
}
|
||||
|
||||
report_level = new_level;
|
||||
|
||||
+5
-65
@@ -15,15 +15,11 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef WINSOCK2
|
||||
# include <sys/socket.h>
|
||||
# include <sys/un.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netdb.h>
|
||||
# include <arpa/inet.h>
|
||||
#else
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -79,11 +75,7 @@ sock_connect (char *host, unsigned short int port)
|
||||
|
||||
report (RPT_DEBUG, "sock_connect: Creating socket");
|
||||
sock = socket (PF_INET, SOCK_STREAM, 0);
|
||||
#ifdef WINSOCK2
|
||||
if (sock == INVALID_SOCKET) {
|
||||
#else
|
||||
if (sock < 0) {
|
||||
#endif
|
||||
report (RPT_ERR, "sock_connect: Error creating socket");
|
||||
return sock;
|
||||
}
|
||||
@@ -93,26 +85,13 @@ sock_connect (char *host, unsigned short int port)
|
||||
return -1;
|
||||
|
||||
err = connect (sock, (struct sockaddr *) &servername, sizeof (servername));
|
||||
#ifdef WINSOCK2
|
||||
if (err == INVALID_SOCKET) {
|
||||
#else
|
||||
if (err < 0) {
|
||||
#endif
|
||||
report (RPT_ERR, "sock_connect: connect failed");
|
||||
shutdown (sock, SHUT_RDWR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef WINSOCK2
|
||||
fcntl (sock, F_SETFL, O_NONBLOCK);
|
||||
#else
|
||||
{
|
||||
unsigned long tmp = 1;
|
||||
|
||||
if (ioctlsocket(sock, FIONBIO, &tmp) == SOCKET_ERROR)
|
||||
report(RPT_ERR, "sock_connect: Error setting socket to non-blocking");
|
||||
}
|
||||
#endif
|
||||
|
||||
return sock;
|
||||
}
|
||||
@@ -195,11 +174,7 @@ sock_recv_string (int fd, char *dest, size_t maxlen)
|
||||
return 0;
|
||||
|
||||
while (1) {
|
||||
#ifndef WINSOCK2
|
||||
int err = read (fd, ptr, 1);
|
||||
#else
|
||||
int err = recv(fd, ptr, 1, 0);
|
||||
#endif
|
||||
if (err == -1) {
|
||||
if (errno == EAGAIN) {
|
||||
if (recvBytes) {
|
||||
@@ -254,11 +229,7 @@ sock_send (int fd, void *src, size_t size)
|
||||
while (offset != size) {
|
||||
// write isn't guaranteed to send the entire string at once,
|
||||
// so we have to sent it in a loop like this
|
||||
#ifndef WINSOCK2
|
||||
int sent = write (fd, ((char *) src) + offset, size - offset);
|
||||
#else
|
||||
int sent = send(fd, ((char *) src) + offset, size - offset, 0);
|
||||
#endif
|
||||
if (sent == -1) {
|
||||
if (errno != EAGAIN) {
|
||||
report (RPT_ERR, "sock_send: socket write error");
|
||||
@@ -296,11 +267,7 @@ sock_recv (int fd, void *dest, size_t maxlen)
|
||||
if (maxlen <= 0)
|
||||
return 0;
|
||||
|
||||
#ifndef WINSOCK2
|
||||
err = read (fd, dest, maxlen);
|
||||
#else
|
||||
err = recv(fd, dest, maxlen, 0);
|
||||
#endif
|
||||
if (err < 0) {
|
||||
//report (RPT_DEBUG,"sock_recv: socket read error");
|
||||
//shutdown(fd, SHUT_RDWR);
|
||||
@@ -320,34 +287,7 @@ sock_recv (int fd, void *dest, size_t maxlen)
|
||||
char*
|
||||
sock_geterror(void)
|
||||
{
|
||||
#ifndef WINSOCK2
|
||||
return strerror(errno);
|
||||
#else
|
||||
static char retString[256];
|
||||
long err;
|
||||
char* tmp;
|
||||
|
||||
err = WSAGetLastError();
|
||||
|
||||
sprintf(retString, "Error code %ld: ", err);
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
err,
|
||||
0, /* Default language */
|
||||
(LPTSTR) &tmp,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
/* append the message text after the error code and ensure a terminating
|
||||
character ends the string */
|
||||
strncpy(retString + strlen(retString), tmp,
|
||||
sizeof(retString) - strlen(retString) - 1);
|
||||
retString[sizeof(retString) - 1] = '\0';
|
||||
|
||||
return retString;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user