only display usable commands in help
[openocd.git] / src / server / httpd.c
index d8659b09e6c39c7d64a4da8abaf041fef5dbd7bf..9fa58790f1f79db0fe5b769345a929a3da769c4e 100644 (file)
@@ -109,7 +109,7 @@ static int httpd_Jim_Command_writeform(Jim_Interp *interp, int argc,
 {
        if (argc != 3)
        {
-               Jim_WrongNumArgs(interp, 1, argv, "method ?args ...?");
+               Jim_WrongNumArgs(interp, 1, argv, "method ?CMD_ARGV ...?");
                return JIM_ERR;
        }
        char *name = (char*) Jim_GetString(argv[1], NULL);
@@ -156,7 +156,7 @@ httpd_Jim_Command_formfetch(Jim_Interp *interp,
 {
     if (argc != 2)
     {
-        Jim_WrongNumArgs(interp, 1, argv, "method ?args ...?");
+        Jim_WrongNumArgs(interp, 1, argv, "method ?CMD_ARGV ...?");
         return JIM_ERR;
     }
     char *name = (char*)Jim_GetString(argv[1], NULL);
@@ -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)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)