Initial Windows port

This commit is contained in:
Asanka Herath
2009-07-22 15:55:45 -04:00
committed by Love Hornquist Astrand
parent 25a2ac726b
commit b1063ea8fc
361 changed files with 11994 additions and 1334 deletions
+26 -9
View File
@@ -33,17 +33,13 @@
#include <config.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "roken.h"
/*
* Like write but never return partial data.
*/
ssize_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
net_write (int fd, const void *buf, size_t nbytes)
{
const char *cbuf = (const char *)buf;
@@ -51,11 +47,7 @@ net_write (int fd, const void *buf, size_t nbytes)
size_t rem = nbytes;
while (rem > 0) {
#ifdef WIN32
count = send (fd, cbuf, rem, 0);
#else
count = write (fd, cbuf, rem);
#endif
if (count < 0) {
if (errno == EINTR)
continue;
@@ -67,3 +59,28 @@ net_write (int fd, const void *buf, size_t nbytes)
}
return nbytes;
}
#ifdef SOCKET_IS_NOT_AN_FD
ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
net_write_s (SOCKET sock, const void *buf, size_t nbytes)
{
const char *cbuf = (const char *)buf;
ssize_t count;
size_t rem = nbytes;
while (rem > 0) {
count = send (sock, cbuf, rem, 0);
if (count < 0) {
if (errno == EINTR)
continue;
else
return count;
}
cbuf += count;
rem -= count;
}
return nbytes;
}
#endif