mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 12:10:03 +00:00
convert format_time to callbacks.print
This commit is contained in:
parent
f84b14904c
commit
d9e2f687b6
@ -956,13 +956,6 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
DO_JUMP;
|
||||
}
|
||||
}
|
||||
OBJ(format_time) {
|
||||
char buf[max_user_text];
|
||||
|
||||
generate_text_internal(buf, max_user_text, *obj->sub, cur);
|
||||
obj->data.s = buf;
|
||||
print_format_time(obj, p, p_max_size);
|
||||
}
|
||||
OBJ(nodename) {
|
||||
snprintf(p, p_max_size, "%s", cur->uname_s.nodename);
|
||||
}
|
||||
|
@ -826,6 +826,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ_ARG(format_time, 0, "format_time needs a pid as argument")
|
||||
obj->sub = malloc(sizeof(struct text_object));
|
||||
extract_variable_text_internal(obj->sub, arg);
|
||||
obj->callbacks.print = &print_format_time;
|
||||
END OBJ(nodename, 0)
|
||||
END OBJ_ARG(cmdline_to_pid, 0, "cmdline_to_pid needs a command line as argument")
|
||||
scan_cmdline_to_pid_arg(obj, arg, free_at_crash);
|
||||
|
@ -155,7 +155,7 @@ void free_tztime(struct text_object *obj)
|
||||
|
||||
//all chars after the ending " and between the seconds and the starting " are silently
|
||||
//ignored, this is wanted behavior, not a bug, so don't "fix" this.
|
||||
void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
static void do_format_time(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
double seconds;
|
||||
char *currentchar, *temp;
|
||||
unsigned int output_length = 0;
|
||||
@ -305,3 +305,13 @@ void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size
|
||||
NORM_ERR("$format_time didn't receive a time in seconds as first argument")
|
||||
}
|
||||
}
|
||||
|
||||
void print_format_time(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
char buf[max_user_text];
|
||||
|
||||
generate_text_internal(buf, max_user_text, *obj->sub, &info);
|
||||
obj->data.s = buf;
|
||||
do_format_time(obj, p, p_max_size);
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,10 @@ void scan_tztime(struct text_object *, const char *);
|
||||
void print_time(struct text_object *, char *, int);
|
||||
void print_utime(struct text_object *, char *, int);
|
||||
void print_tztime(struct text_object *, char *, int);
|
||||
void print_format_time(struct text_object *obj, char *p, int p_max_size);
|
||||
|
||||
/* free object data */
|
||||
void free_time(struct text_object *);
|
||||
void free_tztime(struct text_object *);
|
||||
|
||||
#endif /* _TIMEINFO_H */
|
||||
|
||||
void print_format_time(struct text_object *obj, char *p, int p_max_size);
|
||||
|
Loading…
Reference in New Issue
Block a user