aboutsummaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-12-09 06:11:36 +0000
committerEric Andersen <andersen@codepoet.org>1999-12-09 06:11:36 +0000
commit1792f8c48926450501e19d32e78e140bcb9661c6 (patch)
tree14d0304ebb774077e696a9c86117bf43d935d8bb /utility.c
parentc24db7b591870978fdd2cec8995728d1520c2fa9 (diff)
downloadbusybox-1792f8c48926450501e19d32e78e140bcb9661c6.tar.gz
Tail now works (costs 6k). Several other updates.
-Erik
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/utility.c b/utility.c
index 469275f2d..de7a0fbfc 100644
--- a/utility.c
+++ b/utility.c
@@ -289,7 +289,7 @@ const char *modeString(int mode)
#endif
-#ifdef BB_TAR
+#if defined BB_TAR
/*
* Return the standard ls-like time string from a time_t
* This is static and so is overwritten on each call.
@@ -340,8 +340,10 @@ int fullWrite(int fd, const char *buf, int len)
return total;
}
+#endif
+#if defined BB_TAR || defined BB_TAIL
/*
* Read all of the supplied buffer from a file.
* This does multiple reads as necessary.
@@ -1018,6 +1020,55 @@ extern void whine_if_fstab_is_missing()
#endif
+#if defined BB_DD || defined BB_TAIL
+/*
+ * Read a number with a possible multiplier.
+ * Returns -1 if the number format is illegal.
+ */
+extern long getNum (const char *cp)
+{
+ long value;
+
+ if (!isDecimal (*cp))
+ return -1;
+
+ value = 0;
+
+ while (isDecimal (*cp))
+ value = value * 10 + *cp++ - '0';
+
+ switch (*cp++) {
+ case 'm':
+ value *= 1048576;
+ break;
+
+ case 'k':
+ value *= 1024;
+ break;
+
+ case 'b':
+ value *= 512;
+ break;
+
+ case 'w':
+ value *= 2;
+ break;
+
+ case '\0':
+ return value;
+
+ default:
+ return -1;
+ }
+
+ if (*cp)
+ return -1;
+
+ return value;
+}
+#endif
+
+
/* END CODE */