]> git.sur5r.net Git - openocd/commitdiff
server: use register_commands
authorZachary T Welch <zw@superlucidity.net>
Sat, 21 Nov 2009 22:42:05 +0000 (14:42 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 05:37:32 +0000 (21:37 -0800)
Converts server directory to use new command registration paradigm.

src/server/gdb_server.c
src/server/server.c
src/server/tcl_server.c
src/server/telnet_server.c

index be1f8dbc7805ea8ed877f2e3f6a8a7a96379f66a..cb14cc3f8f3fe62970dad832c0387fc86a002ace 100644 (file)
@@ -2326,27 +2326,55 @@ COMMAND_HANDLER(handle_gdb_breakpoint_override_command)
        return ERROR_OK;
 }
 
-int gdb_register_commands(struct command_context *command_context)
+static const struct command_registration gdb_command_handlers[] = {
+       {
+               .name = "gdb_sync",
+               .handler = &handle_gdb_sync_command,
+               .mode = COMMAND_ANY,
+               .help = "next stepi will return immediately allowing "
+                       "GDB to fetch register state without affecting "
+                       "target state",
+       },
+       {
+               .name = "gdb_port",
+               .handler = &handle_gdb_port_command,
+               .mode = COMMAND_ANY,
+               .help = "daemon configuration command gdb_port",
+               .usage = "<port>",
+       },
+       {
+               .name = "gdb_memory_map",
+               .handler = &handle_gdb_memory_map_command,
+               .mode = COMMAND_CONFIG,
+               .help = "enable or disable memory map",
+               .usage = "enable|disable"
+       },
+       {
+               .name = "gdb_flash_program",
+               .handler = &handle_gdb_flash_program_command,
+               .mode = COMMAND_CONFIG,
+               .help = "enable or disable flash program",
+               .usage = "enable|disable"
+       },
+       {
+               .name = "gdb_report_data_abort",
+               .handler = &handle_gdb_report_data_abort_command,
+               .mode = COMMAND_CONFIG,
+               .help = "enable or disable reporting data aborts",
+               .usage = "enable|disable"
+       },
+       {
+               .name = "gdb_breakpoint_override",
+               .handler = &handle_gdb_breakpoint_override_command,
+               .mode = COMMAND_EXEC,
+               .help = "force type of breakpoint "
+                       "used by gdb 'break' commands.",
+               .usage = "hard|soft|disable",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
+int gdb_register_commands(struct command_context *cmd_ctx)
 {
-       COMMAND_REGISTER(command_context, NULL, "gdb_sync",
-                       handle_gdb_sync_command, COMMAND_ANY,
-                       "next stepi will return immediately allowing GDB to "
-                       "fetch register state without affecting target state");
-       COMMAND_REGISTER(command_context, NULL, "gdb_port",
-                       handle_gdb_port_command, COMMAND_ANY,
-                       "daemon configuration command gdb_port");
-       COMMAND_REGISTER(command_context, NULL, "gdb_memory_map",
-                       handle_gdb_memory_map_command, COMMAND_CONFIG,
-                       "enable or disable memory map");
-       COMMAND_REGISTER(command_context, NULL, "gdb_flash_program",
-                       handle_gdb_flash_program_command, COMMAND_CONFIG,
-                       "enable or disable flash program");
-       COMMAND_REGISTER(command_context, NULL, "gdb_report_data_abort",
-                       handle_gdb_report_data_abort_command, COMMAND_CONFIG,
-                       "enable or disable reporting data aborts");
-       COMMAND_REGISTER(command_context, NULL, "gdb_breakpoint_override",
-                       handle_gdb_breakpoint_override_command, COMMAND_EXEC,
-                       "hard/soft/disable - force type of breakpoint "
-                       "used by gdb 'break' commands.");
-       return ERROR_OK;
+       return register_commands(cmd_ctx, NULL, gdb_command_handlers);
 }
index 5be131668f20fa693bbdd0ca87affb98f71fa9c5..50bc00eb18bb606e1c27d450f3d646fbabeb2eea 100644 (file)
@@ -539,16 +539,21 @@ COMMAND_HANDLER(handle_shutdown_command)
        return ERROR_COMMAND_CLOSE_CONNECTION;
 }
 
-int server_register_commands(struct command_context *context)
+static const struct command_registration server_command_handlers[] = {
+       {
+               .name = "shutdown",
+               .handler = &handle_shutdown_command,
+               .mode = COMMAND_ANY,
+               .help = "shut the server down",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
+int server_register_commands(struct command_context *cmd_ctx)
 {
-       COMMAND_REGISTER(context, NULL, "shutdown",
-                       handle_shutdown_command, COMMAND_ANY,
-                       "shut the server down");
-
-       return ERROR_OK;
+       return register_commands(cmd_ctx, NULL, server_command_handlers);
 }
 
-
 SERVER_PORT_COMMAND()
 {
        switch (CMD_ARGC) {
index a12176eeac647bb716b1efaa75133c33658039e9..22469a4f37144bac3d8fcce0238b2f1f9129d018 100644 (file)
@@ -175,10 +175,19 @@ COMMAND_HANDLER(handle_tcl_port_command)
        return CALL_COMMAND_HANDLER(server_port_command, &tcl_port);
 }
 
+static const struct command_registration tcl_command_handlers[] = {
+       {
+               .name = "tcl_port",
+               .handler = &handle_tcl_port_command,
+               .mode = COMMAND_CONFIG,
+               .help = "port on which to listen "
+                       "for incoming TCL syntax",
+               .usage = "<port>",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
 int tcl_register_commands(struct command_context *cmd_ctx)
 {
-       COMMAND_REGISTER(cmd_ctx, NULL, "tcl_port",
-                       handle_tcl_port_command, COMMAND_CONFIG,
-                       "port on which to listen for incoming TCL syntax");
-       return ERROR_OK;
+       return register_commands(cmd_ctx, NULL, tcl_command_handlers);
 }
index c52119dac64945b9a5bd852206ebf86fba7f6e21..8a86efa0ca1a6956c872d4669d4f7e2349c7f498 100644 (file)
@@ -616,17 +616,25 @@ COMMAND_HANDLER(handle_exit_command)
        return ERROR_COMMAND_CLOSE_CONNECTION;
 }
 
-int telnet_register_commands(struct command_context *command_context)
+static const struct command_registration telnet_command_handlers[] = {
+       {
+               .name = "exit",
+               .handler = &handle_exit_command,
+               .mode = COMMAND_EXEC,
+               .help = "exit telnet session",
+       },
+       {
+               .name = "telnet_port",
+               .handler = &handle_telnet_port_command,
+               .mode = COMMAND_ANY,
+               .help = "port on which to listen "
+                       "for incoming telnet connections",
+               .usage = "<port>",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
+int telnet_register_commands(struct command_context *cmd_ctx)
 {
-       COMMAND_REGISTER(command_context, NULL, "exit",
-                       &handle_exit_command, COMMAND_EXEC,
-                       "exit telnet session");
-
-       COMMAND_REGISTER(command_context, NULL, "telnet_port",
-                       &handle_telnet_port_command, COMMAND_ANY,
-                       "port on which to listen for incoming telnet connections");
-
-       return ERROR_OK;
+       return register_commands(cmd_ctx, NULL, telnet_command_handlers);
 }
-
-