1 /* ------------------------------------------------------------------------ */
3 /* indicator.c -- put indicator */
5 /* Modified Nobutaka Watazaki */
7 /* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */
8 /* Separated from append.c 2003.07.21 Koji Arai */
9 /* ------------------------------------------------------------------------ */
12 #define MAX_INDICATOR_COUNT 58
14 static off_t reading_size;
16 #ifdef NEED_INCREMENTAL_INDICATOR
17 static off_t indicator_count;
18 static long indicator_threshold;
21 #define ALIGN(size, threshold) (((size) + ((threshold)-1))/(threshold))
28 if (isatty(1)) /* stdout */
41 start_indicator(name, size, msg, def_indicator_threshold)
45 long def_indicator_threshold;
47 #ifdef NEED_INCREMENTAL_INDICATOR
55 #ifdef NEED_INCREMENTAL_INDICATOR
58 m = MAX_INDICATOR_COUNT - strlen(name);
59 if (m < 1) /* Bug Fixed by N.Watazaki */
62 printf("%s\t- %s : ", name, msg);
65 ALIGN(size, m*def_indicator_threshold) * def_indicator_threshold;
67 if (indicator_threshold)
68 i = ALIGN(size, indicator_threshold);
76 printf("%s\t- %s : ", name, msg);
84 printf("%s\t- ", name);
90 #ifdef NEED_INCREMENTAL_INDICATOR
95 reading_size += count;
96 if (!quiet && indicator_threshold) {
97 while (reading_size > indicator_count) {
100 indicator_count += indicator_threshold;
107 finish_indicator2(name, msg, pcnt)
116 pcnt = 100; /* (^_^) */
117 #ifdef NEED_INCREMENTAL_INDICATOR
119 printf("%s\t- %s(%d%%)\n", name, msg, pcnt);
127 finish_indicator(name, msg)
134 #ifdef NEED_INCREMENTAL_INDICATOR
136 printf("%s\t- %s\n", name, msg);