Magellan Linux

Annotation of /trunk/mkinitrd-magellan/busybox/debianutils/pipe_progress.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1123 - (hide annotations) (download)
Wed Aug 18 21:56:57 2010 UTC (13 years, 10 months ago) by niro
File MIME type: text/plain
File size: 860 byte(s)
-updated to busybox-1.17.1
1 niro 532 /* 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 niro 816 #include "libbb.h"
10 niro 532
11     #define PIPE_PROGRESS_SIZE 4096
12    
13     /* Read a block of data from stdin, write it to stdout.
14     * Activity is indicated by a '.' to stderr
15     */
16 niro 816 int pipe_progress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
17     int pipe_progress_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
18 niro 532 {
19 niro 1123 char buf[PIPE_PROGRESS_SIZE];
20 niro 532 time_t t = time(NULL);
21 niro 1123 int len;
22 niro 532
23 niro 1123 while ((len = safe_read(STDIN_FILENO, buf, PIPE_PROGRESS_SIZE)) > 0) {
24 niro 532 time_t new_time = time(NULL);
25     if (new_time != t) {
26     t = new_time;
27 niro 1123 bb_putchar_stderr('.');
28 niro 532 }
29 niro 1123 full_write(STDOUT_FILENO, buf, len);
30 niro 532 }
31    
32 niro 1123 bb_putchar_stderr('\n');
33 niro 532
34     return 0;
35     }