fix typos in source files
[fw/openocd] / src / server / httpd.c
index 1c5e6d2b929a9cf3fc2e270fff4f57dc4baab00d..9fa58790f1f79db0fe5b769345a929a3da769c4e 100644 (file)
@@ -207,7 +207,7 @@ static void request_completed(void *cls, struct MHD_Connection *connection,
        *con_cls = NULL;
 }
 
-/* append to said key in dictonary */
+/* append to said key in dictionary */
 static void append_key(struct httpd_request *r, const char *key,
                const char *data, size_t off, size_t size)
 {
@@ -388,7 +388,7 @@ static int ahc_echo_inner(void * cls, struct MHD_Connection * connection,
                r->post = post;
                Jim_SetVariableStr(interp, "httppostdata", Jim_NewDictObj(interp, NULL, 0));
 
-               /* fill in url query strings in dictonary */
+               /* fill in url query strings in dictionary */
                MHD_get_connection_values(connection, MHD_GET_ARGUMENT_KIND,
                                record_arg, r);
 
@@ -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)