| 22 | } |
| 23 | |
| 24 | static unsigned int parse_flags(const char *str, struct flag_definition *defs) |
| 25 | { |
| 26 | struct string_list masks = STRING_LIST_INIT_DUP; |
| 27 | unsigned int result = 0; |
| 28 | |
| 29 | if (!strcmp(str, "0")) |
| 30 | return 0; |
| 31 | |
| 32 | string_list_split(&masks, str, ",", 64); |
| 33 | for (size_t i = 0; i < masks.nr; i++) { |
| 34 | const char *name = masks.items[i].string; |
| 35 | struct flag_definition *def = defs; |
| 36 | int found = 0; |
| 37 | while (def->name) { |
| 38 | if (!strcmp(def->name, name)) { |
| 39 | result |= def->mask; |
| 40 | found = 1; |
| 41 | break; |
| 42 | } |
| 43 | def++; |
| 44 | } |
| 45 | if (!found) |
| 46 | die("unknown flag \"%s\"", name); |
| 47 | } |
| 48 | |
| 49 | string_list_clear(&masks, 0); |
| 50 | return result; |
| 51 | } |
| 52 | |
| 53 | static struct flag_definition empty_flags[] = { { NULL, 0 } }; |
| 54 |
no test coverage detected