X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Funformat.c;h=3c671137941ed47cdcd79d70ab5e4ecc4ff916bd;hb=c025329bb244952938c8575a1d5602a1e54e5fe7;hp=52b8bb779bb6cd460df1f3b960f6b8c929a02c48;hpb=052bda38c34fa73f8d0ad86615b777a0dd7f34d0;p=vpp.git diff --git a/src/vppinfra/unformat.c b/src/vppinfra/unformat.c index 52b8bb779bb..3c671137941 100644 --- a/src/vppinfra/unformat.c +++ b/src/vppinfra/unformat.c @@ -1077,6 +1077,30 @@ unformat_init_unix_env (unformat_input_t * input, char *var) return val != 0; } +uword +unformat_data_size (unformat_input_t * input, va_list * args) +{ + u64 _a; + u64 *a = va_arg (*args, u64 *); + if (unformat (input, "%lluGb", &_a)) + *a = _a << 30; + else if (unformat (input, "%lluG", &_a)) + *a = _a << 30; + else if (unformat (input, "%lluMb", &_a)) + *a = _a << 20; + else if (unformat (input, "%lluM", &_a)) + *a = _a << 20; + else if (unformat (input, "%lluKb", &_a)) + *a = _a << 10; + else if (unformat (input, "%lluK", &_a)) + *a = _a << 10; + else if (unformat (input, "%llu", a)) + ; + else + return 0; + return 1; +} + #endif /* CLIB_UNIX */