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

Function parse_opt

libCacheSim/bin/traceUtils/cli_parser.cpp:94–164  ·  view source on GitHub ↗

PARSER. Field 2 in ARGP. Order of parameters: KEY, ARG, STATE. */

Source from the content-addressed store, hash-verified

92 Order of parameters: KEY, ARG, STATE.
93*/
94static error_t parse_opt(int key, char *arg, struct argp_state *state) {
95 struct arguments *arguments =
96 reinterpret_cast<struct arguments *>(state->input);
97
98 switch (key) {
99 case OPTION_TRACE_TYPE_PARAMS:
100 arguments->trace_type_params = arg;
101 break;
102 case OPTION_IGNORE_OBJ_SIZE:
103 arguments->ignore_obj_size = is_true(arg) ? true : false;
104 break;
105 case OPTION_OUTPUT_PATH:
106 strncpy(arguments->ofilepath, arg, OFILEPATH_LEN - 1);
107 arguments->ofilepath[OFILEPATH_LEN - 1] = '\0';
108 break;
109 case OPTION_SAMPLE_RATIO:
110 arguments->sample_ratio = atof(arg);
111 if (arguments->sample_ratio < 0 || arguments->sample_ratio > 1) {
112 ERROR("sample ratio should be in (0, 1]\n");
113 }
114 break;
115 case OPTION_REMOVE_SIZE_CHANGE:
116 arguments->remove_size_change = is_true(arg) ? true : false;
117 break;
118 case OPTION_OUTPUT_TXT:
119 arguments->output_txt = is_true(arg) ? true : false;
120 break;
121 case OPTION_OUTPUT_FORMAT:
122 arguments->output_format = arg;
123 break;
124 case OPTION_NUM_REQ:
125 arguments->n_req = atoll(arg);
126 break;
127 case OPTION_PRINT_STAT:
128 arguments->print_stat = is_true(arg) ? true : false;
129 break;
130 case OPTION_FIELD_DELIMITER:
131 arguments->delimiter = arg[0];
132 break;
133 case OPTION_OBJ_ID_ONLY:
134 arguments->print_obj_id_only = atol(arg);
135 break;
136 case OPTION_OBJ_ID_32bit:
137 arguments->print_obj_id_32bit = atol(arg);
138 break;
139 case OPTION_FILTER_TYPE:
140 arguments->cache_name = arg;
141 break;
142 case OPTION_FILTER_SIZE:
143 arguments->cache_size = atof(arg);
144 break;
145 case ARGP_KEY_ARG:
146 if (state->arg_num >= N_ARGS) {
147 printf("found too many arguments, current %s\n", arg);
148 argp_usage(state);
149 exit(1);
150 }
151 arguments->args[state->arg_num] = arg;

Callers

nothing calls this directly

Calls 2

is_trueFunction · 0.85
atofFunction · 0.85

Tested by

no test coverage detected