X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fguestfsd.c;h=8d0154a3a09fb04436f3704cd1c67ee148ab84ac;hp=acb44f9908d6c905677504ad5638bd2231197301;hb=15ebf328911fb6376376889c99029bcf2dbe0033;hpb=8e33cd5f2f2e7e30525cb2a70d86de70e3d6a4f9 diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index acb44f9..8d0154a 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -39,13 +39,17 @@ #include #include #include +#include +#include #ifdef HAVE_PRINTF_H # include #endif +#include "sockets.h" #include "c-ctype.h" #include "ignore-value.h" +#include "error.h" #include "daemon.h" @@ -89,6 +93,24 @@ daemon (int nochdir, int noclose) } #endif /* WIN32 */ +#ifdef WIN32 +static int +winsock_init (void) +{ + int r; + + /* http://msdn2.microsoft.com/en-us/library/ms742213.aspx */ + r = gl_sockets_startup (SOCKETS_2_2); + return r == 0 ? 0 : -1; +} +#else /* !WIN32 */ +static int +winsock_init (void) +{ + return 0; +} +#endif /* !WIN32 */ + /* Location to mount root device. */ const char *sysroot = "/sysroot"; /* No trailing slash. */ int sysroot_len = 8; @@ -116,6 +138,9 @@ main (int argc, char *argv[]) char *cmdline; char *vmchannel = NULL; + if (winsock_init () == -1) + error (EXIT_FAILURE, 0, "winsock initialization failed"); + #ifdef HAVE_REGISTER_PRINTF_SPECIFIER /* http://udrepper.livejournal.com/20948.html */ register_printf_specifier ('Q', print_shell_quote, print_arginfo);