* @brief parse the command line arguments * * @param argc * @param argv */
| 118 | * @param argv |
| 119 | */ |
| 120 | void parse_cmd(int argc, char *argv[], struct arguments *args) { |
| 121 | init_arg(args); |
| 122 | |
| 123 | static struct argp argp = {.options = options, |
| 124 | .parser = parse_opt, |
| 125 | .args_doc = args_doc, |
| 126 | .doc = doc, |
| 127 | .children = NULL, |
| 128 | .help_filter = NULL, |
| 129 | .argp_domain = NULL}; |
| 130 | |
| 131 | argp_parse(&argp, argc, argv, 0, 0, args); |
| 132 | |
| 133 | args->trace_path = args->args[0]; |
| 134 | const char *trace_type_str = args->args[1]; |
| 135 | const char *task = args->args[2]; |
| 136 | strncpy(args->task, task, TASK_STR_LEN - 1); |
| 137 | args->task[TASK_STR_LEN - 1] = '\0'; |
| 138 | |
| 139 | /* convert trace type string to enum */ |
| 140 | args->trace_type = trace_type_str_to_enum(trace_type_str, args->trace_path); |
| 141 | |
| 142 | reader_init_param_t reader_init_params; |
| 143 | memset(&reader_init_params, 0, sizeof(reader_init_params)); |
| 144 | reader_init_params.ignore_size_zero_req = true; |
| 145 | reader_init_params.obj_id_is_num = true; |
| 146 | reader_init_params.cap_at_n_req = args->n_req; |
| 147 | reader_init_params.sampler = NULL; |
| 148 | |
| 149 | parse_reader_params(args->trace_type_params, &reader_init_params); |
| 150 | |
| 151 | if ((args->trace_type == CSV_TRACE || args->trace_type == PLAIN_TXT_TRACE) && |
| 152 | reader_init_params.obj_size_field == -1) { |
| 153 | reader_init_params.ignore_obj_size = true; |
| 154 | } |
| 155 | |
| 156 | args->reader = |
| 157 | setup_reader(args->trace_path, args->trace_type, &reader_init_params); |
| 158 | } |
| 159 | |
| 160 | void free_arg(struct arguments *args) { close_reader(args->reader); } |
| 161 |
no test coverage detected