use CALL_COMMAND_HANDLER instead of direct calls
[fw/openocd] / src / server / tcl_server.c
index f37d4975ab37b824eeff6337d963b086ca94ff90..c8da5bcadce31a1ed9bf44f5fa11517a9ecbf0b8 100644 (file)
@@ -36,9 +36,6 @@ typedef struct tcl_connection_s {
 
 static unsigned short tcl_port = 6666;
 
-/* commands */
-static int handle_tcl_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-
 /* handlers */
 static int tcl_new_connection(connection_t *connection);
 static int tcl_input(connection_t *connection);
@@ -141,7 +138,7 @@ static int tcl_input(connection_t *connection)
                        if (memchr(result, '\n', reslen) == NULL)
                                tcl_output(connection, "\n", 1);
                }
-               
+
                tclc->tc_lineoffset = 0;
                tclc->tc_linedrop = 0;
        }
@@ -173,16 +170,15 @@ int tcl_init(void)
        return retval;
 }
 
-int tcl_register_commands(command_context_t *cmd_ctx)
+COMMAND_HANDLER(handle_tcl_port_command)
 {
-       register_command(cmd_ctx, NULL, "tcl_port", handle_tcl_port_command, COMMAND_CONFIG, "port on which to listen for incoming TCL syntax");
-       return ERROR_OK;
+       return CALL_COMMAND_HANDLER(server_port_command, &tcl_port);
 }
 
-static int handle_tcl_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+int tcl_register_commands(command_context_t *cmd_ctx)
 {
-       if (argc == 1) {
-               tcl_port = strtoul(args[0], NULL, 0);
-       }
+       register_command(cmd_ctx, NULL, "tcl_port",
+                       handle_tcl_port_command, COMMAND_CONFIG,
+                       "port on which to listen for incoming TCL syntax");
        return ERROR_OK;
 }