int ParseArguments(int argc, char *argv[], tConf *Conf) { int ch; #ifdef WIN32 /* Not clean. Should be a hook to platform specific options parser */ service_parse_cli(argc, argv); #endif while ((ch = getopt(argc, argv, "h?cf:r:i:u:s:")) != -1) { switch (ch) { case 's': Conf->client_v4 = optarg; break; case 'i': Conf->if_tunnel_v6v4 = optarg; break; case 'u': Conf->if_tunnel_v6udpv4 = optarg; break; case 'f': FileName = optarg; break; case 'r': Conf->retry = atoi(optarg); break; case 'c': tspFixConfig(); // The name of the error code below is confusing in this // case since we're not showing help. The desired behaviour // is the same, however: no error, but quit the application // without continuing. return NO_ERROR_SHOW_HELP; case '?': case 'h': PrintUsage(NULL); if ((optopt != '?') && (optopt != 'h') && (optopt != 0)) { return INVALID_ARGUMENTS; } else { return NO_ERROR_SHOW_HELP; } default: PrintUsage("Error while parsing command line arguments"); return INVALID_ARGUMENTS; } } return NO_ERROR; }
// -------------------------------------------------------------------------- void ParseArguments(sint32_t argc, char *argv[], tConf *Conf) { sint32_t ch; #if defined(WIN32) && !defined(WINCE) // Platform HACK! service_parse_cli(argc, argv); #endif while( (ch = pal_getopt(argc, argv, "h?b?n?y?f:r:i:u:s:")) != -1 ) { switch( ch ) { case 'b': Conf->boot_mode = TRUE; break; case 'n': Conf->nodaemon = TRUE; break; case 'y': Conf->no_questions = TRUE; break; case 's': Conf->client_v4 = optarg; break; case 'i': Conf->if_tunnel_v6v4 = optarg; break; case 'u': Conf->if_tunnel_v6udpv4 = optarg; break; case 'f': FileName = optarg; break; case 'r': Conf->retry_delay = atoi(optarg); break; case '?': case 'h': PrintUsage(NULL); exit(0); default: PrintUsage("Error while parsing command line arguments"); exit(1); } } }