summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-10-24 01:11:13 -0700
committerZachary T Welch <zw@superlucidity.net>2009-11-05 18:03:18 -0800
commitae5732b9e4f085b89da3f9ce07eb526e159e1937 (patch)
treeb40dbd59e5420189b3b4240e1adb8cc6541e1ff5
parent653ea7b25c4bec65fbe60101eb55d2564ba982af (diff)
downloadopenocd_libswd-ae5732b9e4f085b89da3f9ce07eb526e159e1937.tar.gz
openocd_libswd-ae5732b9e4f085b89da3f9ce07eb526e159e1937.tar.bz2
openocd_libswd-ae5732b9e4f085b89da3f9ce07eb526e159e1937.tar.xz
openocd_libswd-ae5732b9e4f085b89da3f9ce07eb526e159e1937.zip
Add server port command helper function.
-rw-r--r--src/server/server.c20
-rw-r--r--src/server/server.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/src/server/server.c b/src/server/server.c
index d2596112..03f0ee6e 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -549,3 +549,23 @@ int handle_shutdown_command(struct command_context_s *cmd_ctx, char *cmd, char *
return ERROR_COMMAND_CLOSE_CONNECTION;
}
+
+int server_port_command(struct command_context_s *cmd_ctx,
+ char *cmd, char **args, int argc, unsigned short *out)
+{
+ 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;
+}
diff --git a/src/server/server.h b/src/server/server.h
index 2dba3dab..dab28eca 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -75,6 +75,9 @@ extern int server_quit(void);
extern int server_loop(command_context_t *command_context);
extern int server_register_commands(command_context_t *context);
+int server_port_command(struct command_context_s *cmd_ctx,
+ char *cmd, char **args, int argc, unsigned short *port);
+
extern int server_use_pipes;
#define ERROR_SERVER_REMOTE_CLOSED (-400)