1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 19:15:12 +00:00

convert fs_*_perc to callbacks.percentage

This commit is contained in:
Phil Sutter 2009-11-25 01:43:36 +01:00
parent 61c4efb305
commit 36a202091e
3 changed files with 11 additions and 11 deletions

View File

@ -600,10 +600,10 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
obj->callbacks.print = &print_fs_free; obj->callbacks.print = &print_fs_free;
END OBJ(fs_used_perc, &update_fs_stats) END OBJ(fs_used_perc, &update_fs_stats)
init_fs(obj, arg); init_fs(obj, arg);
obj->callbacks.print = &print_fs_used_perc; obj->callbacks.percentage = &fs_used_percentage;
END OBJ(fs_free_perc, &update_fs_stats) END OBJ(fs_free_perc, &update_fs_stats)
init_fs(obj, arg); init_fs(obj, arg);
obj->callbacks.print = &print_fs_free_perc; obj->callbacks.percentage = &fs_free_percentage;
END OBJ(fs_size, &update_fs_stats) END OBJ(fs_size, &update_fs_stats)
init_fs(obj, arg); init_fs(obj, arg);
obj->callbacks.print = &print_fs_size; obj->callbacks.print = &print_fs_size;

View File

@ -243,13 +243,13 @@ void init_fs(struct text_object *obj, const char *arg)
obj->data.opaque = prepare_fs_stat(arg ? arg : "/"); obj->data.opaque = prepare_fs_stat(arg ? arg : "/");
} }
static void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size) static uint8_t fs_percentage(struct text_object *obj, int be_free)
{ {
struct fs_stat *fs = obj->data.opaque; struct fs_stat *fs = obj->data.opaque;
int val = 100; int val = 100;
if (!fs) if (!fs)
return; return 0;
if (fs->size) if (fs->size)
val = fs->avail * 100 / fs->size; val = fs->avail * 100 / fs->size;
@ -257,17 +257,17 @@ static void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_m
if (!be_free) if (!be_free)
val = 100 - val; val = 100 - val;
percent_print(p, p_max_size, val); return val;
} }
void print_fs_free_perc(struct text_object *obj, char *p, int p_max_size) uint8_t fs_free_percentage(struct text_object *obj)
{ {
print_fs_perc(obj, 1, p, p_max_size); return fs_percentage(obj, 1);
} }
void print_fs_used_perc(struct text_object *obj, char *p, int p_max_size) uint8_t fs_used_percentage(struct text_object *obj)
{ {
print_fs_perc(obj, 0, p, p_max_size); return fs_percentage(obj, 0);
} }
#define HUMAN_PRINT_FS_GENERATOR(name, expr) \ #define HUMAN_PRINT_FS_GENERATOR(name, expr) \

View File

@ -23,8 +23,8 @@ uint8_t fs_barval(struct text_object *);
uint8_t fs_free_barval(struct text_object *); uint8_t fs_free_barval(struct text_object *);
void init_fs(struct text_object *, const char *); void init_fs(struct text_object *, const char *);
void print_fs_free_perc(struct text_object *, char *, int); uint8_t fs_free_percentage(struct text_object *);
void print_fs_used_perc(struct text_object *, char *, int); uint8_t fs_used_percentage(struct text_object *);
void print_fs_free(struct text_object *, char *, int); void print_fs_free(struct text_object *, char *, int);
void print_fs_size(struct text_object *, char *, int); void print_fs_size(struct text_object *, char *, int);
void print_fs_used(struct text_object *, char *, int); void print_fs_used(struct text_object *, char *, int);