| 78 | } |
| 79 | |
| 80 | int |
| 81 | parser_read_uint64(uint64_t *value, const char *p) |
| 82 | { |
| 83 | char *next; |
| 84 | uint64_t val; |
| 85 | |
| 86 | p = skip_white_spaces(p); |
| 87 | if (!isdigit(*p)) |
| 88 | return -EINVAL; |
| 89 | |
| 90 | val = strtoul(p, &next, 10); |
| 91 | if (p == next) |
| 92 | return -EINVAL; |
| 93 | |
| 94 | p = next; |
| 95 | switch (*p) { |
| 96 | case 'T': |
| 97 | val *= 1024ULL; |
| 98 | /* fall through */ |
| 99 | case 'G': |
| 100 | val *= 1024ULL; |
| 101 | /* fall through */ |
| 102 | case 'M': |
| 103 | val *= 1024ULL; |
| 104 | /* fall through */ |
| 105 | case 'k': |
| 106 | case 'K': |
| 107 | val *= 1024ULL; |
| 108 | p++; |
| 109 | break; |
| 110 | } |
| 111 | |
| 112 | p = skip_white_spaces(p); |
| 113 | if (*p != '\0') |
| 114 | return -EINVAL; |
| 115 | |
| 116 | *value = val; |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | int |
| 121 | parser_read_uint64_hex(uint64_t *value, const char *p) |
no test coverage detected