aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index a8e6ddae5..5035a4836 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,6 +75,11 @@
#include <locale.h>
#endif
+#ifdef WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+
enum {
DEFAULT_BUFFER_SIZE = 2048,
DEFAULT_BUFFER_BEFORE_PLAY = 10,
@@ -136,6 +141,31 @@ openDB(const Options *options)
}
/**
+ * Windows-only initialization of the Winsock2 library.
+ */
+#ifdef WIN32
+static void winsock_init(void)
+{
+ WSADATA sockinfo;
+ int retval;
+
+ retval = WSAStartup(MAKEWORD(2, 2), &sockinfo);
+ if(retval != 0)
+ {
+ g_error("Attempt to open Winsock2 failed; error code %d\n",
+ retval);
+ }
+
+ if (LOBYTE(sockinfo.wVersion) != 2)
+ {
+ g_error("We use Winsock2 but your version is either too new or "
+ "old; please install Winsock 2.x\n");
+ }
+
+}
+#endif
+
+/**
* Initialize the decoder and player core, including the music pipe.
*/
static void
@@ -212,6 +242,9 @@ int main(int argc, char *argv[])
/* enable GLib's thread safety code */
g_thread_init(NULL);
+#ifdef WIN32
+ winsock_init();
+#endif
idle_init();
dirvec_init();
songvec_init();
@@ -339,6 +372,9 @@ int main(int argc, char *argv[])
idle_deinit();
stats_global_finish();
daemonize_finish();
+#ifdef WIN32
+ WSACleanup();
+#endif
close_log_files();
return EXIT_SUCCESS;