summaryrefslogtreecommitdiff
path: root/src/biruda.c
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2014-09-15 15:43:52 +0200
committerAndreas Baumann <abaumann@yahoo.com>2014-09-15 15:43:52 +0200
commitf370e929588815ebb19e5d9c49c24a224f320b10 (patch)
tree653414efc58b3cebf7a2de0ac544bcb1fd908244 /src/biruda.c
parentc6a321715da321456b311bb7dca3ecf0c8e9567c (diff)
downloadbiruda-f370e929588815ebb19e5d9c49c24a224f320b10.tar.gz
biruda-f370e929588815ebb19e5d9c49c24a224f320b10.tar.bz2
gethostname fix for Windows
Diffstat (limited to 'src/biruda.c')
-rw-r--r--src/biruda.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/biruda.c b/src/biruda.c
index 860125f..535c49f 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
+#include <Winsock2.h>
+#include <ws2tcpip.h>
#else
#include <errno.h>
#include <unistd.h>
@@ -178,12 +180,30 @@ int main( int argc, char *argv[] )
return( ( test_config( &args_info ) == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE );
}
+#ifdef _WIN32
+ WORD version;
+ WSADATA data;
+ int rc;
+
+ version = MAKEWORD( 2, 2 );
+ rc = WSAStartup( version, &data );
+ if( rc != 0 ) {
+ fprintf( stderr, "ERROR: WSAStartup failed with error: %d\n", rc );
+ cfg_free( cfg );
+ cmdline_parser_free( &args_info );
+ exit( EXIT_FAILURE );
+ }
+#endif
+
unsigned int has_master = cfg_size( cfg, "master" );
if( has_master ) {
if( create_master( cfg ) != 0 ) {
fprintf( stderr, "FATAL: Unable to create master thread!\n" );
cfg_free( cfg );
cmdline_parser_free( &args_info );
+#ifdef _WIN32
+ WSACleanup( );
+#endif
exit( EXIT_FAILURE );
}
}
@@ -194,6 +214,9 @@ int main( int argc, char *argv[] )
fprintf( stderr, "FATAL: Unable to create coordinator thread!\n" );
cfg_free( cfg );
cmdline_parser_free( &args_info );
+#ifdef _WIN32
+ WSACleanup( );
+#endif
exit( EXIT_FAILURE );
}
}
@@ -217,5 +240,9 @@ int main( int argc, char *argv[] )
cfg_free( cfg );
cmdline_parser_free( &args_info );
+#ifdef _WIN32
+ WSACleanup( );
+#endif
+
exit( EXIT_SUCCESS );
}