Last change
on this file since 953 was 821, checked in by Bruno Cornec, 18 years ago |
Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)
|
File size:
901 bytes
|
Rev | Line | |
---|
[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
| 3 | * Monitor a pipe with a simple progress display.
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 2003 by Rob Landley <rob@landley.net>, Joey Hess
|
---|
| 6 | *
|
---|
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #include "busybox.h"
|
---|
| 11 | #include <stdio.h>
|
---|
| 12 | #include <stdlib.h>
|
---|
| 13 | #include <unistd.h>
|
---|
| 14 | #include <time.h>
|
---|
| 15 |
|
---|
| 16 | #define PIPE_PROGRESS_SIZE 4096
|
---|
| 17 |
|
---|
| 18 | /* Read a block of data from stdin, write it to stdout.
|
---|
| 19 | * Activity is indicated by a '.' to stderr
|
---|
| 20 | */
|
---|
| 21 | int pipe_progress_main(int argc, char **argv)
|
---|
| 22 | {
|
---|
| 23 | RESERVE_CONFIG_BUFFER(buf, PIPE_PROGRESS_SIZE);
|
---|
| 24 | time_t t = time(NULL);
|
---|
| 25 | size_t len;
|
---|
| 26 |
|
---|
| 27 | while ((len = fread(buf, 1, PIPE_PROGRESS_SIZE, stdin)) > 0) {
|
---|
| 28 | time_t new_time = time(NULL);
|
---|
| 29 | if (new_time != t) {
|
---|
| 30 | t = new_time;
|
---|
| 31 | fputc('.', stderr);
|
---|
| 32 | }
|
---|
| 33 | fwrite(buf, len, 1, stdout);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | fputc('\n', stderr);
|
---|
| 37 |
|
---|
| 38 | if (ENABLE_FEATURE_CLEAN_UP)
|
---|
| 39 | RELEASE_CONFIG_BUFFER(buf);
|
---|
| 40 |
|
---|
| 41 | return 0;
|
---|
| 42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.