[openbnc-cvs] openbnc/src openbnc.c,1.5,1.6
Status: Beta
Brought to you by:
andrereis
From: Mateusz K. <sh...@us...> - 2004-07-06 11:03:58
|
Update of /cvsroot/openbnc/openbnc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10078/openbnc/src Modified Files: openbnc.c Log Message: - Add command line parametrs ( like --help e.t.c ) Index: openbnc.c =================================================================== RCS file: /cvsroot/openbnc/openbnc/src/openbnc.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- openbnc.c 6 Jul 2004 09:37:27 -0000 1.5 +++ openbnc.c 6 Jul 2004 11:03:49 -0000 1.6 @@ -199,17 +199,67 @@ FILE *pidfile,*conffile; int i; + /* Checking uid - IF root -> exit + - it may be really unsecure */ + if ( getuid() == 0 ) { printf("Don't run OpenBNC as root!\n"); exit(127); } - if(argc==2) +/* if(argc>1) { strmncpy(configfile,argv[1],sizeof(configfile)); } else { - strcpy(configfile,"openbnc.conf"); /* rcsid */ - } + strcpy(configfile,"openbnc.conf"); + } */ + + /* Checking parametrs */ + + if ( argc > 1 ) { + + for ( i = 1 ; i < argc ; i++ ) { + + /* --version | -v - Output APPNAME and VERSION */ + if ( !strcasecmp("--version",argv[i]) || !strcasecmp("-v",argv[i]) ) { + printf("%s %s\n",APPNAME,APPVER); + exit(0); + } + + /* --config | -c - Reading config from specify file */ + if ( !strcasecmp("--config",argv[i]) || !strcasecmp("-c",argv[i]) ) { + if ( argv[i+1] != NULL ) { + strcpy(configfile,argv[i+1]); + } else { + printf("ERROR: --config without parametr!\n"); + exit(127); + } + } + + /* --help | -h - Display Help */ + if ( !strcasecmp("--help",argv[i]) || !strcasecmp("-h",argv[i]) ) { + printf("%s %s\n\n",APPNAME,APPVER); + printf("Options :\n"); + printf("---------\n\n"); + printf("-h, --help Display help and exit\n"); + printf("-v, --version Display Version and exit\n"); + printf("-c, --config [file] Read configuration from specified file\n"); + printf("-u, --user [user] Run as specific user [*]\n"); + printf("-g, --group [group] Run as specific group [*]\n"); + printf("-l, --user-limit Max no. of users\n"); + printf("-i, --interval Time between connection attempts to IRC server\n\n"); + exit(0); + } + + } + + } else { + + /* if no paramers - reading standard file */ + strcpy(configfile,"openbnc.conf"); + + } + conffile=fopen(configfile,"r"); if(conffile==NULL) { |