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

View File

@@ -40,7 +40,7 @@
* Set `sa' to the unitialized address of address family `af'
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_any (struct sockaddr *sa, int af)
{
switch (af) {
@@ -74,7 +74,7 @@ socket_set_any (struct sockaddr *sa, int af)
* set `sa' to (`ptr', `port')
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port)
{
switch (sa->sa_family) {
@@ -108,7 +108,7 @@ socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port)
* Return the size of an address of the type in `sa'
*/
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_addr_size (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -120,7 +120,7 @@ socket_addr_size (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return 0);
}
}
@@ -128,7 +128,7 @@ socket_addr_size (const struct sockaddr *sa)
* Return the size of a `struct sockaddr' in `sa'.
*/
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_sockaddr_size (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -140,7 +140,7 @@ socket_sockaddr_size (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return 0);
}
}
@@ -148,7 +148,7 @@ socket_sockaddr_size (const struct sockaddr *sa)
* Return the binary address of `sa'.
*/
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
socket_get_address (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -164,7 +164,7 @@ socket_get_address (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return NULL);
}
}
@@ -172,7 +172,7 @@ socket_get_address (const struct sockaddr *sa)
* Return the port number from `sa'.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
socket_get_port (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -188,7 +188,7 @@ socket_get_port (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return 0);
}
}
@@ -196,7 +196,7 @@ socket_get_port (const struct sockaddr *sa)
* Set the port in `sa' to `port'.
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_port (struct sockaddr *sa, int port)
{
switch (sa->sa_family) {
@@ -221,8 +221,8 @@ socket_set_port (struct sockaddr *sa, int port)
/*
* Set the range of ports to use when binding with port = 0.
*/
void ROKEN_LIB_FUNCTION
socket_set_portrange (int sock, int restr, int af)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_portrange (SOCKET sock, int restr, int af)
{
#if defined(IP_PORTRANGE)
if (af == AF_INET) {
@@ -247,8 +247,8 @@ socket_set_portrange (int sock, int restr, int af)
* Enable debug on `sock'.
*/
void ROKEN_LIB_FUNCTION
socket_set_debug (int sock)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_debug (SOCKET sock)
{
#if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT)
int on = 1;
@@ -262,8 +262,8 @@ socket_set_debug (int sock)
* Set the type-of-service of `sock' to `tos'.
*/
void ROKEN_LIB_FUNCTION
socket_set_tos (int sock, int tos)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_tos (SOCKET sock, int tos)
{
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
if (setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof (int)) < 0)
@@ -276,8 +276,8 @@ socket_set_tos (int sock, int tos)
* set the reuse of addresses on `sock' to `val'.
*/
void ROKEN_LIB_FUNCTION
socket_set_reuseaddr (int sock, int val)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_reuseaddr (SOCKET sock, int val)
{
#if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT)
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val,
@@ -290,10 +290,21 @@ socket_set_reuseaddr (int sock, int val)
* Set the that the `sock' should bind to only IPv6 addresses.
*/
void ROKEN_LIB_FUNCTION
socket_set_ipv6only (int sock, int val)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_ipv6only (SOCKET sock, int val)
{
#if defined(IPV6_V6ONLY) && defined(HAVE_SETSOCKOPT)
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&val, sizeof(val));
#endif
}
#ifdef SOCKET_IS_NOT_AN_FD
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
fd_from_socket(SOCKET sock, int flags)
{
return _open_osfhandle((intptr_t) sock, flags);
}
#endif