- cfg_cmd_ctx = copy_command_context(cmd_ctx);
- cfg_cmd_ctx->mode = COMMAND_CONFIG;
- command_set_output_handler(cfg_cmd_ctx, configuration_output_handler, NULL);
-
- if (parse_cmdline_args(cfg_cmd_ctx, argc, argv) != ERROR_OK)
+ return cmd_ctx;
+}
+
+int httpd_start(void);
+void httpd_stop(void);
+
+
+#if !BUILD_HTTPD && !BUILD_ECOSBOARD
+/* implementations of OpenOCD that uses multithreading needs to know when
+ * OpenOCD is sleeping. No-op in vanilla OpenOCD
+ */
+void openocd_sleep_prelude(void)
+{
+}
+
+void openocd_sleep_postlude(void)
+{
+}
+#endif
+
+
+/* normally this is the main() function entry, but if OpenOCD is linked
+ * into application, then this fn will not be invoked, but rather that
+ * application will have it's own implementation of main(). */
+int openocd_main(int argc, char *argv[])
+{
+ int ret;
+
+ /* initialize commandline interface */
+ struct command_context *cmd_ctx;
+
+ cmd_ctx = setup_command_handler();
+
+#if BUILD_IOUTIL
+ if (ioutil_init(cmd_ctx) != ERROR_OK)
+ {
+ return EXIT_FAILURE;
+ }
+#endif
+
+ LOG_OUTPUT("For bug reports, read\n\t"
+ "http://openocd.berlios.de/doc/doxygen/bugs.html"
+ "\n");
+
+
+ command_context_mode(cmd_ctx, COMMAND_CONFIG);
+ command_set_output_handler(cmd_ctx, configuration_output_handler, NULL);
+
+ if (parse_cmdline_args(cmd_ctx, argc, argv) != ERROR_OK)