git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1363 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2007-10-15 22:59:08 +00:00
parent ff820b7ab3
commit 694f1a417e
8 changed files with 423 additions and 36 deletions
+3 -4
View File
@@ -2242,8 +2242,7 @@ void fatal(char *s, char *o) { cleanupserver(); printf("fatal: %s\n", s); exit(E
int main(int argc, char **argv)
{
int uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5, port = 0;
char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *adminpasswd = NULL, *srvmsg = NULL;
bool service = false;
char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *adminpasswd = NULL, *srvmsg = NULL, *service = NULL;
for(int i = 1; i<argc; i++)
{
@@ -2260,7 +2259,7 @@ int main(int argc, char **argv)
case 'x': adminpasswd = a; break;
case 'o': srvmsg = a; break;
case 'k': scthreshold = atoi(a); break;
case 's': service = true; break;
case 's': service = a; break;
case 'f': port = atoi(a); break;
default: printf("WARNING: unknown commandline option\n");
}
@@ -2269,7 +2268,7 @@ int main(int argc, char **argv)
if(service && !svcctrl)
{
#ifdef WIN32
svcctrl = new winservice();
svcctrl = new winservice(service);
#endif
if(svcctrl)
{
+3 -32
View File
@@ -17,9 +17,9 @@ struct winservice : servercontroller
SERVICE_STATUS_HANDLE statushandle;
SERVICE_STATUS status;
HANDLE stopevent;
const char *name, *displayname;
const char *name;
winservice() : name("assaultcubeserver"), displayname("AssaultCube Server") { callbacks::svc = this; };
winservice(const char *name) : name(name) { callbacks::svc = this; };
~winservice()
{
if(status.dwCurrentState != SERVICE_STOPPED) stop();
@@ -88,36 +88,7 @@ struct winservice : servercontroller
extern int main(int argc, char **argv);
return main(0, NULL); // todo args
}
/*bool install() // provide install routine?
{
SC_HANDLE scm, svc;
char path[MAX_PATH];
if(!GetModuleFileName(NULL, path, MAX_PATH)) return false;
if((scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) return false;
printf("checking if the service is already installed..");
svc = OpenService(scm, name, SC_MANAGER_CONNECT);
if(svc)
{
printf("service already exists..");
return false;
}
printf("service not found, trying to install it..");
svc = CreateService(scm, name, displayname, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, path, NULL, NULL, NULL, NULL, NULL);
if(svc == NULL)
{
printf("service installation failed");
CloseServiceHandle(scm);
return false;
}
else
{
CloseServiceHandle(svc);
CloseServiceHandle(scm);
printf("service installation successfull\n");
return true;
}
}*/
struct callbacks
{