From dc15e3b0d74480b8468c469e96ec21d14e230346 Mon Sep 17 00:00:00 2001 From: Andrew Karpow Date: Mon, 27 Oct 2014 22:12:10 +0100 Subject: [PATCH] add WITH_DYNAMIC_SERVING for theme developing --- CMakeLists.txt | 1 + src/config.h.in | 4 ++-- src/ympd.c | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4839c84..4fb845b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ set(CPACK_PACKAGE_VERSION_MINOR "2") set(CPACK_PACKAGE_VERSION_PATCH "3") option(WITH_MPD_HOST_CHANGE "Let users of the web frontend change the MPD Host" ON) +option(WITH_DYNAMIC_SERVING "Serve file of ./htdocs dynamically (development)" OFF) option(WITH_IPV6 "enable IPv6 support" ON) find_package(LibMPDClient REQUIRED) diff --git a/src/config.h.in b/src/config.h.in index 242fb0b..202d63a 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -22,8 +22,8 @@ #define YMPD_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR} #define YMPD_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR} #define YMPD_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH} -#define DATADIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}" -#define LOCAL_RESOURCE_PATH DATADIR"/htdocs" +#define SRC_PATH "${PROJECT_SOURCE_DIR}/htdocs" #cmakedefine WITH_MPD_HOST_CHANGE +#cmakedefine WITH_DYNAMIC_SERVING #endif diff --git a/src/ympd.c b/src/ympd.c index c6d87c0..cb7912b 100644 --- a/src/ympd.c +++ b/src/ympd.c @@ -51,7 +51,11 @@ static int server_callback(struct mg_connection *c, enum mg_event ev) { else return MG_TRUE; } else +#ifdef WITH_DYNAMIC_SERVING + return MG_FALSE; +#else return callback_http(c); +#endif case MG_AUTH: return MG_TRUE; default: @@ -69,6 +73,10 @@ int main(int argc, char **argv) atexit(bye); error_msg = mg_set_option(server, "listening_port", "8080"); +#ifdef WITH_DYNAMIC_SERVING + mg_set_option(server, "document_root", SRC_PATH); +#endif + mpd.port = 6600; strcpy(mpd.host, "127.0.0.1"); -- 2.20.1