From 8a0b1d0eff21fc8f0b6007107490d7064af5bacb Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 2 Jan 2020 18:50:26 +0100 Subject: Support parsing [device] block size argument with SI suffix Signed-off-by: David Oberhollenzer --- include/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/common.h') diff --git a/include/common.h b/include/common.h index 9938ba0..5f768c1 100644 --- a/include/common.h +++ b/include/common.h @@ -159,4 +159,12 @@ void print_version(const char *progname); */ sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg); +/* + Parse a number optionally followed by a KMG suffix (case insensitive). Prints + an error message to stderr and returns -1 on failure, 0 on success. + + The "what" string is used to prefix error messages (perror style). + */ +int parse_size(const char *what, size_t *out, const char *str); + #endif /* COMMON_H */ -- cgit v1.2.3