server: add server_preinit which is called before config file is parsed.
[fw/openocd] / src / server / server.c
index 256c590da082b1174cefc26a0813fbbfe3c18392..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"
@@ -386,7 +386,7 @@ int server_loop(struct command_context *command_context)
                }
 
                target_call_timer_callbacks();
-               process_jim_events ();
+               process_jim_events(command_context);
 
                if (retval == 0)
                {
@@ -487,8 +487,12 @@ void sig_handler(int sig) {
 }
 #endif
 
-int server_init(void)
+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,7 +522,12 @@ int server_init(void)
        signal(SIGABRT, sig_handler);
 #endif
 
-       int ret = tcl_init();
+       return ERROR_OK;
+}
+
+int server_init(struct command_context *cmd_ctx)
+{
+       int ret = tcl_init(cmd_ctx);
        if (ERROR_OK != ret)
                return ret;