[Refdb-cvs] CVS: refdb/src refdbc.c,1.70,1.71
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2004-03-31 17:25:27
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20856 Modified Files: refdbc.c Log Message: pass help option through to command in batch mode; check for valid command name in batch mode Index: refdbc.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbc.c,v retrieving revision 1.70 retrieving revision 1.71 diff -u -U2 -r1.70 -r1.71 --- refdbc.c 17 Feb 2004 22:11:54 -0000 1.70 +++ refdbc.c 31 Mar 2004 17:13:38 -0000 1.71 @@ -212,5 +212,4 @@ int n_readinit = 1; /* if 1, read config file. If 0, skip config file */ int retval; - int n_test_cgi = 1; /* whether to test for CGI environment */ int n_inbytes = 0; /* number of bytes to be read on stdin */ FILE* errstream; @@ -228,5 +227,5 @@ for (i = 0; i < argc; i++) { if (argv[i][0] == '-' && argv[i][1] == 'C') { - n_test_cgi = 0; + n_batchmode = 1; break; } @@ -234,5 +233,5 @@ #ifdef REFDB_CGI - if (n_test_cgi) { + if (!n_batchmode) { n_cgi = is_cgi(&request_method, &content_length, delayed_cgi_errmsg); /* 1 if we are running as a cgi app */ } @@ -358,5 +357,9 @@ strncpy(the_cmd, optarg, 31); the_cmd[31] = '\0'; - n_batchmode = 1; + if (!find_command(optarg, commands)) { + fprintf (stderr, "%s: No such command for refdb.\n", optarg); + exit (1); + } +/* n_batchmode was set at startup */ break; case 'd': @@ -381,6 +384,17 @@ break; case 'h': - fprintf(stderr, "Usage: refdbc [-c pager] [-C command] [-d db] [-e logdest] [-F fields] [-G url] [-h] [-i address] [-l loglevel] [-L logfile] [-p port] [-q] [-R pdfroot] [-T time] [-u name] [-v] [-V] [-w password] [-y confdir]\nOptions: -c command line of pager\n -C run command in batch mode\n -d use database db\n -e log destination (0=stderr;1=syslog;2=custom file)\n -F additional fields in reference output\n -G URL of a css stylesheet for HTML output\n -h prints this help\n -i set server IP address\n -l set log level (0<=level<=7)\n -L full path of custom log file\n -p set server port\n -q ignore init-file\n -R set pdf root directory\n -T set timeout in seconds\n -u use this username\n -v show version information\n -V switch to verbose mode\n -w set password (use '*' to be asked interactively)\n -y look for configuration files in confdir\n"); - exit (0); + if (!n_batchmode) { + fprintf(stderr, "Usage: refdbc [-c pager] [-C command] [-d db] [-e logdest] [-F fields] [-G url] [-h] [-i address] [-l loglevel] [-L logfile] [-p port] [-q] [-R pdfroot] [-T time] [-u name] [-v] [-V] [-w password] [-y confdir]\nOptions: -c command line of pager\n -C run command in batch mode\n -d use database db\n -e log destination (0=stderr;1=syslog;2=custom file)\n -F additional fields in reference output\n -G URL of a css stylesheet for HTML output\n -h prints this help\n -i set server IP address\n -l set log level (0<=level<=7)\n -L full path of custom log file\n -p set server port\n -q ignore init-file\n -R set pdf root directory\n -T set timeout in seconds\n -u use this username\n -v show version information\n -V switch to verbose mode\n -w set password (use '*' to be asked interactively)\n -y look for configuration files in confdir\n"); + exit (0); + } + else { + if ((new_the_command = mstrcat(the_command, " -h ", &the_command_len, 0)) == NULL) { + fprintf(stderr, "out of memory\n"); + exit (1); + } + else { + the_command = new_the_command; + } + } break; case 'i': @@ -1964,7 +1978,7 @@ /* now we have the tokens nicely arranged in inargc */ - /* for (i = 0; i < inargc; i++) { */ - /* printf("inargv[%d]: %s\n", i, inargv[i]); */ - /* } */ + for (i = 0; i < inargc; i++) { + printf("inargv[%d]: %s\n", i, inargv[i]); + } /* get options */ |