Files
sics/SICSmain.c
Douglas Clowes 8678bcb102 Add -d option for debugging - to suppress daemonisation for profiler and debugger
r1979 | dcl | 2007-05-23 08:55:21 +1000 (Wed, 23 May 2007) | 2 lines
2012-11-15 13:18:12 +11:00

99 lines
2.2 KiB
C

/*--------------------------------------------------------------------------
THE SICS SERVER
This file contains the main entry point into the world of SICS.
Mark Koennecke, October 1996
Copyright: see copyright.h
Labor fuer Neutronenstreuung
Paul Scherrer Institut
CH-5423 Villigen-PSI
----------------------------------------------------------------------------*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "nserver.h"
/***************************** Necessary Globals ****************************/
IPair *pSICSOptions = NULL;
pServer pServ = NULL;
/* ========================= Less dreadful file statics =================== */
#define DEFAULTINIFILE "servo.tcl"
/*---------------------------------------------------------------------------
The Servers Main program. May take one argument: the name of an
initialisation file
*/
int main(int argc, char *argv[])
{
int iRet;
int debug = 0;
const char* filename = NULL;
/* initialise, will die on you if problems */
if(argc >= 2)
{
if (strcasecmp(argv[1], "-d") == 0)
{
debug = 1;
if (argc > 2)
filename = argv[2];
}
else
{
filename = argv[1];
}
}
iRet = InitServer(filename, &pServ);
if(!iRet)
{
printf("Unrecoverable error on server startup, exiting.........\n");
exit(1);
}
if (debug == 0)
daemon(1,1);
RunServer(pServ);
StopServer(pServ);
pServ = NULL;
exit(0);
}
/*--------------------------------------------------------------------------*/
SicsInterp *GetInterpreter(void)
{
return pServ->pSics;
}
/*--------------------------------------------------------------------------*/
pExeList GetExecutor(void)
{
return pServ->pExecutor;
}
/*------------------------------------------------------------------------*/
void StopExit(void)
{
if(pServ)
{
StopServer(pServ);
}
}
/*-------------------------------------------------------------------------*/
pTaskMan GetTasker(void)
{
return pServ->pTasker;
}