blob: 53d8524e8b6480f1febb172182bdda5fef5fbed2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// rougly based on https://github.com/doches/progressbar
// but changed in API, multi-line support and some interna
// also simplified to exactly what we need for cssh
#ifndef _PROGRESSBAR_HEADER_INCLUDED
#define _PROGRESSBAR_HEADER_INCLUDED
#include <inttypes.h>
#include <sys/types.h>
#define DEFAULT_COLS 80
#define TERMBUF_SIZE 2048
struct cssh_progressbar_pool_t;
typedef struct cssh_progressbar_t {
uint64_t min_value;
uint64_t max_value;
char *label;
uint64_t value;
unsigned int total_steps;
unsigned int current_step;
struct cssh_progressbar_pool_t *pool;
char *buf;
} cssh_progressbar_t;
typedef struct cssh_progressbar_pool_t {
size_t capacity;
size_t N;
cssh_progressbar_t **progressbar;
char *termbuf;
unsigned char cols;
} cssh_progressbar_pool_t;
int create_progressbar( cssh_progressbar_t *progressbar, uint64_t min_value, uint64_t max_value, size_t size, const char *label_fmt, ... );
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 );
int append_progressbar_to_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar );
int remove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar );
void redraw_progressbars( cssh_progressbar_pool_t *pool );
#endif
|