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.
This commit is contained in:
parent
17a9dea53a
commit
8f5ff3ddcf
|
@ -41,6 +41,7 @@
|
||||||
#include "telnet_server.h"
|
#include "telnet_server.h"
|
||||||
#include "gdb_server.h"
|
#include "gdb_server.h"
|
||||||
#include "tcl_server.h"
|
#include "tcl_server.h"
|
||||||
|
#include "httpd.h"
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -216,10 +217,6 @@ struct command_context *setup_command_handler(void)
|
||||||
return cmd_ctx;
|
return cmd_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int httpd_start(void);
|
|
||||||
void httpd_stop(void);
|
|
||||||
|
|
||||||
|
|
||||||
#if !BUILD_HTTPD && !BUILD_ECOSBOARD
|
#if !BUILD_HTTPD && !BUILD_ECOSBOARD
|
||||||
/* implementations of OpenOCD that uses multithreading needs to know when
|
/* implementations of OpenOCD that uses multithreading needs to know when
|
||||||
* OpenOCD is sleeping. No-op in vanilla OpenOCD
|
* OpenOCD is sleeping. No-op in vanilla OpenOCD
|
||||||
|
@ -269,7 +266,7 @@ int openocd_main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
#if BUILD_HTTPD
|
#if BUILD_HTTPD
|
||||||
if (httpd_start() != ERROR_OK)
|
if (httpd_start(cmd_ctx) != ERROR_OK)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ libserver_la_SOURCES = server.c telnet_server.c gdb_server.c
|
||||||
if HTTPD
|
if HTTPD
|
||||||
libserver_la_SOURCES += httpd.c
|
libserver_la_SOURCES += httpd.c
|
||||||
endif
|
endif
|
||||||
|
noinst_HEADERS += httpd.h
|
||||||
|
|
||||||
libserver_la_CFLAGS =
|
libserver_la_CFLAGS =
|
||||||
if IS_MINGW
|
if IS_MINGW
|
||||||
|
|
|
@ -460,7 +460,25 @@ static int ahc_echo(void * cls, struct MHD_Connection * connection,
|
||||||
|
|
||||||
static struct MHD_Daemon * d;
|
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_t attr;
|
||||||
pthread_mutexattr_init(&attr);
|
pthread_mutexattr_init(&attr);
|
||||||
|
@ -475,20 +493,7 @@ int httpd_start(void)
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
|
|
||||||
Jim_CreateCommand(interp,
|
return register_commands(cmd_ctx, NULL, httpd_command_handlers);
|
||||||
"formfetch",
|
|
||||||
httpd_Jim_Command_formfetch,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Jim_CreateCommand(interp,
|
|
||||||
"writeform",
|
|
||||||
httpd_Jim_Command_writeform,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
|
||||||
return ERROR_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpd_stop(void)
|
void httpd_stop(void)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef OPENOCD_SERVER_HTTPD_H
|
||||||
|
#define OPENOCD_SERVER_HTTPD_H
|
||||||
|
|
||||||
|
struct command_context;
|
||||||
|
|
||||||
|
int httpd_start(struct command_context *cmd_ctx);
|
||||||
|
void httpd_stop(void);
|
||||||
|
|
||||||
|
#endif // OPENOCD_SERVER_HTTPD_H
|
Loading…
Reference in New Issue