git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change some usleep() to nanosleep() `cause usleep() is obsolete since
[stg.git]
/
projects
/
sgauth
/
main.cpp
diff --git
a/projects/sgauth/main.cpp
b/projects/sgauth/main.cpp
index 1aae7aa6f6c0aaeddf9a603d073f44aa91e048a4..cdda3cb978bb11b335ae8941bc8b5b1467293168 100644
(file)
--- a/
projects/sgauth/main.cpp
+++ b/
projects/sgauth/main.cpp
@@
-105,6
+105,14
@@
private:
};
//-----------------------------------------------------------------------------
SETTINGS::SETTINGS()
};
//-----------------------------------------------------------------------------
SETTINGS::SETTINGS()
+ : port(0),
+ localPort(0),
+ listenWebIP(0),
+ refreshPeriod(0),
+ daemon(false),
+ noWeb(false),
+ reconnect(false),
+ showPid(false)
{
confFile = "/etc/sgauth.conf";
}
{
confFile = "/etc/sgauth.conf";
}
@@
-303,12
+311,6
@@
void Usage()
printf("sgauth <server> <port> <login> <password>\n"); //TODO change to correct
}
//-----------------------------------------------------------------------------
printf("sgauth <server> <port> <login> <password>\n"); //TODO change to correct
}
//-----------------------------------------------------------------------------
-void EventsFn(int)
-{
-LOADSTAT ls;
-clnp->GetStat(&ls);
-}
-//-----------------------------------------------------------------------------
void SetDirName(const vector<string> & dn, void *)
{
for (int j = 0; j < DIR_NUM; j++)
void SetDirName(const vector<string> & dn, void *)
{
for (int j = 0; j < DIR_NUM; j++)
@@
-358,7
+360,7
@@
if (clnp->GetAuthorized())
{
cout << "Connect" << endl;
clnp->Connect();
{
cout << "Connect" << endl;
clnp->Connect();
-
}
+ }
}
//-----------------------------------------------------------------------------
void CatchUSR2(int)
}
//-----------------------------------------------------------------------------
void CatchUSR2(int)
@@
-414,9
+416,6
@@
return;
//-----------------------------------------------------------------------------
int main(int argc, char *argv[])
{
//-----------------------------------------------------------------------------
int main(int argc, char *argv[])
{
-//int port;
-//char *endptr;
-
SETTINGS settings;
#ifndef WIN32
SETTINGS settings;
#ifndef WIN32
@@
-426,13
+425,6
@@
if(0)
#endif
{
settings.SetConfFile(argv[1]);
#endif
{
settings.SetConfFile(argv[1]);
- if (settings.ReadSettings())
- {
- printf("ReadSettingsError\n");
- printf("%s\n", settings.GetStrError().c_str());
- exit(-1);
- }
- settings.Print();
}
else
{
}
else
{
@@
-455,7
+447,13
@@
else
}*/
}
}*/
}
-//settings.Print();
+if (settings.ReadSettings())
+ {
+ printf("ReadSettingsError\n");
+ printf("%s\n", settings.GetStrError().c_str());
+ exit(-1);
+ }
+settings.Print();
#ifndef WIN32
if (settings.GetDaemon())
#ifndef WIN32
if (settings.GetDaemon())
@@
-466,22
+464,19
@@
if (settings.GetDaemon())
switch (fork())
{
switch (fork())
{
- case -1:
// ìÁÖÁ
+ case -1:
exit(1);
break;
exit(1);
break;
- case 0:
// ðÏÔÏÍÏË
+ case 0:
setsid();
break;
setsid();
break;
- default:
// ïÓÎÏ×ÎÏÊ ÐÒÏÃÅÓÓ
+ default:
exit(0);
break;
}
}
exit(0);
break;
}
}
-
-
-
#endif
clnp = new IA_CLIENT_PROT(settings.GetServerName(), settings.GetServerPort(), settings.GetLocalPort());
#endif
clnp = new IA_CLIENT_PROT(settings.GetServerName(), settings.GetServerPort(), settings.GetLocalPort());
@@
-504,7
+499,6
@@
clnp->SetDirNameCb(SetDirName, NULL);
clnp->SetStatChangedCb(StatUpdate, NULL);
clnp->SetReconnect(settings.GetReconnect());
clnp->SetStatChangedCb(StatUpdate, NULL);
clnp->SetReconnect(settings.GetReconnect());
-
clnp->Start();
SetSignalHandlers();
clnp->Start();
SetSignalHandlers();
@@
-566,5
+560,3
@@
while (1)
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
-
-