diff options
Diffstat (limited to 'cgpt/cgpt_common.c')
-rw-r--r-- | cgpt/cgpt_common.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index 29fe524a..29906d40 100644 --- a/cgpt/cgpt_common.c +++ b/cgpt/cgpt_common.c @@ -51,6 +51,22 @@ void Warning(const char *format, ...) { va_end(ap); } +int check_int_parse(char option, const char *buf) { + if (!*optarg || (buf && *buf)) { + Error("invalid argument to -%c: \"%s\"\n", option, optarg); + return 1; + } + return 0; +} + +int check_int_limit(char option, int val, int low, int high) { + if (val < low || val > high) { + Error("value for -%c must be between %d and %d", option, low, high); + return 1; + } + return 0; +} + int CheckValid(const struct drive *drive) { if ((drive->gpt.valid_headers != MASK_BOTH) || (drive->gpt.valid_entries != MASK_BOTH)) { |