From: Naffanya Date: Thu, 10 Apr 2014 00:39:50 +0000 (+0300) Subject: Merge branch 'master' into naffanya-dev X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/fc0e3a75f76a611f67a846737dabda1c64b2ecd0?hp=920fdb96809e7caae6a7cecc0ac8e5f7e26411c5 Merge branch 'master' into naffanya-dev --- diff --git a/projects/rscriptd/build b/projects/rscriptd/build index c7aa090d..62681932 100755 --- a/projects/rscriptd/build +++ b/projects/rscriptd/build @@ -20,6 +20,7 @@ if [ "$1" = "debug" ] then DEFS="$DEFS -DDEBUG" MAKEOPTS="$MAKEOPTS -j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra" DEBUG="yes" else @@ -27,6 +28,7 @@ else DEBUG="no" fi +CFLAGS="$CFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" diff --git a/projects/sgauth/build b/projects/sgauth/build index 5ea022a2..203e0c88 100755 --- a/projects/sgauth/build +++ b/projects/sgauth/build @@ -20,6 +20,7 @@ if [ "$1" = "debug" ] then DEFS="$DEFS -DDEBUG" MAKEOPTS="$MAKEOPTS -j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra" DEBUG="yes" else @@ -27,8 +28,9 @@ else DEBUG="no" fi +CFLAGS="$CFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS -I/usr/local/include" -LDFLAGS="$CXXFLAGS -L/usr/local/lib" +LDFLAGS="$LDFLAGS -L/usr/local/lib" if [ "$sys" = "Linux" ] then diff --git a/projects/sgauthstress/build b/projects/sgauthstress/build index 2b145659..825f00b5 100755 --- a/projects/sgauthstress/build +++ b/projects/sgauthstress/build @@ -25,6 +25,7 @@ else then DEFS="-DDEBUG" MAKEOPTS="-j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall" DEBUG="yes" else @@ -33,8 +34,9 @@ else fi fi +CFLAGS="$CFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS -I/usr/local/include" -LDFLAGS="$CXXFLAGS -L/usr/local/lib" +LDFLAGS="$LDFLAGS -L/usr/local/lib" if [ "$sys" = "Linux" ] then diff --git a/projects/sgconf/build b/projects/sgconf/build index d7b72363..62fceb23 100755 --- a/projects/sgconf/build +++ b/projects/sgconf/build @@ -20,6 +20,7 @@ if [ "$1" = "debug" ] then DEFS="$DEFS -DDEBUG" MAKEOPTS="$MAKEOPTS -j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra" DEBUG="yes" else @@ -27,6 +28,7 @@ else DEBUG="no" fi +CFLAGS="$CFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" diff --git a/projects/sgconf/main.cpp b/projects/sgconf/main.cpp index 2d39cb2c..9025602e 100644 --- a/projects/sgconf/main.cpp +++ b/projects/sgconf/main.cpp @@ -209,6 +209,66 @@ class CONFIG_ACTION : public ACTION void ParseHostAndPort(const std::string & hostAndPort); }; +class COMMAND_FUNCTOR +{ + public: + virtual ~COMMAND_FUNCTOR() {} + virtual bool operator()(const std::string& arg, const std::map& options) = 0; +}; + +class COMMAND_ACTION : public ACTION +{ + public: + COMMAND_ACTION(CONFIG & config, + const std::string & paramDescription, + bool needArgument, + const OPTION_BLOCK& suboptions, + COMMAND_FUNCTOR* funPtr) + : m_config(config), + m_description(paramDescription), + m_argument(needArgument), + m_suboptions(suboptions), + m_funPtr(funPtr) + {} + + virtual ACTION * Clone() const { return new COMMAND_ACTION(*this); } + + virtual std::string ParamDescription() const { return m_description; } + virtual std::string DefaultDescription() const { return ""; } + virtual OPTION_BLOCK & Suboptions() { return m_suboptions; } + virtual PARSER_STATE Parse(int argc, char ** argv) + { + PARSER_STATE state(false, argc, argv); + if (m_argument) + { + if (argc == 0 || + argv == NULL || + *argv == NULL) + throw ERROR("Missing argument."); + m_argument = *argv; + --state.argc; + ++state.argv; + } + std::list::iterator it(m_suboptions.begin()); + while (!state.stop && it != m_suboptions.end()) + { + state = it->Parse(state.argc, state.argv); + ++it; + } + m_funPtr(m_argument, m_params); + return state; + } + + private: + CONFIG & m_config; + std::string m_description; + bool m_needArgument; + std::string m_argument; + OPTION_BLOCK m_suboptions; + std::map m_params; + COMMAND_FUNCTOR* m_funPtr; +}; + PARSER_STATE CONFIG_ACTION::Parse(int argc, char ** argv) { if (argc == 0 || diff --git a/projects/sgconf_xml/build b/projects/sgconf_xml/build index e9cfb40b..9314452b 100755 --- a/projects/sgconf_xml/build +++ b/projects/sgconf_xml/build @@ -20,6 +20,7 @@ if [ "$1" = "debug" ] then DEFS="$DEFS -DDEBUG" MAKEOPTS="$MAKEOPTS -j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra" DEBUG="yes" else @@ -27,6 +28,7 @@ else DEBUG="no" fi +CFLAGS="$CFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" diff --git a/projects/sgconv/build b/projects/sgconv/build index 7e430be2..580d515a 100755 --- a/projects/sgconv/build +++ b/projects/sgconv/build @@ -21,6 +21,7 @@ if [ "$1" = "debug" ] then DEFS="$DEFS -DDEBUG" MAKEOPTS="$MAKEOPTS -j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra" DEBUG="yes" else @@ -28,6 +29,7 @@ else DEBUG="no" fi +CFLAGS="$CFLAGS -ggdb3 -W -Wall -I/usr/local/include" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" diff --git a/projects/stargazer/build b/projects/stargazer/build index 2061d538..d8ed3092 100755 --- a/projects/stargazer/build +++ b/projects/stargazer/build @@ -39,6 +39,7 @@ if [ "$1" = "debug" ] then DEFS="$DEFS -DDEBUG" MAKEOPTS="$MAKEOPTS -j1" + CFLAGS="$CFLAGS -ggdb3 -W -Wall" CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall" DEBUG="yes" else @@ -46,6 +47,7 @@ else DEBUG="no" fi +CFLAGS="$CFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib"