mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
tail, head: use OBJ_ARG to simplify code
This commit is contained in:
parent
a529ac52de
commit
b9a28c37a8
@ -901,9 +901,9 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
free(buf);
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
END OBJ(tail, 0)
|
||||
END OBJ_ARG(tail, 0, "tail needs arguments")
|
||||
init_tailhead("tail", arg, obj, free_at_crash);
|
||||
END OBJ(head, 0)
|
||||
END OBJ_ARG(head, 0, "head needs arguments")
|
||||
init_tailhead("head", arg, obj, free_at_crash);
|
||||
END OBJ_ARG(lines, 0, "lines needs an argument")
|
||||
obj->data.s = strndup(arg, text_buffer_size);
|
||||
|
@ -59,7 +59,6 @@ void tailstring(char *string, int endofstring, int wantedlines) {
|
||||
void init_tailhead(const char* type, const char* arg, struct text_object *obj, void* free_at_crash) {
|
||||
unsigned int args;
|
||||
|
||||
if(arg) {
|
||||
obj->data.headtail.logfile=malloc(DEFAULT_TEXT_BUFFER_SIZE);
|
||||
obj->data.headtail.max_uses = DEFAULT_MAX_HEADTAIL_USES;
|
||||
args = sscanf(arg, "%s %d %d", obj->data.headtail.logfile, &obj->data.headtail.wantedlines, &obj->data.headtail.max_uses);
|
||||
@ -80,9 +79,6 @@ void init_tailhead(const char* type, const char* arg, struct text_object *obj, v
|
||||
free(obj->data.headtail.logfile);
|
||||
CRIT_ERR(obj, free_at_crash, "%s needs a file as 1st and a number of lines as 2nd argument", type);
|
||||
}
|
||||
} else {
|
||||
CRIT_ERR(obj, free_at_crash, "%s needs arguments", type);
|
||||
}
|
||||
}
|
||||
|
||||
void print_tailhead(const char* type, struct text_object *obj, char *p, int p_max_size) {
|
||||
|
Loading…
Reference in New Issue
Block a user