int ModuleCmd_Help( Tcl_Interp *interp, int argc, char *argv[]) { /** ** General or module specific help wanted. General help is done within ** here. In case of module specific help we'll call a subroutine to do ** it ... **/ #if WITH_DEBUGGING_MODULECMD ErrorLogger( NO_ERR_START, LOC, _proc_ModuleCmd_Help, NULL); #endif if( argc > 0) PerModuleHelp( interp, argc, argv); else module_usage(stderr); /** ** Return on success **/ #if WITH_DEBUGGING_MODULECMD ErrorLogger( NO_ERR_START, LOC, _proc_ModuleCmd_Help, NULL); #endif return( TCL_OK); } /** End of 'ModuleCmd_Help' **/
int ModuleCmd_Help( Tcl_Interp *interp, int argc, char *argv[]) { /** ** General or module specific help wanted. General help is done within ** here. In case of module specific help we'll call a subroutine to do ** it ... **/ if( argc > 0) PerModuleHelp( interp, argc, argv); else module_usage(stderr); /** ** Return on success **/ return( TCL_OK); } /** End of 'ModuleCmd_Help' **/
static int Check_Switches( int *argc, char *argv[]) { int c; /** ** These are the options we do provide **/ const struct option longopts[] = { { "force", no_argument, NULL, 'f' }, { "terse", no_argument, NULL, 't' }, { "long", no_argument, NULL, 'l' }, { "human", no_argument, NULL, 'h' }, { "parseable", no_argument, NULL, 'p' }, { "parse", no_argument, NULL, 'p' }, { "verbose", no_argument, NULL, 'v' }, { "silent", no_argument, NULL, 's' }, { "create", no_argument, NULL, 'c' }, { "icase", no_argument, NULL, 'i' }, { "userlvl", required_argument, NULL, 'u'}, { "append", no_argument, NULL, 'a' }, { "help", no_argument, NULL, 'H' }, { "version", no_argument, NULL, 'V' }, { NULL, no_argument, NULL, 0 } }; #if WITH_DEBUGGING_INIT ErrorLogger( NO_ERR_START, LOC, _proc_Check_Switches, NULL); #endif /** ** Scan the command line for options defined in the longopt table. ** Skip the very first argument, which is the shell to be used **/ if( *argc > 1) { while( EOF != (c = getopt_long( *argc-1, &argv[1], "hpftlvsciu:aHV", longopts, NULL))) { switch( c) { /** ** Force **/ case 'f': /* force */ sw_force = 1; break; /** ** Format of the messages **/ case 't': /* terse */ sw_format |= (SW_SET | SW_TERSE); sw_format &= ~ SW_LONG; break; case 'l': /* long */ sw_format |= (SW_SET | SW_LONG); sw_format &= ~ SW_TERSE; break; case 'h': /* human */ sw_format |= (SW_SET | SW_HUMAN); sw_format &= ~ SW_PARSE; break; case 'p': /* parseable */ sw_format |= (SW_SET | SW_PARSE); sw_format &= ~ SW_HUMAN; break; /** ** Verbosity **/ case 'v': /* verbose */ sw_verbose = 1; break; case 's': /* silent */ sw_detach = 1; break; /** ** Caching control **/ case 'c': /* create */ sw_create = 1; break; /** ** Locating **/ case 'i': /* icase */ sw_icase = 1; break; /** ** The user level comes as a string argument to the -u option **/ case 'u': /* userlvl */ cmdModuleUser_sub( optarg); break; /** ** a special purpose flag for 'use' only **/ case 'a': /* --append */ append_flag = 1; break; case 'H': /* helpful info */ module_usage(stderr); return ~TCL_OK; case 'V': /* version */ version(stderr); return ~TCL_OK; /** ** All remaining options will influence their flags as defined ** in the optlong table above. **/ case 0: break; /** ** Error messages for unknown options will be printed by ** getopt ... **/ case '?': break; /** ** Well, this seems to be an internal error **/ default: if( OK != ErrorLogger( ERR_GETOPT, LOC, NULL)) return( TCL_ERROR); /** --- EXIT (FAILURE) ----> **/ break; } /** switch() **/ } /** while() **/ } /** if( argc) **/ /** ** Special things to be dine for the 'silent' option: Pipe stderr ** output to /dev/null **/ if( sw_detach) { sw_verbose = 0; if (!ttyname(2)) { int temp_fd = open("/dev/null", O_RDWR); close(2); dup2(temp_fd, 2); } } /** ** Finally remove all options from the command line stream **/ c = (optind - 1); if ((optind < *argc) && (c > 0)) { while (optind < *argc) { argv[(optind - c)] = argv[optind]; optind++; } *argc -= c; } /** ** Exit on success: **/ #if WITH_DEBUGGING_INIT ErrorLogger(NO_ERR_END, LOC, _proc_Check_Switches, NULL); #endif /* WITH_DEBUGGING_INIT */ return (TCL_OK); } /** End of 'Check_Switches' **/