X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/73f662acc31034cd98fdc6e157454f7763ef0792..1347f3d1e04bedd1508589173f577673ee2c5554:/projects/stargazer/main.cpp diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index cabd991b..eb61e2d5 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -60,8 +60,6 @@ #include "pidfile.h" #include "eventloop.h" -using namespace std; - #ifdef DEBUG #define MAIN_DEBUG (1) #define NO_DAEMON (1) @@ -69,7 +67,16 @@ using namespace std; #define START_FILE "/._ST_ART_ED_" -set executersPid; +namespace +{ +std::set executersPid; + +bool StartModCmp(const PLUGIN_RUNNER & lhs, const PLUGIN_RUNNER & rhs); +bool StopModCmp(const PLUGIN_RUNNER & lhs, const PLUGIN_RUNNER & rhs); +void StartTimer(); +int StartScriptExecuter(char * procName, int msgKey, int * msgID, SETTINGS_IMPL * settings); +int ForkAndWait(const std::string & confDir); +void KillExecuters(); //----------------------------------------------------------------------------- bool StartModCmp(const PLUGIN_RUNNER & lhs, const PLUGIN_RUNNER & rhs) @@ -82,7 +89,7 @@ bool StopModCmp(const PLUGIN_RUNNER & lhs, const PLUGIN_RUNNER & rhs) return lhs.GetStopPosition() > rhs.GetStopPosition(); } //----------------------------------------------------------------------------- -static void StartTimer() +void StartTimer() { STG_LOGGER & WriteServLog = GetStgLogger(); @@ -165,14 +172,14 @@ return 0; } //----------------------------------------------------------------------------- #ifndef NO_DAEMON -int ForkAndWait(const string & confDir) +int ForkAndWait(const std::string & confDir) #else -int ForkAndWait(const string &) +int ForkAndWait(const std::string &) #endif { #ifndef NO_DAEMON pid_t childPid = fork(); -string startFile = confDir + START_FILE; +std::string startFile = confDir + START_FILE; unlink(startFile.c_str()); switch (childPid) @@ -209,7 +216,7 @@ return 0; //----------------------------------------------------------------------------- void KillExecuters() { -set::iterator pid; +std::set::iterator pid; pid = executersPid.begin(); while (pid != executersPid.end()) { @@ -219,6 +226,8 @@ while (pid != executersPid.end()) } } //----------------------------------------------------------------------------- +} // namespace anonymous +//----------------------------------------------------------------------------- int main(int argc, char * argv[]) { SETTINGS_IMPL * settings = NULL; @@ -236,10 +245,10 @@ int msgID = -11; WriteServLog.SetLogFileName("/var/log/stargazer.log"); } -vector modSettings; -list modules; +std::vector modSettings; +std::list modules; -list::iterator modIter; +std::list::iterator modIter; if (getuid()) { @@ -264,7 +273,7 @@ if (settings->ReadSettings()) } #ifndef NO_DAEMON -string startFile(settings->GetConfDir() + START_FILE); +std::string startFile(settings->GetConfDir() + START_FILE); #endif if (ForkAndWait(settings->GetConfDir()) < 0) @@ -338,7 +347,7 @@ modSettings = settings->GetModulesSettings(); for (size_t i = 0; i < modSettings.size(); i++) { - string modulePath = settings->GetModulesPath(); + std::string modulePath = settings->GetModulesPath(); modulePath += "/mod_"; modulePath += modSettings[i].moduleName; modulePath += ".so"; @@ -400,7 +409,7 @@ while (modIter != modules.end()) ++modIter; } -srandom(stgTime); +srandom(static_cast(stgTime)); WriteServLog("Stg started successfully."); WriteServLog("+++++++++++++++++++++++++++++++++++++++++++++"); @@ -417,7 +426,7 @@ while (true) bool stop = false; int status; pid_t childPid; - set::iterator it; + std::set::iterator it; switch (sig) { case SIGHUP: