From e2a37cf9c1c1e209dec015ded939b8eb5226bbf3 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Mon, 7 Sep 2015 21:43:01 +0200 Subject: .. --- src/cssh.c | 1 + src/progressbar.c | 17 ++++++++++++++++- src/progressbar.h | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cssh.c b/src/cssh.c index 4a58c03..7b99c6e 100644 --- a/src/cssh.c +++ b/src/cssh.c @@ -1364,6 +1364,7 @@ int main( int argc, char *argv[] ) break; } } + redraw_progressbars( &progressbars ); } break; } } diff --git a/src/progressbar.c b/src/progressbar.c index 3d07e4e..e8cd54b 100644 --- a/src/progressbar.c +++ b/src/progressbar.c @@ -20,6 +20,8 @@ int create_progressbar( cssh_progressbar_t *progressbar, uint64_t min_value, uin (void)vsnprintf( progressbar->label, size, label_fmt, va ); + progressbar->value = progressbar->min_value; + va_end( va ); return 0; @@ -32,7 +34,12 @@ void free_progressbar( cssh_progressbar_t *progressbar ) void set_value_of_progressbar( cssh_progressbar_t *progressbar, uint64_t value ) { - fprintf( stderr, "%s %"PRIu64" \n", progressbar->label, value ); + progressbar->value = value; +} + +void redraw_progressbar( cssh_progressbar_t *progressbar ) +{ + fprintf( stderr, "%s %"PRIu64" \n", progressbar->label, progressbar->value ); } int create_progressbar_pool( cssh_progressbar_pool_t *pool, size_t initial_size ) @@ -88,4 +95,12 @@ int remove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressba return -1; } +void redraw_progressbars( cssh_progressbar_pool_t *pool ) +{ + + for( size_t i = 0; i < pool->N; i++ ) { + redraw_progressbar( pool->progressbar[i] ); + } + printf( "\33[%dF\n", pool->N + 1 ); +} diff --git a/src/progressbar.h b/src/progressbar.h index 71eaed1..3bcc65b 100644 --- a/src/progressbar.h +++ b/src/progressbar.h @@ -12,6 +12,7 @@ typedef struct cssh_progressbar_t { uint64_t min_value; uint64_t max_value; char *label; + uint64_t value; } cssh_progressbar_t; typedef struct cssh_progressbar_pool_t { @@ -26,6 +27,8 @@ void free_progressbar( cssh_progressbar_t *progressbar ); void set_value_of_progressbar( cssh_progressbar_t *progressbar, uint64_t value ); +void redraw_progressbar( cssh_progressbar_t *progressbar ); + int create_progressbar_pool( cssh_progressbar_pool_t *pool, size_t initial_size ); void free_progressbar_pool( cssh_progressbar_pool_t *pool ); @@ -34,4 +37,6 @@ int append_progressbar_to_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_ int remove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar ); +void redraw_progressbars( cssh_progressbar_pool_t *pool ); + #endif -- cgit v1.2.3-54-g00ecf