* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008 Øyvind Harboe *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2008 by Spencer Oliver *
/* shutdown_openocd == 1: exit the main event loop, and quit the debugger */
static int shutdown_openocd = 0;
-int handle_shutdown_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* set when using pipes rather than tcp */
int server_use_pipes = 0;
return ERROR_OK;
}
+/* tell the server we want to shut down */
+COMMAND_HANDLER(handle_shutdown_command)
+{
+ shutdown_openocd = 1;
+
+ return ERROR_COMMAND_CLOSE_CONNECTION;
+}
+
int server_register_commands(command_context_t *context)
{
- register_command(context, NULL, "shutdown", handle_shutdown_command,
- COMMAND_ANY, "shut the server down");
+ register_command(context, NULL, "shutdown",
+ handle_shutdown_command, COMMAND_ANY,
+ "shut the server down");
return ERROR_OK;
}
-/* tell the server we want to shut down */
-int handle_shutdown_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- shutdown_openocd = 1;
- return ERROR_COMMAND_CLOSE_CONNECTION;
+SERVER_PORT_COMMAND()
+{
+ switch (argc) {
+ case 0:
+ command_print(cmd_ctx, "%d", *out);
+ break;
+ case 1:
+ {
+ uint16_t port;
+ COMMAND_PARSE_NUMBER(u16, args[0], port);
+ *out = port;
+ break;
+ }
+ default:
+ return ERROR_INVALID_ARGUMENTS;
+ }
+ return ERROR_OK;
}