From: Vlad S. <ser...@us...> - 2005-04-03 23:37:17
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24321/nsd Modified Files: nsmain.c Removed Files: getopt.c Log Message: changed command line parsing from getopt to simple manual processing thus getopt is not needed anymore --- getopt.c DELETED --- Index: nsmain.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsmain.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** nsmain.c 3 Apr 2005 06:38:01 -0000 1.4 --- nsmain.c 3 Apr 2005 23:37:06 -0000 1.5 *************** *** 70,74 **** static int WaitForServer(); ! static void UsageError(char *msg); static void StatusMsg(int state); static char *FindConfig(char *config); --- 70,74 ---- static int WaitForServer(); ! static void UsageError(char *msg, ...); static void StatusMsg(int state); static char *FindConfig(char *config); *************** *** 109,117 **** Ns_Main(int argc, char **argv, Ns_ServerInitProc *initProc) { ! int i, fd, sig, cmdargc; ! char **cmdargv; char *config; Ns_Time timeout; - char buf[PATH_MAX]; #ifndef _WIN32 --- 109,115 ---- Ns_Main(int argc, char **argv, Ns_ServerInitProc *initProc) { ! int i, fd, sig; char *config; Ns_Time timeout; #ifndef _WIN32 *************** *** 198,204 **** */ ! opterr = 0; ! while ((i = getopt(argc, argv, "+chpzifwVs:t:IRSkKdr:u:g:b:B:")) != -1) { ! switch (i) { case 'h': UsageError(NULL); --- 196,205 ---- */ ! for (i = 1; i < argc; i++) { ! if (argv[i][0] != '-') { ! UsageError("invalid option: %s", argv[i]); ! exit(1); ! } ! switch (argv[i][1]) { case 'h': UsageError(NULL); *************** *** 221,225 **** #endif } ! mode = i; break; case 's': --- 222,226 ---- #endif } ! mode = argv[i][1]; break; case 's': *************** *** 227,231 **** UsageError("multiple -s <server> options"); } ! server = optarg; break; case 't': --- 228,236 ---- UsageError("multiple -s <server> options"); } ! if (i + 1 < argc) { ! server = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; case 't': *************** *** 233,237 **** UsageError("multiple -t <file> options"); } ! nsconf.config = optarg; break; case 'p': --- 238,246 ---- UsageError("multiple -t <file> options"); } ! if (i + 1 < argc) { ! nsconf.config = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; case 'p': *************** *** 241,252 **** #ifndef _WIN32 case 'b': ! bindargs = optarg; break; case 'B': ! bindfile = optarg; break; case 'r': ! root = optarg; ! break; break; case 'd': --- 250,272 ---- #ifndef _WIN32 case 'b': ! if (i + 1 < argc) { ! bindargs = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; case 'B': ! if (i + 1 < argc) { ! bindfile = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; case 'r': ! if (i + 1 < argc) { ! root = server = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; case 'd': *************** *** 254,270 **** break; case 'g': ! garg = optarg; break; case 'u': ! uarg = optarg; break; #endif - case ':': - sprintf(buf, "option -%c requires a parameter", optopt); - UsageError(buf); - break; default: ! sprintf(buf, "invalid option: -%c", optopt); ! UsageError(buf); break; } --- 274,293 ---- break; case 'g': ! if (i + 1 < argc) { ! garg = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; case 'u': ! if (i + 1 < argc) { ! uarg = argv[++i]; ! } else { ! UsageError("no parameter for -%c option", argv[i][1]); ! } break; #endif default: ! UsageError("invalid option: -%c", argv[i][1]); break; } *************** *** 514,518 **** Tcl_FindExecutable(argv[0]); nsconf.nsd = (char *) Tcl_GetNameOfExecutable(); ! NsConfigEval(config, argc, argv, optind); ns_free(config); --- 537,541 ---- Tcl_FindExecutable(argv[0]); nsconf.nsd = (char *) Tcl_GetNameOfExecutable(); ! NsConfigEval(config, argc, argv, argc); ns_free(config); *************** *** 718,728 **** NsRestoreSignals(); ! cmdargv = ns_calloc((size_t) argc - optind + 2, sizeof(char *)); ! cmdargc = 0; ! cmdargv[cmdargc++] = argv[0]; ! for (i = optind; i < argc; i++) { ! cmdargv[cmdargc++] = argv[i]; ! } ! Tcl_Main(cmdargc, cmdargv, CommandInit); } --- 741,745 ---- NsRestoreSignals(); ! Tcl_Main(argc, argv, CommandInit); } *************** *** 1004,1011 **** static void ! UsageError(char *msg) { if (msg != NULL) { ! fprintf(stderr, "\nError: %s\n", msg); } fprintf(stderr, "\n" --- 1021,1033 ---- static void ! UsageError(char *msg, ...) { if (msg != NULL) { ! va_list ap; ! va_start(ap, msg); ! fprintf(stderr, "\nError: "); ! vfprintf(stderr, msg, ap); ! fprintf(stderr, "\n"); ! va_end(ap); } fprintf(stderr, "\n" |