diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2014-09-15 15:43:52 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2014-09-15 15:43:52 +0200 |
commit | f370e929588815ebb19e5d9c49c24a224f320b10 (patch) | |
tree | 653414efc58b3cebf7a2de0ac544bcb1fd908244 /src/biruda.c | |
parent | c6a321715da321456b311bb7dca3ecf0c8e9567c (diff) | |
download | biruda-f370e929588815ebb19e5d9c49c24a224f320b10.tar.gz biruda-f370e929588815ebb19e5d9c49c24a224f320b10.tar.bz2 |
gethostname fix for Windows
Diffstat (limited to 'src/biruda.c')
-rw-r--r-- | src/biruda.c | 27 |
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 ); } |