version 1.57, 2015/02/05 10:29:43 |
version 1.58, 2015/02/06 17:11:39 |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
|
/* Expand keys in a template, passing through strftime first. */ |
|
char * |
|
format_expand_time(struct format_tree *ft, const char *fmt, time_t t) |
|
{ |
|
char *tmp, *expanded; |
|
size_t tmplen; |
|
struct tm *tm; |
|
|
|
if (fmt == NULL) |
|
return (xstrdup("")); |
|
|
|
tm = localtime(&t); |
|
|
|
tmp = NULL; |
|
tmplen = strlen(fmt); |
|
|
|
do { |
|
tmp = xreallocarray(tmp, 2, tmplen); |
|
tmplen *= 2; |
|
} while (strftime(tmp, tmplen, fmt, tm) == 0); |
|
|
|
expanded = format_expand(ft, tmp); |
|
free(tmp); |
|
|
|
return (expanded); |
|
} |
|
|
/* Expand keys in a template. */ |
/* Expand keys in a template. */ |
char * |
char * |
format_expand(struct format_tree *ft, const char *fmt) |
format_expand(struct format_tree *ft, const char *fmt) |
|
|
const char *ptr, *s; |
const char *ptr, *s; |
size_t off, len, n; |
size_t off, len, n; |
int ch, brackets; |
int ch, brackets; |
|
|
|
if (fmt == NULL) |
|
return (xstrdup("")); |
|
|
len = 64; |
len = 64; |
buf = xmalloc(len); |
buf = xmalloc(len); |