]> git.sur5r.net Git - openocd/commitdiff
Add server port command helper function.
authorZachary T Welch <zw@superlucidity.net>
Sat, 24 Oct 2009 08:11:13 +0000 (01:11 -0700)
committerZachary T Welch <zw@superlucidity.net>
Fri, 6 Nov 2009 02:03:18 +0000 (18:03 -0800)
src/server/server.c
src/server/server.h

index d2596112151058082132d82a6784114406b917f0..03f0ee6ec94a2d30d69cadc15bf871fc50fcbe8b 100644 (file)
@@ -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;
+}
index 2dba3dabe9e0c3ee82bf505c82b884612a62fc1d..dab28eca3dfe09bd47d8946f5e24e810a4415545 100644 (file)
@@ -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)