From 6ad7301c3a364a34747ecc631a8b239570c303fa Mon Sep 17 00:00:00 2001 From: bertho Date: Wed, 4 Feb 2009 11:37:49 +0000 Subject: - Add missing include files - Add config option for xml macros and templates basedir --- server/src/configuration.cc | 4 ++++ server/src/configuration.h | 2 ++ server/src/configurationparser.cc | 5 +++++ server/src/macroparser.cc | 4 +++- server/src/pracrod.cc | 13 ++++++++++++- server/src/saxparser.cc | 2 ++ server/src/server.cc | 1 + server/src/templateparser.cc | 4 +++- server/src/xml_encode_decode.cc | 1 + 9 files changed, 33 insertions(+), 3 deletions(-) diff --git a/server/src/configuration.cc b/server/src/configuration.cc index 8e932d1..c921da6 100644 --- a/server/src/configuration.cc +++ b/server/src/configuration.cc @@ -26,6 +26,8 @@ */ #include "configuration.h" +#include + port_t Conf::server_port = 12345; std::string Conf::server_user = "pracro"; std::string Conf::server_group = "pracro"; @@ -42,3 +44,5 @@ port_t Conf::pentominos_port = 11108; std::string Conf::database_addr = "localhost"; std::string Conf::database_user = "pracro"; std::string Conf::database_passwd = "pracro"; + +std::string Conf::xml_basedir = XML; diff --git a/server/src/configuration.h b/server/src/configuration.h index fde9bd1..56a2f0e 100644 --- a/server/src/configuration.h +++ b/server/src/configuration.h @@ -51,6 +51,8 @@ namespace Conf { extern std::string database_addr; extern std::string database_user; extern std::string database_passwd; + + extern std::string xml_basedir; }; #endif/*__ARTEFACT_CONFIGURATION_H__*/ diff --git a/server/src/configurationparser.cc b/server/src/configurationparser.cc index 6bab578..1c89655 100644 --- a/server/src/configurationparser.cc +++ b/server/src/configurationparser.cc @@ -122,4 +122,9 @@ void ConfigurationParser::reload() } catch( ... ) { } + try { + std::string p = lookup("xml_basedir"); + Conf::xml_basedir = p; + } catch( ... ) { + } } diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index 582c90c..ae7f648 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -25,6 +25,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "macroparser.h" +#include "configuration.h" // For assert #include @@ -44,6 +45,7 @@ #endif/*XML*/ #include +#include #include "exception.h" @@ -70,7 +72,7 @@ MacroParser::MacroParser(std::string macro) current_map = NULL; current_script = NULL; - file = XML"/macros/" + macro + ".xml"; + file = Conf::xml_basedir + "/macros/" + macro + ".xml"; printf("Using macro file: %s\n", file.c_str()); diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc index 6ca21db..634ae67 100644 --- a/server/src/pracrod.cc +++ b/server/src/pracrod.cc @@ -82,6 +82,7 @@ static const char usage_str[] = " -f, --foreground Run in foreground mode (non-background mode)\n" " -u, --user user Run as 'user' (overrides the configfile)\n" " -g, --group group Run as 'group' (overrides the configfile)\n" +" -x, --xml-basedir d Use 'd' as basedir for finding template- and macro-files (default "XML").\n" " -v, --version Print version information and exit.\n" " -h, --help Print this message and exit.\n" ; @@ -139,6 +140,7 @@ int main(int argc, char *argv[]) char *user = NULL; char *group = NULL; bool foreground = false; + char *xml_basedir = NULL; int option_index = 0; while(1) { @@ -150,10 +152,11 @@ int main(int argc, char *argv[]) {"group", required_argument, 0, 'g'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, + {"xml-basedir", required_argument, 0, 'x'}, {0, 0, 0, 0} }; - c = getopt_long (argc, argv, "hvfc:u:g:", long_options, &option_index); + c = getopt_long (argc, argv, "hvfc:u:g:x:", long_options, &option_index); if (c == -1) break; @@ -175,6 +178,10 @@ int main(int argc, char *argv[]) group = strdup(optarg); break; + case 'x': + xml_basedir = strdup(optarg); + break; + case '?': case 'h': printf(version_str); @@ -204,6 +211,10 @@ int main(int argc, char *argv[]) group = strdup(Conf::server_group.c_str()); } + if(xml_basedir) { + Conf::xml_basedir = xml_basedir; + } + signal(SIGHUP, reload); signal(SIGCLD, childwait); if(foreground) signal (SIGINT, ctrl_c); diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc index 4a69a6c..fc1803e 100644 --- a/server/src/saxparser.cc +++ b/server/src/saxparser.cc @@ -26,6 +26,8 @@ */ #include "saxparser.h" +#include + static void character_hndl(void *p, const XML_Char *s, int len) { SAXParser *parser = (SAXParser*)XML_GetUserData(p); diff --git a/server/src/server.cc b/server/src/server.cc index 01e9398..3e41d67 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -34,6 +34,7 @@ // For fork #include #include +#include #include "configuration.h" #include "transaction.h" diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 8874b74..412924c 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -25,6 +25,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "templateparser.h" +#include "configuration.h" // For assert #include @@ -44,6 +45,7 @@ #endif/*XML*/ #include +#include #include "exception.h" @@ -69,7 +71,7 @@ TemplateParser::TemplateParser(std::string course) t = new Template(); current_macro = NULL; - file = XML"/templates/" + course + ".xml"; + file = Conf::xml_basedir + "/templates/" + course + ".xml"; printf("Using template file: %s\n", file.c_str()); diff --git a/server/src/xml_encode_decode.cc b/server/src/xml_encode_decode.cc index caf28b2..5ed61f2 100644 --- a/server/src/xml_encode_decode.cc +++ b/server/src/xml_encode_decode.cc @@ -25,6 +25,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "xml_encode_decode.h" +#include char xml_map[][2][16] = { -- cgit v1.2.3