libarchive: treat one "FIXME: avoid seek"
[oweals/busybox.git] / libbb / xatonum.c
index dec3c2dc4aa5ce85373942baf2b000ad7b9f0c7c..7639a62aa6b114105fa6a290838f7cc215fc1eec 100644 (file)
@@ -4,9 +4,8 @@
  *
  * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
  *
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
  */
-
 #include "libbb.h"
 
 #define type long long
@@ -34,7 +33,7 @@
 #endif
 
 #if UINT_MAX != ULONG_MAX
-static ATTRIBUTE_ALWAYS_INLINE
+static ALWAYS_INLINE
 unsigned bb_strtoui(const char *str, char **end, int b)
 {
        unsigned long v = strtoul(str, end, b);
@@ -59,12 +58,59 @@ unsigned bb_strtoui(const char *str, char **end, int b)
 
 /* A few special cases */
 
-int xatoi_u(const char *numstr)
+int FAST_FUNC xatoi_positive(const char *numstr)
 {
        return xatou_range(numstr, 0, INT_MAX);
 }
 
-uint16_t xatou16(const char *numstr)
+uint16_t FAST_FUNC xatou16(const char *numstr)
 {
        return xatou_range(numstr, 0, 0xffff);
 }
+
+const struct suffix_mult bkm_suffixes[] = {
+       { "b", 512 },
+       { "k", 1024 },
+       { "m", 1024*1024 },
+       { "", 0 }
+};
+
+const struct suffix_mult cwbkMG_suffixes[] = {
+       { "c", 1 },
+       { "w", 2 },
+       { "b", 512 },
+       { "kB", 1000 },
+       { "kD", 1000 },
+       { "k", 1024 },
+       { "KB", 1000 }, /* compat with coreutils dd */
+       { "KD", 1000 }, /* compat with coreutils dd */
+       { "K", 1024 },  /* compat with coreutils dd */
+       { "MB", 1000000 },
+       { "MD", 1000000 },
+       { "M", 1024*1024 },
+       { "GB", 1000000000 },
+       { "GD", 1000000000 },
+       { "G", 1024*1024*1024 },
+       /* "D" suffix for decimal is not in coreutils manpage, looks like it's deprecated */
+       /* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */
+       { "", 0 }
+};
+
+const struct suffix_mult kmg_i_suffixes[] = {
+       { "KiB", 1024 },
+       { "kiB", 1024 },
+       { "K", 1024 },
+       { "k", 1024 },
+       { "MiB", 1048576 },
+       { "miB", 1048576 },
+       { "M", 1048576 },
+       { "m", 1048576 },
+       { "GiB", 1073741824 },
+       { "giB", 1073741824 },
+       { "G", 1073741824 },
+       { "g", 1073741824 },
+       { "KB", 1000 },
+       { "MB", 1000000 },
+       { "GB", 1000000000 },
+       { "", 0 }
+};