Mercurial > hg > toybox
annotate toys/count.c @ 226:6aac63925eff
Update web pages.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 05 Jan 2008 18:09:49 -0600 |
parents | 30a6db5a95c2 |
children | d4176f3f3835 |
rev | line source |
---|---|
86
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 /* vi: set sw=4 ts=4: */ |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 /* |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 * count.c - Progress indicator from stdin to stdout |
194
30a6db5a95c2
Add comments about SUSv3 specs (or lack thereof).
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
4 * |
30a6db5a95c2
Add comments about SUSv3 specs (or lack thereof).
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
5 * Not in SUSv3. |
86
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 */ |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 #include "toys.h" |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 |
186
25447caf1b4b
Change command main() functions to return void, and exit(toys.exitval) from
Rob Landley <rob@landley.net>
parents:
86
diff
changeset
|
10 void count_main(void) |
86
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 { |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 uint64_t size = 0; |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 int len; |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 for (;;) { |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 len = xread(0, toybuf, sizeof(toybuf)); |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 if (!len) break; |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 size += len; |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 xwrite(1, toybuf, sizeof(toybuf)); |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 fdprintf(2, "%"PRIu64" bytes\r", size); |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 } |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 fdprintf(2,"\n"); |
d2e38cb0b1cd
I forgot to add count.c a while ago. (Memo to self: grab snapshots and build
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 } |