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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
cssh - cluster secure shell
Copyright (C) 2015-2021 Andreas Baumann
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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
|