mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 17:47:09 +00:00
if_mounted: convert to callbacks.iftest
This commit is contained in:
parent
9af79a4907
commit
5249c9da04
@ -17,7 +17,7 @@ void start_update_threading(void);
|
||||
|
||||
|
||||
void strfold(char *start, int count);
|
||||
int check_mount(char *s);
|
||||
int check_mount(struct text_object *);
|
||||
void prepare_update(void);
|
||||
void update_uptime(void);
|
||||
void update_meminfo(void);
|
||||
|
@ -969,12 +969,6 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
*spc = ' ';
|
||||
}
|
||||
}
|
||||
OBJ(if_mounted) {
|
||||
if ((obj->data.s)
|
||||
&& (!check_mount(obj->data.s))) {
|
||||
DO_JUMP;
|
||||
}
|
||||
}
|
||||
OBJ(if_running) {
|
||||
#ifdef __linux__
|
||||
if (!get_process_by_name(obj->data.s)) {
|
||||
|
@ -691,6 +691,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
|
||||
obj->data.s = strndup(arg, text_buffer_size);
|
||||
obj->callbacks.iftest = &check_mount;
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
#ifdef __linux__
|
||||
END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "freebsd.h"
|
||||
#include "logging.h"
|
||||
#include "net_stat.h"
|
||||
#include "text_object.h"
|
||||
#include "top.h"
|
||||
#include "diskio.h"
|
||||
|
||||
@ -135,14 +136,17 @@ void update_uptime(void)
|
||||
}
|
||||
}
|
||||
|
||||
int check_mount(char *s)
|
||||
int check_mount(struct text_object *obj)
|
||||
{
|
||||
struct statfs *mntbuf;
|
||||
int i, mntsize;
|
||||
|
||||
if (!obj->data.s)
|
||||
return 0;
|
||||
|
||||
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
|
||||
for (i = mntsize - 1; i >= 0; i--) {
|
||||
if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
|
||||
if (strcmp(mntbuf[i].f_mntonname, obj->data.s) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
11
src/linux.c
11
src/linux.c
@ -127,17 +127,20 @@ void update_uptime(void)
|
||||
}
|
||||
}
|
||||
|
||||
int check_mount(char *s)
|
||||
int check_mount(struct text_object *obj)
|
||||
{
|
||||
int ret = 0;
|
||||
FILE *mtab = fopen("/etc/mtab", "r");
|
||||
FILE *mtab;
|
||||
|
||||
if (mtab) {
|
||||
if (!obj->data.s)
|
||||
return 0;
|
||||
|
||||
if ((mtab = fopen("/etc/mtab", "r"))) {
|
||||
char buf1[256], buf2[128];
|
||||
|
||||
while (fgets(buf1, 256, mtab)) {
|
||||
sscanf(buf1, "%*s %128s", buf2);
|
||||
if (!strcmp(s, buf2)) {
|
||||
if (!strcmp(obj->data.s, buf2)) {
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -108,9 +108,10 @@ void update_uptime()
|
||||
}
|
||||
}
|
||||
|
||||
int check_mount(char *s)
|
||||
int check_mount(struct text_object *obj)
|
||||
{
|
||||
/* stub */
|
||||
(void)obj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -134,9 +134,10 @@ static int swapmode(int *used, int *total)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int check_mount(char *s)
|
||||
int check_mount(struct text_object *obj)
|
||||
{
|
||||
/* stub */
|
||||
(void)obj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,9 @@ void update_meminfo()
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
int check_mount(char *s)
|
||||
int check_mount(struct text_object *obj)
|
||||
{
|
||||
/* stub */
|
||||
(void)obj;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user