aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-12-18 21:38:57 +0000
committerMatt Kraai <kraai@debian.org>2000-12-18 21:38:57 +0000
commit24ac0179617e43ab517141fe5497f4ebac108678 (patch)
tree333d1ef43d092edd4b41030112cb71559bf9cb3a /coreutils/tail.c
parent0d2acb0eadf2d6ae9d60fa3fe9f897e254eaadda (diff)
downloadbusybox-w32-24ac0179617e43ab517141fe5497f4ebac108678.tar.gz
busybox-w32-24ac0179617e43ab517141fe5497f4ebac108678.tar.bz2
busybox-w32-24ac0179617e43ab517141fe5497f4ebac108678.zip
Rewrote dd.
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c48
1 files changed, 14 insertions, 34 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 308bb3085..5f0381882 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -61,6 +61,13 @@ static char verbose = 0;
61 61
62static off_t units=0; 62static off_t units=0;
63 63
64static struct suffix_mult tail_suffixes[] = {
65 { "b", 512 },
66 { "k", 1024 },
67 { "m", 1048576 },
68 { NULL, 0 }
69};
70
64static int tail_stream(int fd) 71static int tail_stream(int fd)
65{ 72{
66 ssize_t startpoint; 73 ssize_t startpoint;
@@ -170,32 +177,6 @@ int tail_main(int argc, char **argv)
170 177
171 switch (opt) { 178 switch (opt) {
172#ifndef BB_FEATURE_SIMPLE_TAIL 179#ifndef BB_FEATURE_SIMPLE_TAIL
173 case 'c':
174 unit_type = BYTES;
175 test = atoi(optarg);
176 if(test==0)
177 usage(tail_usage);
178 if(optarg[strlen(optarg)-1]>'9') {
179 switch (optarg[strlen(optarg)-1]) {
180 case 'b':
181 test *= 512;
182 break;
183 case 'k':
184 test *= 1024;
185 break;
186 case 'm':
187 test *= (1024 * 1024);
188 break;
189 default:
190 fprintf(stderr,"Size must be b,k, or m.");
191 usage(tail_usage);
192 }
193 }
194 if(optarg[0]=='+')
195 units=test+1;
196 else
197 units=-(test+1);
198 break;
199 case 'q': 180 case 'q':
200 show_headers = 0; 181 show_headers = 0;
201 break; 182 break;
@@ -207,15 +188,12 @@ int tail_main(int argc, char **argv)
207 case 'v': 188 case 'v':
208 verbose = 1; 189 verbose = 1;
209 break; 190 break;
191 case 'c':
192 unit_type = BYTES;
193 /* FALLS THROUGH */
210#endif 194#endif
211 case 'f':
212 follow = 1;
213 break;
214 case 'h':
215 usage(tail_usage);
216 break;
217 case 'n': 195 case 'n':
218 test = atoi(optarg); 196 test = parse_number(optarg, tail_suffixes);
219 if (test) { 197 if (test) {
220 if (optarg[0] == '+') 198 if (optarg[0] == '+')
221 units = test; 199 units = test;
@@ -224,8 +202,10 @@ int tail_main(int argc, char **argv)
224 } else 202 } else
225 usage(tail_usage); 203 usage(tail_usage);
226 break; 204 break;
205 case 'f':
206 follow = 1;
207 break;
227 default: 208 default:
228 error_msg("\nUnknown arg: %c.\n\n",optopt);
229 usage(tail_usage); 209 usage(tail_usage);
230 } 210 }
231 } 211 }