static void get_options(int argc, char **argv, const char *progname) { signed char c; char tmp[512]; char *catalog_host = NULL; int catalog_port = 0; while((c = getopt(argc, argv, "p:P:n:d:F:N:C:s:r:R:k:w:c:o:uxvhaZ:")) > -1) { switch (c) { case 'p': port = atoi(optarg); break; case 'r': repeat_filename = optarg; break; case 'R': retry_max = atoi(optarg); break; case 's': rectangle_size = atoi(optarg); break; case 'k': kmer_size = atoi(optarg); break; case 'w': window_size = atoi(optarg); break; case 'c': checkpoint_filename = optarg; break; case 'd': debug_flags_set(optarg); break; case 'F': wq_option_fast_abort_multiplier = atof(optarg); break; case 'a': work_queue_master_mode = WORK_QUEUE_MASTER_MODE_CATALOG; break; case 'N': free(project); project = xxstrdup(optarg); break; case 'P': priority = atoi(optarg); break; case 'C': if(!parse_catalog_server_description(optarg, &catalog_host, &catalog_port)) { fprintf(stderr, "sand_filter: catalog server should be given as HOSTNAME:PORT'.\n"); exit(1); } setenv("CATALOG_HOST", catalog_host, 1); char *value = string_format("%d", catalog_port); setenv("CATALOG_PORT", value, 1); free(value); work_queue_master_mode = WORK_QUEUE_MASTER_MODE_CATALOG; break; case 'u': do_not_unlink = 1; break; case 'Z': port_file = optarg; port = 0; break; case 'o': debug_config_file(optarg); break; case 'v': cctools_version_print(stdout, progname); exit(0); default: case 'h': show_help(progname); exit(0); } } cctools_version_debug(D_DEBUG, argv[0]); if(argc - optind != 2) { show_help(progname); exit(1); } sequence_filename = argv[optind++]; outfilename = argv[optind++]; outdirname = malloc(strlen(outfilename) + 15); sprintf(outdirname, "%s.filter.tmp", outfilename); if(mkdir(outdirname, S_IRWXU) != 0) { if(errno == EEXIST) { fprintf(stderr, "%s: directory %s already exists, you may want to delete or rename before running.\n", progname, outdirname); } else { fprintf(stderr, "%s: couldn't create %s: %s\n", progname, outdirname, strerror(errno)); exit(1); } } sprintf(filter_program_args, "-k %d -w %d -s d", kmer_size, window_size); if(repeat_filename) { sprintf(tmp, " -r %s", string_basename(repeat_filename)); strcat(filter_program_args, tmp); } }
static void work_queue_status_parse_command_line_arguments(int argc, char *argv[]) { signed int c; static struct option long_options[] = { {"statistics", no_argument, 0, 'Q'}, {"workers", no_argument, 0, 'W'}, {"tasks", no_argument, 0, 'T'}, {"verbose", no_argument, 0, 'l'}, {"resources", no_argument, 0, 'R'}, {"catalog", required_argument, 0, 'C'}, {"debug", required_argument, 0, 'd'}, {"timeout", required_argument, 0, 't'}, {"help", no_argument, 0, 'h'}, {0,0,0,0}}; while((c = getopt_long(argc, argv, "QTWC:d:lo:O:Rt:vh", long_options, NULL)) > -1) { switch (c) { case 'C': if(!parse_catalog_server_description(optarg, &catalog_host, &catalog_port)) { fprintf(stderr, "Cannot parse catalog description: %s. \n", optarg); exit(EXIT_FAILURE); } break; case 'd': debug_flags_set(optarg); break; case 'Q': query_mode = QUERY_QUEUE; break; case 'T': query_mode = QUERY_TASKS; break; case 'W': query_mode = QUERY_WORKERS; break; case 'l': format_mode = FORMAT_LONG; break; case 'o': debug_config_file(optarg); break; case 'O': debug_config_file_size(string_metric_parse(optarg)); break; case 't': work_queue_status_timeout = strtol(optarg, NULL, 10); break; case 'h': show_help(argv[0]); exit(EXIT_SUCCESS); break; case 'R': query_mode = QUERY_MASTER_RESOURCES; resource_mode = 1; break; case 'v': cctools_version_print(stdout, argv[0]); exit(EXIT_SUCCESS); default: show_help(argv[0]); exit(EXIT_FAILURE); break; } } }