Files
sics/SICSmain.c
Ferdi Franceschini 10d29d597c Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c
Conflicts:
	.gitignore
	SICSmain.c
	asynnet.c
	confvirtualmot.c
	counter.c
	devexec.c
	drive.c
	event.h
	exebuf.c
	exeman.c
	histmem.c
	interface.h
	motor.c
	motorlist.c
	motorsec.c
	multicounter.c
	napi.c
	napi.h
	napi4.c
	network.c
	nwatch.c
	nxscript.c
	nxxml.c
	nxxml.h
	ofac.c
	reflist.c
	scan.c
	sicshipadaba.c
	sicsobj.c
	site_ansto/docs/Copyright.txt
	site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl
	site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl
	statusfile.c
	tasdrive.c
	tasub.c
	tasub.h
	tasublib.c
	tasublib.h
2015-04-23 20:49:26 +10:00

103 lines
2.3 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"
#include "servlog.h"
#include "sicsglobal.h"
extern void KeepStartupCommands(); /* ofac.c */
/* ========================= Less dreadful file statics =================== */
#define DEFAULTINIFILE "servo.tcl"
int usage(const char *name)
{
fprintf(stderr, "usage: %s [-d] [-nolog] <config.tcl>\n", name);
fprintf(stderr, " -d: daemonize the process\n");
fprintf(stderr, " -nolog: disable log file writing\n");
return 1;
}
/*---------------------------------------------------------------------------
The Servers Main program. May take one argument: the name of an
initialisation file
*/
int main(int argc, char *argv[])
{
int iRet;
int daemonize = 0;
char *file = NULL;
int i, firstArg = 1;
extern pServer pServ;
argv0 = argv[0];
if (argc < 2)
return usage(argv[0]);
/* initialise, will die on you if problems */
for (i = firstArg; i < argc; i++) {
if (argv[i][0] == '-') {
if (strcasecmp(argv[i], "-nolog") == 0) {
SICSLogEnable(0);
}else if(strcmp(argv[i],"-keepstartup") == 0){
KeepStartupCommands();
#ifdef SITE_ANSTO
} else if (strcasecmp(argv[i], "-v") == 0) {
extern void SiteReportVersion(void);
SiteReportVersion();
return 0;
#endif
} else if (strcasecmp(argv[i], "-d") == 0) {
daemonize = 1;
} else {
fprintf(stderr, "Unrecognized option ignored: %s\n", argv[i]);
}
} else if (file == NULL) {
file = argv[i];
} else {
fprintf(stderr, "Unrecognized argument ignored: %s\n", argv[i]);
}
}
if (file == NULL)
return usage(argv[0]);
iRet = InitServer(file, &pServ);
if (!iRet) {
printf("Unrecoverable error on server startup, exiting.........\n");
exit(1);
}
if (daemonize == 1)
daemon(1, 1);
RunServer(pServ);
StopServer(pServ);
pServ = NULL;
exit(0);
}