MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / parse_cmd

Function parse_cmd

libCacheSim/bin/customized/SOSP23/oneHit/cli_parser.c:121–159  ·  view source on GitHub ↗

* @brief parse the command line arguments * * @param argc * @param argv */

Source from the content-addressed store, hash-verified

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

Callers 2

mainFunction · 0.70
mainFunction · 0.50

Calls 4

trace_type_str_to_enumFunction · 0.85
parse_reader_paramsFunction · 0.85
setup_readerFunction · 0.85
init_argFunction · 0.70

Tested by

no test coverage detected