diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/include/sockio.h | 13 | ||||
-rw-r--r-- | src/lib/sockio-c.c | 10 |
3 files changed, 20 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f7e95a38..28fbb4b9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2008-09-06 Gabriel Dos Reis <gdr@cs.tamu.edu> + * include/sockio.h (openaxiom_filedesc): New. Abstract over + differences between Win32 named pipes and POSIX local sockets. + * lib/sockio-c.c: Use it. + +2008-09-06 Gabriel Dos Reis <gdr@cs.tamu.edu> + * lib/sockio-c.c (oa_open_ip4_client_stream_socket): Use deprecated inet_addr on MinGW host. diff --git a/src/include/sockio.h b/src/include/sockio.h index 15202d93..1a4e1253 100644 --- a/src/include/sockio.h +++ b/src/include/sockio.h @@ -61,8 +61,10 @@ #ifdef __MINGW32__ typedef SOCKET openaxiom_socket; +typedef HANDLE openaxiom_filedesc; #else typedef int openaxiom_socket; +typedef int openaxiom_filedesc; #endif typedef int openaxiom_port; @@ -83,7 +85,8 @@ typedef struct openaxiom_sio { -OPENAXIOM_EXPORT int oa_open_local_client_stream_socket(const char*); +OPENAXIOM_EXPORT openaxiom_filedesc + oa_open_local_client_stream_socket(const char*); OPENAXIOM_EXPORT int oa_open_local_server_stream_socket(const char*); OPENAXIOM_EXPORT openaxiom_socket oa_open_ip4_client_stream_socket(const char*, openaxiom_port); @@ -93,9 +96,11 @@ OPENAXIOM_EXPORT int oa_socket_read(openaxiom_socket, openaxiom_byte*, int); OPENAXIOM_EXPORT void oa_close_socket(openaxiom_socket); -OPENAXIOM_EXPORT int oa_filedesc_write(int, const openaxiom_byte*, int); -OPENAXIOM_EXPORT int oa_filedesc_read(int, openaxiom_byte*, int); -OPENAXIOM_EXPORT int oa_filedesc_close(int); +OPENAXIOM_EXPORT int +oa_filedesc_write(openaxiom_filedesc, const openaxiom_byte*, int); +OPENAXIOM_EXPORT int +oa_filedesc_read(openaxiom_filedesc, openaxiom_byte*, int); +OPENAXIOM_EXPORT int oa_filedesc_close(openaxiom_filedesc); OPENAXIOM_EXPORT int sread(openaxiom_sio*, openaxiom_byte*, int, const char*); OPENAXIOM_EXPORT int swrite(openaxiom_sio*, const openaxiom_byte*, int, diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c index 912e16a9..b3e4ca24 100644 --- a/src/lib/sockio-c.c +++ b/src/lib/sockio-c.c @@ -217,7 +217,7 @@ oa_close_socket(openaxiom_socket s) ae full duplex communication links, supporting regular file I/O operations. */ -OPENAXIOM_EXPORT int +OPENAXIOM_EXPORT openaxiom_filedesc oa_open_local_client_stream_socket(const char* path) { #ifdef __WIN32__ @@ -244,7 +244,7 @@ oa_open_local_client_stream_socket(const char* path) if (GetLastError() != ERROR_PIPE_BUSY || !WaitNamedPipe(pipename, NMPWAIT_WAIT_FOREVER)) - return -1; + return INVALID_HANDLE_VALUE; } # undef NAMED_PIPE_PREFIX #else @@ -265,7 +265,7 @@ oa_open_local_client_stream_socket(const char* path) } OPENAXIOM_EXPORT int -oa_filedesc_read(int desc, openaxiom_byte* buf, int size) +oa_filedesc_read(openaxiom_filedesc desc, openaxiom_byte* buf, int size) { #ifdef __WIN32__ DWORD count = -1; @@ -282,7 +282,7 @@ oa_filedesc_read(int desc, openaxiom_byte* buf, int size) } OPENAXIOM_EXPORT int -oa_filedesc_write(int desc, const openaxiom_byte* buf, int size) +oa_filedesc_write(openaxiom_filedesc desc, const openaxiom_byte* buf, int size) { #ifdef __WIN32__ DWORD count = -1; @@ -299,7 +299,7 @@ oa_filedesc_write(int desc, const openaxiom_byte* buf, int size) } OPENAXIOM_EXPORT int -oa_filedesc_close(int desc) +oa_filedesc_close(openaxiom_filedesc desc) { #ifdef __WIN32__ return CloseHandle(desc) ? 0 : -1; |