diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-12-09 06:11:36 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-12-09 06:11:36 +0000 |
commit | 1792f8c48926450501e19d32e78e140bcb9661c6 (patch) | |
tree | 14d0304ebb774077e696a9c86117bf43d935d8bb /dd.c | |
parent | c24db7b591870978fdd2cec8995728d1520c2fa9 (diff) | |
download | busybox-w32-1792f8c48926450501e19d32e78e140bcb9661c6.tar.gz busybox-w32-1792f8c48926450501e19d32e78e140bcb9661c6.tar.bz2 busybox-w32-1792f8c48926450501e19d32e78e140bcb9661c6.zip |
Tail now works (costs 6k). Several other updates.
-Erik
Diffstat (limited to 'dd.c')
-rw-r--r-- | dd.c | 46 |
1 files changed, 1 insertions, 45 deletions
@@ -48,54 +48,10 @@ static const char dd_usage[] = | |||
48 | "\tcount=n\tcopy only n input blocks\n" | 48 | "\tcount=n\tcopy only n input blocks\n" |
49 | //"\tskip=n\tskip n input blocks\n" | 49 | //"\tskip=n\tskip n input blocks\n" |
50 | "\n" | 50 | "\n" |
51 | "BYTES may be suffixed: by k for x1024, b for x512, and w for x2.\n"; | 51 | "BYTES may be suffixed by w (x2), k (x1024), b (x512), or m (x1024^2).\n"; |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | |||
56 | /* | ||
57 | * Read a number with a possible multiplier. | ||
58 | * Returns -1 if the number format is illegal. | ||
59 | */ | ||
60 | static long getNum (const char *cp) | ||
61 | { | ||
62 | long value; | ||
63 | |||
64 | if (!isDecimal (*cp)) | ||
65 | return -1; | ||
66 | |||
67 | value = 0; | ||
68 | |||
69 | while (isDecimal (*cp)) | ||
70 | value = value * 10 + *cp++ - '0'; | ||
71 | |||
72 | switch (*cp++) { | ||
73 | case 'k': | ||
74 | value *= 1024; | ||
75 | break; | ||
76 | |||
77 | case 'b': | ||
78 | value *= 512; | ||
79 | break; | ||
80 | |||
81 | case 'w': | ||
82 | value *= 2; | ||
83 | break; | ||
84 | |||
85 | case '\0': | ||
86 | return value; | ||
87 | |||
88 | default: | ||
89 | return -1; | ||
90 | } | ||
91 | |||
92 | if (*cp) | ||
93 | return -1; | ||
94 | |||
95 | return value; | ||
96 | } | ||
97 | |||
98 | |||
99 | extern int dd_main (int argc, char **argv) | 55 | extern int dd_main (int argc, char **argv) |
100 | { | 56 | { |
101 | const char *inFile = NULL; | 57 | const char *inFile = NULL; |