diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-24 10:58:32 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-24 21:37:37 -0800 |
commit | 8f5ff3ddcf0ab11b0ec6fc9215144154fb0519f9 (patch) | |
tree | 10e2c2c19ab0aad9cdaf2e6bd551d1f666f2594b /src/server/httpd.c | |
parent | 17a9dea53a71e9d7e241262725f3dd707b620d37 (diff) |
httpd: use register_commands()
Updates httpd_start() to use register_commands() for 'readform' and
'writeform' commands. Adds server/httpd.h to export the new signatures
for this function (and httpd_stop), which allows removing the obsoleted
declarations inside openocd.c.
Diffstat (limited to 'src/server/httpd.c')
-rw-r--r-- | src/server/httpd.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/server/httpd.c b/src/server/httpd.c index 1c5e6d2b..8c1d3dba 100644 --- a/src/server/httpd.c +++ b/src/server/httpd.c @@ -460,7 +460,25 @@ static int ahc_echo(void * cls, struct MHD_Connection * connection, static struct MHD_Daemon * d; -int httpd_start(void) +static const struct command_registration httpd_command_handlers[] = { + { + .name = "formfetch", + .jim_handler = &httpd_Jim_Command_formfetch, + .mode = COMMAND_EXEC, + .usage = "<parameter_name>", + .help = "Reads a posted form value.", + }, + { + .name = "writeform", + .jim_handler = &httpd_Jim_Command_writeform, + .mode = COMMAND_EXEC, + .usage = "<parameter_name> <file>", + .help = "Writes a form value to a file.", + }, + COMMAND_REGISTRATION_DONE +}; + +int httpd_start(struct command_context *cmd_ctx) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -475,20 +493,7 @@ int httpd_start(void) if (d == NULL) return ERROR_FAIL; - Jim_CreateCommand(interp, - "formfetch", - httpd_Jim_Command_formfetch, - NULL, - NULL); - - Jim_CreateCommand(interp, - "writeform", - httpd_Jim_Command_writeform, - NULL, - NULL); - - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, httpd_command_handlers); } void httpd_stop(void) |