bool CArgParser::parseServerArgs(CServerArgs& args, int argc, const char* const* argv) { setArgsBase(args); updateCommonArgs(argv); for (int i = 1; i < argc; ++i) { if (parsePlatformArg(args, argc, argv, i)) { continue; } else if (parseGenericArgs(argc, argv, i)) { continue; } else if (isArg(i, argc, argv, "-a", "--address", 1)) { // save listen address args.m_synergyAddress = argv[++i]; } else if (isArg(i, argc, argv, "-c", "--config", 1)) { // save configuration file path args.m_configFile = argv[++i]; } else { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; } } if (checkUnexpectedArgs()) { return false; } return true; }
int parseArguments(char *cmdLine, vmArg args[]) { /* argv[0] = executable name */ vmOptions[numOptionsVM++] = cmdLine; cmdLine = parseStringArg(cmdLine, &(vmOptions[numOptionsVM-1])); if(!cmdLine) return 0; /* parse VM options */ cmdLine = parseVMArgs(cmdLine, args); if(cmdLine == NULL) return 0; /* parse image and generic args */ cmdLine = parseGenericArgs(cmdLine); return cmdLine != NULL; }
bool ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv) { setArgsBase(args); updateCommonArgs(argv); int i; for (i = 1; i < argc; ++i) { if (parsePlatformArg(args, argc, argv, i)) { continue; } else if (parseGenericArgs(argc, argv, i)) { continue; } else if (parseDeprecatedArgs(argc, argv, i)) { continue; } else if (isArg(i, argc, argv, NULL, "--camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--no-camp")) { // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--yscroll", 1)) { // define scroll args.m_yscroll = atoi(argv[++i]); } else { if (i + 1 == argc) { args.m_synergyAddress = argv[i]; return true; } LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; } } // exactly one non-option argument (server-address) if (i == argc) { LOG((CLOG_PRINT "%s: a server address or name is required" BYE, args.m_pname, args.m_pname)); return false; } if (checkUnexpectedArgs()) { return false; } return true; }