version 1.176, 2019/03/14 21:41:30 |
version 1.177, 2019/03/14 23:14:27 |
|
|
struct client *client; |
struct client *client; |
u_int tag; |
u_int tag; |
int flags; |
int flags; |
|
time_t time; |
|
|
RB_HEAD(format_entry_tree, format_entry) tree; |
RB_HEAD(format_entry_tree, format_entry) tree; |
}; |
}; |
|
|
|
|
ft->tag = tag; |
ft->tag = tag; |
ft->flags = flags; |
ft->flags = flags; |
|
ft->time = time(NULL); |
|
|
format_add_cb(ft, "host", format_cb_host); |
format_add_cb(ft, "host", format_cb_host); |
format_add_cb(ft, "host_short", format_cb_host_short); |
format_add_cb(ft, "host_short", format_cb_host_short); |
|
|
value = new; |
value = new; |
} |
} |
else if (modifiers & FORMAT_EXPANDTIME) { |
else if (modifiers & FORMAT_EXPANDTIME) { |
new = format_expand_time(ft, value, 0); |
new = format_expand_time(ft, value); |
free(value); |
free(value); |
value = new; |
value = new; |
} |
} |
|
|
|
|
/* Expand keys in a template, passing through strftime first. */ |
/* Expand keys in a template, passing through strftime first. */ |
char * |
char * |
format_expand_time(struct format_tree *ft, const char *fmt, time_t t) |
format_expand_time(struct format_tree *ft, const char *fmt) |
{ |
{ |
struct tm *tm; |
struct tm *tm; |
char s[2048]; |
char s[2048]; |
|
|
if (fmt == NULL || *fmt == '\0') |
if (fmt == NULL || *fmt == '\0') |
return (xstrdup("")); |
return (xstrdup("")); |
|
|
if (t == 0) |
tm = localtime(&ft->time); |
t = time(NULL); |
|
tm = localtime(&t); |
|
|
|
if (strftime(s, sizeof s, fmt, tm) == 0) |
if (strftime(s, sizeof s, fmt, tm) == 0) |
return (xstrdup("")); |
return (xstrdup("")); |
|
|