Exemplo n.º 1
0
static void reload_parsed_opts(void)
{
	if (curopts.path_prefix) {
		set_path_prefix(curopts.path_prefix);
	}

	if (curopts.version_url) {
		set_version_url(curopts.version_url);
	}

	if (curopts.content_url) {
		set_content_url(curopts.content_url);
	}

	if (curopts.format_string) {
		set_format_string(curopts.format_string);
	}

	if (curopts.state_dir) {
		set_state_dir(curopts.state_dir);
	}

	if (curopts.cert_path) {
		set_cert_path(curopts.cert_path);
	}

	force = curopts.force;
	sigcheck = curopts.sigcheck;
}
Exemplo n.º 2
0
static bool parse_options(int argc, char **argv)
{
	int opt;

	while ((opt = getopt_long(argc, argv, "hnIp:u:c:v:P:F:S:C:", prog_opts, NULL)) != -1) {
		switch (opt) {
		case '?':
		case 'h':
			print_help(argv[0]);
			exit(EXIT_SUCCESS);
		case 'p': /* default empty path_prefix removes on the running OS */
			if (!optarg || !set_path_prefix(optarg)) {
				fprintf(stderr, "Invalid --path argument\n\n");
				goto err;
			}
			break;
		case 'u':
			if (!optarg) {
				fprintf(stderr, "error: invalid --url argument\n\n");
				goto err;
			}
			set_version_url(optarg);
			set_content_url(optarg);
			break;
		case 'c':
			if (!optarg) {
				fprintf(stderr, "Invalid --contenturl argument\n\n");
				goto err;
			}
			set_content_url(optarg);
			break;
		case 'v':
			if (!optarg) {
				fprintf(stderr, "Invalid --versionurl argument\n\n");
				goto err;
			}
			set_version_url(optarg);
			break;
		case 'P':
			if (sscanf(optarg, "%ld", &update_server_port) != 1) {
				fprintf(stderr, "Invalid --port argument\n\n");
				goto err;
			}
			break;
		case 'F':
			if (!optarg || !set_format_string(optarg)) {
				fprintf(stderr, "Invalid --format argument\n\n");
				goto err;
			}
			break;
		case 'S':
			if (!optarg || !set_state_dir(optarg)) {
				fprintf(stderr, "Invalid --statedir argument\n\n");
				goto err;
			}
			break;
		case 'n':
			sigcheck = false;
			break;
		case 'I':
			timecheck = false;
			break;
		case 'C':
			if (!optarg) {
				fprintf(stderr, "Invalid --certpath argument\n\n");
				goto err;
			}
			set_cert_path(optarg);
			break;
		default:
			fprintf(stderr, "error: unrecognized option\n\n");
			goto err;
		}
	}

	if (argc <= optind) {
		fprintf(stderr, "error: missing bundle(s) to be removed\n\n");
		goto err;
	}

	bundles = argv + optind;

	return true;
err:
	print_help(argv[0]);
	return false;
}
Exemplo n.º 3
0
static bool parse_options(int argc, char **argv)
{
	int opt;
	int err;

	while ((opt = getopt_long(argc, argv, "hu:c:v:P:p:F:s:t:mlbinIdS:C:", prog_opts, NULL)) != -1) {
		switch (opt) {
		case '?':
		case 'h':
			print_help(argv[0]);
			exit(0);
		case 'u':
			if (!optarg) {
				fprintf(stderr, "error: invalid --url argument\n\n");
				goto err;
			}
			set_version_url(optarg);
			set_content_url(optarg);
			break;
		case 'c':
			if (!optarg) {
				fprintf(stderr, "Invalid --contenturl argument\n\n");
				goto err;
			}
			set_content_url(optarg);
			break;
		case 'v':
			if (!optarg) {
				fprintf(stderr, "Invalid --versionurl argument\n\n");
				goto err;
			}
			set_version_url(optarg);
			break;
		case 'P':
			if (sscanf(optarg, "%ld", &update_server_port) != 1) {
				fprintf(stderr, "Invalid --port argument\n\n");
				goto err;
			}
			break;
		case 'p': /* default empty path_prefix verifies the running OS */
			if (!optarg || !set_path_prefix(optarg)) {
				fprintf(stderr, "Invalid --path argument\n\n");
				goto err;
			}
			break;
		case 's':
			if (!optarg || (strcmp(optarg, "b") && (strcmp(optarg, "o")))) {
				fprintf(stderr, "Invalid --scope argument. Must be 'b' or 'o'\n\n");
				goto err;
			}

			if (!strcmp(optarg, "b")) {
				scope = 'b';
			} else if (!strcmp(optarg, "o")) {
				scope = 'o';
			}

			break;
		case 't':
			err = strtoi_err(optarg, NULL, &num_results);
			if (err != 0) {
				fprintf(stderr, "Invalid --top argument\n\n");
				goto err;
			}
			break;
		case 'm':
			csv_format = true;
			break;
		case 'F':
			if (!optarg || !set_format_string(optarg)) {
				fprintf(stderr, "Invalid --format argument\n\n");
				goto err;
			}
			break;
		case 'S':
			if (!optarg || !set_state_dir(optarg)) {
				fprintf(stderr, "Invalid --statedir argument\n\n");
				goto err;
			}
			break;
		case 'l':
			if (search_type != '0') {
				fprintf(stderr, "Error, cannot specify multiple search types "
						"(-l and -b are mutually exclusive)\n");
				goto err;
			}

			search_type = 'l';
			break;
		case 'i':
			init = true;
			break;
		case 'n':
			sigcheck = false;
			break;
		case 'I':
			timecheck = false;
			break;
		case 'b':
			if (search_type != '0') {
				fprintf(stderr, "Error, cannot specify multiple search types "
						"(-l and -b are mutually exclusive)\n");
				goto err;
			}

			search_type = 'b';
			break;
		case 'd':
			display_files = true;
			break;
		case 'C':
			if (!optarg) {
				fprintf(stderr, "Invalid --certpath argument\n\n");
				goto err;
			}
			set_cert_path(optarg);
			break;
		default:
			fprintf(stderr, "Error: unrecognized option: -'%c',\n\n", opt);
			goto err;
		}
	}

	if ((optind == argc) && (!init) && (!display_files)) {
		fprintf(stderr, "Error: Search term missing\n\n");
		print_help(argv[0]);
		return false;
	}

	if ((optind == argc - 1) && (display_files)) {
		fprintf(stderr, "Error: Cannot supply a search term and -d, --display-files together\n");
		return false;
	}

	search_string = argv[optind];

	if (optind + 1 < argc) {
		fprintf(stderr, "Error, only 1 search term supported at a time\n");
		return false;
	}

	return true;

err:
	print_help(argv[0]);
	return false;
}
Exemplo n.º 4
0
static bool parse_options(int argc, char **argv)
{
	int opt;

	while ((opt = getopt_long(argc, argv, "hxnm:p:u:P:c:v:fiF:qS:C:", prog_opts, NULL)) != -1) {
		switch (opt) {
		case '?':
		case 'h':
			print_help(argv[0]);
			exit(EXIT_SUCCESS);
		case 'm':
			if (strcmp("latest", optarg) == 0) {
				version = -1;
			} else if (sscanf(optarg, "%i", &version) != 1) {
				printf("Invalid --manifest argument\n\n");
				goto err;
			}
			break;
		case 'p': /* default empty path_prefix verifies the running OS */
			if (!optarg || !set_path_prefix(optarg)) {
				printf("Invalid --path argument\n\n");
				goto err;
			}
			break;
		case 'u':
			if (!optarg) {
				printf("Invalid --url argument\n\n");
				goto err;
			}
			set_version_url(optarg);
			set_content_url(optarg);
			break;
		case 'P':
			if (sscanf(optarg, "%ld", &update_server_port) != 1) {
				printf("Invalid --port argument\n\n");
				goto err;
			}
			break;
		case 'c':
			if (!optarg) {
				printf("Invalid --contenturl argument\n\n");
				goto err;
			}
			set_content_url(optarg);
			break;
		case 'v':
			if (!optarg) {
				printf("Invalid --versionurl argument\n\n");
				goto err;
			}
			set_version_url(optarg);
			break;
		case 'f':
			cmdline_option_fix = true;
			break;
		case 'i':
			cmdline_option_install = true;
			cmdline_option_quick = true;
			break;
		case 'F':
			if (!optarg || !set_format_string(optarg)) {
				printf("Invalid --format argument\n\n");
				goto err;
			}
			break;
		case 'S':
			if (!optarg || !set_state_dir(optarg)) {
				printf("Invalid --statedir argument\n\n");
				goto err;
			}
			break;
		case 'q':
			cmdline_option_quick = true;
			break;
		case 'x':
			force = true;
			break;
		case 'n':
			sigcheck = false;
			break;
		case 'C':
			if (!optarg) {
				printf("Invalid --certpath argument\n\n");
				goto err;
			}
			set_cert_path(optarg);
			break;
		default:
			printf("Unrecognized option\n\n");
			goto err;
		}
	}

	if (cmdline_option_install) {
		if (version == 0) {
			printf("--install option requires -m version option\n");
			return false;
		}
		if (path_prefix == NULL) {
			printf("--install option requires --path option\n");
			return false;
		}
		if (cmdline_option_fix) {
			printf("--install and --fix options are mutually exclusive\n");
			return false;
		}
	} else if (version == -1) {
		printf("-m latest only supported with --install\n");
		return false;
	}

	return true;
err:
	print_help(argv[0]);
	return false;
}