Skip to content

Commit

Permalink
Whitespace Cleanup and some codestyling corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
NTX authored and NTX committed Mar 9, 2012
1 parent 9980a34 commit 4e62a8a
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 288 deletions.
22 changes: 11 additions & 11 deletions Application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ debug(false), control(false), daemonize(false), libLoaded(false), terminate(fals
refTrim(property);
value = arg.substr(arg.find('=') + 1 , string::npos);
refTrim(value);
}
}
else
{
property = arg.substr(arg.find_first_not_of('-'), string::npos);
value = string("1");
value = string("1");
}
RunOptions.insert(make_pair(property, value));
}
Expand All @@ -39,7 +39,7 @@ debug(false), control(false), daemonize(false), libLoaded(false), terminate(fals
{
config.getline(buff, 1024);
line = buff;
if( (line.length() > 0) &&
if( (line.length() > 0) &&
(line[0] != '#') && (line[0] != ';') &&
(line.find('=') != string::npos))
{
Expand Down Expand Up @@ -118,7 +118,7 @@ void Application::outDebugParams() const
if (isDaemon())
{
sLog->outString("****** Runnig as Daemon ******");
sLog->outString("Process Id: %d Parent Process Id: %d Process Group Id: %d",
sLog->outString("Process Id: %d Parent Process Id: %d Process Group Id: %d",
GetProcessId(), GetParentProcessId(), GetCurrentProcessGroupId());
sLog->outString("Working Directory %s", GetWorkingDirectory());
sLog->outString();
Expand Down Expand Up @@ -169,7 +169,7 @@ void Application::LoadIntConfig(string ConfigName, uint32 Config, uint32 Default
s.str(FileOptions[ConfigName]);
s >> IntConfigs[Config];
}
else
else
IntConfigs[Config] = Default;
}
}
Expand All @@ -190,7 +190,7 @@ void Application::LoadBoolConfig(string ConfigName, uint32 Config, bool Default)
s.str(FileOptions[ConfigName]);
s >> BoolConfigs[Config];
}
else
else
BoolConfigs[Config] = Default;
}
}
Expand All @@ -205,7 +205,7 @@ void Application::LoadIntRunConfig(string ConfigName, string ShortFormat, uint32
s.str(RunOptions[ConfigName]);
s >> IntConfigs[Config];
}
else
else
if (RunOptions.find(ShortFormat) != RunOptions.end())
{
stringstream s;
Expand All @@ -221,7 +221,7 @@ void Application::LoadStringRunConfig(string ConfigName, string ShortFormat, uin
{
if (RunOptions.find(ConfigName) != RunOptions.end())
StringConfigs[Config] = RunOptions[ConfigName];
else
else
if (RunOptions.find(ShortFormat) != RunOptions.end())
StringConfigs[Config] = RunOptions[ShortFormat];
}
Expand All @@ -237,7 +237,7 @@ void Application::LoadBoolRunConfig(string ConfigName, string ShortFormat, uint3
s.str(RunOptions[ConfigName]);
s >> BoolConfigs[Config];
}
else
else
if (RunOptions.find(ShortFormat) != RunOptions.end())
{
stringstream s;
Expand Down Expand Up @@ -382,8 +382,8 @@ uint32 Application::Update()
timeval selectTimeout;
selectTimeout.tv_sec = 0;
selectTimeout.tv_usec = 500000;
int ProcessQueue = threadMgr->CreateThread("Queue", &CallProcessQueue, handler);

int ProcessQueue = threadMgr->CreateThread("Queue", &CallProcessQueue, handler);
if (ProcessQueue == -1)
{
sLog->outError("[Recv Thread] Executing Packet Handling Queue Failed errno: %d",errno);
Expand Down
10 changes: 5 additions & 5 deletions Application/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Daemon.h"

#ifndef __App
#define __App
#define __App

using Files::AsciiFile ;

Expand Down Expand Up @@ -99,7 +99,7 @@ class Application : public Daemon

pthread_mutex_t* GetLogWriteMutex() { return &logMutex; }

protected:
protected:
Options FileOptions;
Options RunOptions;
bool debug;
Expand All @@ -116,10 +116,10 @@ class Application : public Daemon
string ApplicationAddress;
pthread_mutex_t logMutex;

private:
private:
void ParseParams();
void _initGlobals();
void _uninitGlobals();
void _uninitGlobals();
void _InitServerSocket();
void LoadConfigs();

Expand All @@ -134,4 +134,4 @@ class Application : public Daemon
void outDebugParams() const;
void outDebugLibrary() const;
};
#endif
#endif
12 changes: 6 additions & 6 deletions ConfigMgr/ConfigMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ ConfigMgr::ConfigMgr(const char* conf, char* argv[], int argc)
refTrim(property);
value = arg.substr(arg.find('=') + 1 , string::npos);
refTrim(value);
}
}
else
{
property = arg.substr(arg.find_first_not_of('-'), string::npos);
value = string("1");
value = string("1");
}
RunOptions.insert(make_pair(property, value));
}
Expand All @@ -35,7 +35,7 @@ ConfigMgr::ConfigMgr(const char* conf, char* argv[], int argc)
{
config.getline(buff, 1024);
line = buff;
if( (line.length() > 0) &&
if( (line.length() > 0) &&
(line[0] != '#') && (line[0] != ';') &&
(line.find('=') != string::npos))
{
Expand Down Expand Up @@ -72,7 +72,7 @@ string ConfigMgr::LoadStringConfig(string ConfigName, string Default)
{
if (FileOptions.size() > 0)
if (FileOptions.find(ConfigName) != FileOptions.end())
return FileOptions[ConfigName];
return FileOptions[ConfigName];

return Default;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ int ConfigMgr::LoadIntRunConfig(string ConfigName, string ShortFormat, int Defau
s >> value;
return value;
}
else
else
if (RunOptions.find(ShortFormat) != RunOptions.end())
{
stringstream s;
Expand Down Expand Up @@ -142,7 +142,7 @@ bool ConfigMgr::LoadBoolRunConfig(string ConfigName, string ShortFormat, bool De
s >> value;
return value;
}
else
else
if (RunOptions.find(ShortFormat) != RunOptions.end())
{
stringstream s;
Expand Down
10 changes: 5 additions & 5 deletions Daemon/Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ void Daemon::Daemonize(const char* lockFile, const char* workingDir)
int i, lfp;
char str[10];
#pragma GCC diagnostic ignored "-Wunused-result"
if (GetParentProcessId() == 1)
if (GetParentProcessId() == 1)
return;
i = fork();
if (i < 0)
exit(-1);
if (i > 0)
if (i > 0)
exit(0);
SetCurrentProcessSessionId();
for (i = getdtablesize(); i >= 0; --i)
for (i = getdtablesize(); i >= 0; --i)
close(i);
i = open("/dev/null", O_RDWR);
i = open("/dev/null", O_RDWR);
dup(i);
dup(i);
umask(027);
Expand All @@ -26,7 +26,7 @@ void Daemon::Daemonize(const char* lockFile, const char* workingDir)
if (lockFile)
{
lfp = open(lockFile, O_RDWR | O_CREAT, 0640);
if (lfp < 0)
if (lfp < 0)
exit(-1);
if (lockf(lfp, F_TLOCK, 0) < 0)
exit(0);
Expand Down
Loading

0 comments on commit 4e62a8a

Please sign in to comment.