server: add server_preinit which is called before config file is parsed.
[fw/openocd] / src / server / server.c
index 0f977a76c81515ab44ad348b99f296205b2c1728..75a6bed08be6dcb48532c4b7b10561e9031a5877 100644 (file)
@@ -28,7 +28,7 @@
 #endif
 
 #include "server.h"
-#include "target.h"
+#include <target/target.h>
 #include "openocd.h"
 #include "tcl_server.h"
 #include "telnet_server.h"
@@ -487,8 +487,12 @@ void sig_handler(int sig) {
 }
 #endif
 
-int server_init(struct command_context *cmd_ctx)
+int server_preinit(void)
 {
+       /* this currently only calls WSAStartup on native win32 systems
+        * before any socket operations are performed.
+        * This is an issue if you call init in your config script */
+
 #ifdef _WIN32
        WORD wVersionRequested;
        WSADATA wsaData;
@@ -518,6 +522,11 @@ int server_init(struct command_context *cmd_ctx)
        signal(SIGABRT, sig_handler);
 #endif
 
+       return ERROR_OK;
+}
+
+int server_init(struct command_context *cmd_ctx)
+{
        int ret = tcl_init(cmd_ctx);
        if (ERROR_OK != ret)
                return ret;