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

Function parse_cmd

libCacheSim/bin/distUtil/cli.c:129–192  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

127 * @param argv
128 */
129void parse_cmd(int argc, char *argv[], struct arguments *args) {
130 init_arg(args);
131
132 static struct argp argp = {.options = options,
133 .parser = parse_opt,
134 .args_doc = args_doc,
135 .doc = doc,
136 .children = NULL,
137 .help_filter = NULL,
138 .argp_domain = NULL};
139
140 argp_parse(&argp, argc, argv, 0, 0, args);
141
142 args->trace_path = args->args[0];
143 const char *trace_type_str = args->args[1];
144 const char *dist_type_str = args->args[2];
145 strncpy(args->output_type, args->args[3], 7);
146 strncpy(args->ofilepath, args->args[4], OFILEPATH_LEN - 1);
147 args->ofilepath[OFILEPATH_LEN - 1] = '\0';
148 assert(N_ARGS == 5);
149
150 if (args->ofilepath[0] == '\0') {
151 snprintf(args->ofilepath, OFILEPATH_LEN, "%s.dist",
152 rindex(args->trace_path, '/') + 1);
153 }
154
155 /* convert trace type string to enum */
156 // args->trace_type = trace_type_str_to_enum(trace_type_str,
157 // args->trace_path);
158
159 if (strcasecmp(dist_type_str, "stack_dist") == 0) {
160 args->dist_type = STACK_DIST;
161 } else if (strcasecmp(dist_type_str, "future_stack_dist") == 0) {
162 args->dist_type = FUTURE_STACK_DIST;
163 } else if (strcasecmp(dist_type_str, "dist_since_last_access") == 0) {
164 args->dist_type = DIST_SINCE_LAST_ACCESS;
165 } else if (strcasecmp(dist_type_str, "dist_since_first_access") == 0) {
166 args->dist_type = DIST_SINCE_FIRST_ACCESS;
167 } else {
168 ERROR("unsupported dist type %s\n", dist_type_str);
169 }
170
171 // reader_init_param_t reader_init_params;
172 // memset(&reader_init_params, 0, sizeof(reader_init_params));
173 // reader_init_params.ignore_obj_size = true;
174 // reader_init_params.ignore_size_zero_req = true;
175 // reader_init_params.obj_id_is_num = true;
176 // reader_init_params.cap_at_n_req = args->n_req;
177 // reader_init_params.sampler = NULL;
178
179 // parse_reader_params(args->trace_type_params, &reader_init_params);
180
181 // if ((args->trace_type == CSV_TRACE || args->trace_type == PLAIN_TXT_TRACE)
182 // &&
183 // reader_init_params.obj_size_field == -1) {
184 // reader_init_params.ignore_obj_size = true;
185 // }
186

Callers 1

mainFunction · 0.70

Calls 3

assertFunction · 0.85
create_readerFunction · 0.85
init_argFunction · 0.70

Tested by

no test coverage detected