From: Maxim Mamontov Date: Tue, 12 Apr 2011 07:08:14 +0000 (+0300) Subject: Merge branch 'master' of gitorious.org:stg/stg X-Git-Tag: 2.407-rc3~5 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/41ef27bc78218657d477a8f4334dede5d09ab38d?hp=0d979c5993dfa89dcb4a5143202304bba6c55b17 Merge branch 'master' of gitorious.org:stg/stg --- diff --git a/include/stg/plugin.h b/include/stg/plugin.h index d196b353..35a5a4c9 100644 --- a/include/stg/plugin.h +++ b/include/stg/plugin.h @@ -39,7 +39,7 @@ class TRAFFCOUNTER; class SETTINGS; class STORE; -class MODULE_SETTINGS; +struct MODULE_SETTINGS; class PLUGIN : private NONCOPYABLE { public: diff --git a/include/stg/tariffs.h b/include/stg/tariffs.h index 1f91948f..8c098c8b 100644 --- a/include/stg/tariffs.h +++ b/include/stg/tariffs.h @@ -26,7 +26,7 @@ class ADMIN; class TARIFF; -class TARIFF_DATA; +struct TARIFF_DATA; class TARIFFS { public: diff --git a/projects/stargazer/plugins/authorization/ao/ao.cpp b/projects/stargazer/plugins/authorization/ao/ao.cpp index 71d16608..193b20bc 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.cpp +++ b/projects/stargazer/plugins/authorization/ao/ao.cpp @@ -236,13 +236,11 @@ users->CloseSearch(h); //----------------------------------------------------------------------------- void AUTH_AO::Unauthorize(USER_PTR u) const { -printfd(__FILE__, "AUTH_AO::Unauthorize - login: '%s'\n", u->GetLogin().c_str()); u->Unauthorize(this); } //----------------------------------------------------------------------------- void AUTH_AO::UpdateUserAuthorization(USER_PTR u) const { -printfd(__FILE__, "AUTH_AO::UpdateUserAuthorization - login: '%s'\n", u->GetLogin().c_str()); if (u->GetProperty().alwaysOnline) { USER_IPS ips = u->GetProperty().ips; @@ -257,7 +255,6 @@ if (u->GetProperty().alwaysOnline) //----------------------------------------------------------------------------- void AUTH_AO::AddUser(USER_PTR u) { -printfd(__FILE__, "AUTH_AO::AddUser - login: '%s'\n", u->GetLogin().c_str()); SetUserNotifiers(u); usersList.push_back(u); UpdateUserAuthorization(u); @@ -265,7 +262,6 @@ UpdateUserAuthorization(u); //----------------------------------------------------------------------------- void AUTH_AO::DelUser(USER_PTR u) { -printfd(__FILE__, "AUTH_AO::DelUser - login: '%s'\n", u->GetLogin().c_str()); Unauthorize(u); UnSetUserNotifiers(u); usersList.remove(u); @@ -280,7 +276,6 @@ return -1; template void CHG_BEFORE_NOTIFIER::Notify(const varParamType &, const varParamType &) { -printfd(__FILE__, "CHG_BEFORE_NOTIFIER::Notify\n"); //EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::Unauthorize, user); auth.Unauthorize(user); } @@ -288,7 +283,6 @@ auth.Unauthorize(user); template void CHG_AFTER_NOTIFIER::Notify(const varParamType &, const varParamType &) { -printfd(__FILE__, "CHG_AFTER_NOTIFIER::Notify\n"); //EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::UpdateUserAuthorization, user); auth.UpdateUserAuthorization(user); } diff --git a/projects/stargazer/settings_impl.cpp b/projects/stargazer/settings_impl.cpp index e0eb4639..d5fb2dad 100644 --- a/projects/stargazer/settings_impl.cpp +++ b/projects/stargazer/settings_impl.cpp @@ -235,9 +235,9 @@ return 0; //----------------------------------------------------------------------------- void SETTINGS_IMPL::ErrorCallback(void * data, const char * buf) { - printfd(__FILE__, buf); + printfd(__FILE__, "SETTINGS_IMPL::ErrorCallback() - %s\n", buf); SETTINGS_IMPL * settings = static_cast(data); - settings->logger(buf); + settings->logger("%s", buf); } //----------------------------------------------------------------------------- int SETTINGS_IMPL::ReadSettings() diff --git a/projects/stargazer/traffcounter_impl.cpp b/projects/stargazer/traffcounter_impl.cpp index 3f6eb0c0..a605e284 100644 --- a/projects/stargazer/traffcounter_impl.cpp +++ b/projects/stargazer/traffcounter_impl.cpp @@ -90,6 +90,7 @@ if (!stopped) if (ReadRules()) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::Start() - Cannot read rules\n"); WriteServLog("TRAFFCOUNTER: Cannot read rules."); return -1; } @@ -99,6 +100,7 @@ int h = users->OpenSearch(); USER_PTR u; if (!h) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::Start() - Cannot get users\n"); WriteServLog("TRAFFCOUNTER: Cannot get users."); return -1; } @@ -112,7 +114,8 @@ users->CloseSearch(h); running = true; if (pthread_create(&thread, NULL, Run, this)) { - WriteServLog("TRAFFCOUNTER: Error: Cannot start thread!"); + printfd(__FILE__, "TRAFFCOUNTER_IMPL::Start() - Cannot start thread\n"); + WriteServLog("TRAFFCOUNTER: Error: Cannot start thread."); return -1; } return 0; @@ -690,7 +693,8 @@ f = fopen(rulesFileName.c_str(), "rt"); if (!f) { - WriteServLog("File %s cannot be oppened.", rulesFileName.c_str()); + printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - File '%s' cannot be opened.\n", rulesFileName.c_str()); + WriteServLog("File '%s' cannot be oppened.", rulesFileName.c_str()); return true; } @@ -705,7 +709,8 @@ while (fgets(str, 1023, f)) r = sscanf(str,"%s %s %s", tp, ta, td); if (r != 3) { - WriteServLog("Error in file %s. There must be 3 parameters. Line %d.", rulesFileName.c_str(), lineNumber); + printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. There must be 3 parameters.\n", rulesFileName.c_str(), lineNumber); + WriteServLog("Error in file '%s' at line %d. There must be 3 parameters.", rulesFileName.c_str(), lineNumber); fclose(f); return true; } @@ -727,6 +732,7 @@ while (fgets(str, 1023, f)) if (rul.dir == 0xff || rul.proto == 0xff) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d.\n", rulesFileName.c_str(), lineNumber); WriteServLog("Error in file %s. Line %d.", rulesFileName.c_str(), lineNumber); fclose(f); @@ -735,6 +741,7 @@ while (fgets(str, 1023, f)) if (ParseAddress(ta, &rul) != 0) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. Error in adress.\n", rulesFileName.c_str(), lineNumber); WriteServLog("Error in file %s. Error in adress. Line %d.", rulesFileName.c_str(), lineNumber); fclose(f); @@ -769,12 +776,14 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); if (ReadRules(true)) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::Reload() - Failed to reload rules.\n"); WriteServLog("TRAFFCOUNTER: Cannot reload rules. Errors found."); return -1; } FreeRules(); ReadRules(); +printfd(__FILE__, "TRAFFCOUNTER_IMPL::Reload() - Reload rules successfull.\n"); WriteServLog("TRAFFCOUNTER: Reload rules successfull."); return 0; } @@ -829,6 +838,7 @@ if (n == ':') // port if (!(rule->proto == tcp || rule->proto == udp || rule->proto == tcp_udp)) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::ParseAddress() - No ports specified for this protocol.\n"); WriteServLog("No ports specified for this protocol."); return true; } @@ -887,6 +897,7 @@ rule->mask = CalcMask(msk); if ((ip & rule->mask) != ip) { + printfd(__FILE__, "TRAFFCOUNTER_IMPL::ParseAddress() - Address does'n match mask.\n"); WriteServLog("Address does'n match mask."); return true; } diff --git a/stglibs/Makefile.in b/stglibs/Makefile.in index 0417eaff..a0c854e6 100644 --- a/stglibs/Makefile.in +++ b/stglibs/Makefile.in @@ -89,7 +89,7 @@ endif deps: $(SRCS) ../../Makefile.conf @>deps ;\ for file in $(SRCS); do\ - echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -MM -MG $$file` Makefile ../../Makefile.conf" >> deps ;\ + echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\ echo -e '\t$$(CC) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -c $$<' >> deps ;\ done diff --git a/stglibs/dotconfpp.lib/dotconfpp.cpp b/stglibs/dotconfpp.lib/dotconfpp.cpp index ceca3ab2..8ac25440 100644 --- a/stglibs/dotconfpp.lib/dotconfpp.cpp +++ b/stglibs/dotconfpp.lib/dotconfpp.cpp @@ -339,7 +339,7 @@ int DOTCONFDocument::setContent(const char * _fileName) char realpathBuf[PATH_MAX]; if(realpath(_fileName, realpathBuf) == NULL){ - error(0, NULL, "realpath(%s) failed: %s", _fileName, strerror(errno)); + error(0, _fileName, "realpath('%s') failed: %s", _fileName, strerror(errno)); return -1; } @@ -509,13 +509,17 @@ void DOTCONFDocument::error(int lineNum, const char * fileName, const char * fmt va_list args; va_start(args, fmt); - size_t len = (lineNum!=0?strlen(fileName):0) + strlen(fmt) + 50; + char msg[256]; + + vsnprintf(msg, 256, fmt, args); + + size_t len = (lineNum!=0?strlen(fileName):0) + strlen(msg) + 50; char * buf = (char*)mempool->alloc(len); if(lineNum) - (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, fmt); + (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, msg); else - (void) snprintf(buf, len, "DOTCONF++: %s\n", fmt); + (void) snprintf(buf, len, "DOTCONF++: file '%s': %s\n", fileName, msg); if (errorCallback) { errorCallback(errorCallbackData, buf);