]> git.stg.codes - stg.git/blobdiff - projects/sgconf/main.cpp
Some refactoring.
[stg.git] / projects / sgconf / main.cpp
index 625e8564a5ce0ad7842b242a34b272d4a0ec6e75..6a71f652ac399d8e9255b8bf7807f1d956aaba49 100644 (file)
 #include "actions.h"
 #include "config.h"
 
-#include "stg/servconf.h"
-#include "stg/user_conf.h"
-#include "stg/user_stat.h"
-#include "stg/common.h"
-
-#include <cerrno>
-#include <clocale>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
 #include <string>
-#include <sstream>
+#include <iostream>
 
-#include <unistd.h>
-#include <getopt.h>
-#include <iconv.h>
-#include <langinfo.h>
+#include <cstdlib> // getenv
+#include <cstring> // basename
 
-namespace
-{
-
-template <typename T>
-struct ARRAY_TYPE
-{
-typedef typename T::value_type type;
-};
+#include <unistd.h> // access
 
-template <typename T>
-struct ARRAY_TYPE<T[]>
-{
-typedef T type;
-};
-
-template <typename T, size_t N>
-struct ARRAY_TYPE<T[N]>
+namespace
 {
-typedef T type;
-};
 
 template <typename T>
 struct nullary_function
@@ -144,26 +116,6 @@ CONST_METHOD1_ADAPTER<C, A, R> Method1Adapt(R (C::* func)(A) const, C & obj)
 return CONST_METHOD1_ADAPTER<C, A, R>(func, obj);
 }
 
-template <typename T>
-bool SetArrayItem(T & array, const char * index, const typename ARRAY_TYPE<T>::type & value)
-{
-size_t pos = 0;
-if (str2x(index, pos))
-    return false;
-array[pos] = value;
-return true;
-}
-
-void RawXMLCallback(bool result, const std::string & reason, const std::string & response, void * /*data*/)
-{
-if (!result)
-    {
-    std::cerr << "Failed to get raw XML response. Reason: '" << reason << "'." << std::endl;
-    return;
-    }
-SGCONF::PrintXML(response);
-}
-
 void Version(const std::string & self)
 {
 std::cout << self << ", version: 2.0.0-alpha.\n";
@@ -396,17 +348,6 @@ ACTION * MakeAPIAction(COMMANDS & commands,
 return new API_ACTION(commands, "", false, funPtr);
 }
 
-bool RawXMLFunction(const SGCONF::CONFIG & config,
-                    const std::string & arg,
-                    const std::map<std::string, std::string> & /*options*/)
-{
-    STG::SERVCONF proto(config.server.data(),
-                        config.port.data(),
-                        config.userName.data(),
-                        config.userPass.data());
-    return proto.RawXML(arg, RawXMLCallback, NULL) == STG::st_ok;
-}
-
 } // namespace SGCONF
 
 time_t stgTime;