1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-05 21:07:52 +00:00

convert freq and freq_g to callbacks.print

This commit is contained in:
Phil Sutter 2009-11-26 01:42:54 +01:00
parent 31c3734cc8
commit c652427aed
4 changed files with 27 additions and 20 deletions

View File

@ -688,3 +688,24 @@ void free_acpitemp(struct text_object *obj)
close(obj->data.i);
}
#endif /* !__OpenBSD__ */
void print_freq(struct text_object *obj, char *p, int p_max_size)
{
static int ok = 1;
if (ok) {
ok = get_freq(p, p_max_size, "%.0f", 1, obj->data.i);
}
}
void print_freq_g(struct text_object *obj, char *p, int p_max_size)
{
static int ok = 1;
if (ok) {
#ifndef __OpenBSD__
ok = get_freq(p, p_max_size, "%'.2f", 1000, obj->data.i);
#else
/* OpenBSD has no such flag (SUSv2) */
ok = get_freq(p, p_max_size, "%.2f", 1000, obj->data.i);
#endif /* __OpenBSD */
}
}

View File

@ -113,4 +113,7 @@ void print_acpitemp(struct text_object *, char *, int);
void free_acpitemp(struct text_object *);
#endif /* !__OpenBSD__ */
void print_freq(struct text_object *, char *, int);
void print_freq_g(struct text_object *, char *, int);
#endif /* _COMMON_H */

View File

@ -798,26 +798,6 @@ void generate_text_internal(char *p, int p_max_size,
switch (obj->type) {
default:
NORM_ERR("not implemented obj type %d", obj->type);
OBJ(freq) {
static int ok = 1;
if (ok) {
ok = get_freq(p, p_max_size, "%.0f", 1,
obj->data.i);
}
}
OBJ(freq_g) {
static int ok = 1;
if (ok) {
#ifndef __OpenBSD__
ok = get_freq(p, p_max_size, "%'.2f", 1000,
obj->data.i);
#else
/* OpenBSD has no such flag (SUSv2) */
ok = get_freq(p, p_max_size, "%.2f", 1000,
obj->data.i);
#endif /* __OpenBSD */
}
}
#ifndef __OpenBSD__
OBJ(acpifan) {
get_acpi_fan(p, p_max_size);

View File

@ -157,6 +157,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
#endif /* X11 */
#ifdef __OpenBSD__
OBJ(freq, 0)
obj->callbacks.print = &print_freq;
#else
OBJ(acpitemp, 0)
obj->data.i = open_acpi_temperature(arg);
@ -174,6 +175,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
} else {
obj->data.i = atoi(&arg[0]);
}
obj->callbacks.print = &print_freq;
END OBJ(freq_g, 0)
get_cpu_count();
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
@ -184,6 +186,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
} else {
obj->data.i = atoi(&arg[0]);
}
obj->callbacks.print = &print_freq_g;
END OBJ_ARG(read_tcp, 0, "read_tcp: Needs \"(host) port\" as argument(s)")
parse_read_tcp_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_read_tcp;