Beispiel #1
0
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;
}
Beispiel #2
0
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;
}