* For each matching key, call the given handler function. */
| 171 | * For each matching key, call the given handler function. |
| 172 | */ |
| 173 | int |
| 174 | rte_kvargs_process(const struct rte_kvargs *kvlist, |
| 175 | const char *key_match, |
| 176 | arg_handler_t handler, |
| 177 | void *opaque_arg) |
| 178 | { |
| 179 | const struct rte_kvargs_pair *pair; |
| 180 | unsigned i; |
| 181 | |
| 182 | if (kvlist == NULL) |
| 183 | return 0; |
| 184 | |
| 185 | for (i = 0; i < kvlist->count; i++) { |
| 186 | pair = &kvlist->pairs[i]; |
| 187 | if (key_match == NULL || strcmp(pair->key, key_match) == 0) { |
| 188 | if ((*handler)(pair->key, pair->value, opaque_arg) < 0) |
| 189 | return -1; |
| 190 | } |
| 191 | } |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /* free the rte_kvargs structure */ |
| 196 | void |