aboutsummaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
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)
289#endif 289#endif
290 290
291 291
292#ifdef BB_TAR 292#if defined BB_TAR
293/* 293/*
294 * Return the standard ls-like time string from a time_t 294 * Return the standard ls-like time string from a time_t
295 * This is static and so is overwritten on each call. 295 * This is static and so is overwritten on each call.
@@ -340,8 +340,10 @@ int fullWrite(int fd, const char *buf, int len)
340 340
341 return total; 341 return total;
342} 342}
343#endif
343 344
344 345
346#if defined BB_TAR || defined BB_TAIL
345/* 347/*
346 * Read all of the supplied buffer from a file. 348 * Read all of the supplied buffer from a file.
347 * This does multiple reads as necessary. 349 * This does multiple reads as necessary.
@@ -1018,6 +1020,55 @@ extern void whine_if_fstab_is_missing()
1018#endif 1020#endif
1019 1021
1020 1022
1023#if defined BB_DD || defined BB_TAIL
1024/*
1025 * Read a number with a possible multiplier.
1026 * Returns -1 if the number format is illegal.
1027 */
1028extern long getNum (const char *cp)
1029{
1030 long value;
1031
1032 if (!isDecimal (*cp))
1033 return -1;
1034
1035 value = 0;
1036
1037 while (isDecimal (*cp))
1038 value = value * 10 + *cp++ - '0';
1039
1040 switch (*cp++) {
1041 case 'm':
1042 value *= 1048576;
1043 break;
1044
1045 case 'k':
1046 value *= 1024;
1047 break;
1048
1049 case 'b':
1050 value *= 512;
1051 break;
1052
1053 case 'w':
1054 value *= 2;
1055 break;
1056
1057 case '\0':
1058 return value;
1059
1060 default:
1061 return -1;
1062 }
1063
1064 if (*cp)
1065 return -1;
1066
1067 return value;
1068}
1069#endif
1070
1071
1021/* END CODE */ 1072/* END CODE */
1022 1073
1023 1074