remove #if BUILD_HTTPD

Add httpd_stubs.c to provide no-op implementations of httpd_start()
and httpd_stop().

Allows these routines to be called unconditionally and ensures the
libocdserver ABI remains unchanged regardless of whether this feature
was built-in or not.

Prints a DEBUG message when the stub implementation is included.
This commit is contained in:
Zachary T Welch 2009-12-01 19:58:32 -08:00
parent eaf10f69de
commit 6ec526e706
4 changed files with 33 additions and 10 deletions

View File

@ -614,12 +614,6 @@ else
AC_DEFINE(BUILD_ZY1000, 0, [0 if you don't want ZY1000.]) AC_DEFINE(BUILD_ZY1000, 0, [0 if you don't want ZY1000.])
fi fi
if test $build_httpd = yes; then
AC_DEFINE(BUILD_HTTPD, 1, [1 if you want httpd.])
else
AC_DEFINE(BUILD_HTTPD, 0, [0 if you don't want httpd.])
fi
if test $build_at91rm9200 = yes; then if test $build_at91rm9200 = yes; then
build_bitbang=yes build_bitbang=yes
AC_DEFINE(BUILD_AT91RM9200, 1, [1 if you want at91rm9200.]) AC_DEFINE(BUILD_AT91RM9200, 1, [1 if you want at91rm9200.])

View File

@ -244,10 +244,8 @@ int openocd_main(int argc, char *argv[])
if (ret != ERROR_OK) if (ret != ERROR_OK)
return EXIT_FAILURE; return EXIT_FAILURE;
#if BUILD_HTTPD
if (httpd_start(cmd_ctx) != ERROR_OK) if (httpd_start(cmd_ctx) != ERROR_OK)
return EXIT_FAILURE; return EXIT_FAILURE;
#endif
ret = server_init(cmd_ctx); ret = server_init(cmd_ctx);
if (ERROR_OK != ret) if (ERROR_OK != ret)
@ -266,9 +264,7 @@ int openocd_main(int argc, char *argv[])
server_quit(); server_quit();
#if BUILD_HTTPD
httpd_stop(); httpd_stop();
#endif
unregister_all_commands(cmd_ctx, NULL); unregister_all_commands(cmd_ctx, NULL);

View File

@ -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
else else
libserver_la_SOURCES += httpd_stubs.c
if !ECOSBOARD if !ECOSBOARD
libserver_la_SOURCES += server_stubs.c libserver_la_SOURCES += server_stubs.c
endif endif

32
src/server/httpd_stubs.c Normal file
View File

@ -0,0 +1,32 @@
/***************************************************************************
* 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. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "httpd.h"
int httpd_start(struct command_context *cmd_ctx)
{
LOG_DEBUG("libocdserver was built without HTTPD support");
return ERROR_OK;
}
void httpd_stop(void)
{
}