From 16f960feb501d9c2444c1b5d8ad5ba81e932b975 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Thu, 31 Mar 2005 00:19:13 +0000 Subject: Added log_format_has(). --- log.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'log.c') diff --git a/log.c b/log.c index 87cd1d77..c8a433db 100644 --- a/log.c +++ b/log.c @@ -364,7 +364,7 @@ static void log_formatted(enum logcode code, char *format, char *op, * rather keep going until we reach the nul of the format. */ total = strlcpy(buf, format, sizeof buf); - for (p = buf; (p = strchr(p, '%')) != NULL && p[1]; ) { + for (p = buf; (p = strchr(p, '%')) != NULL; ) { s = p++; n = fmt + 1; if (*p == '-') @@ -535,6 +535,26 @@ static void log_formatted(enum logcode code, char *format, char *op, rprintf(code, "%s\n", buf); } +int log_format_has(const char *format, char esc) +{ + const char *p; + + if (!format) + return 0; + + for (p = format; (p = strchr(p, '%')) != NULL; ) { + if (*++p == '-') + p++; + while (isdigit(*(uchar*)p)) + p++; + if (!*p) + break; + if (*p == esc) + return 1; + } + return 0; +} + /* log the transfer of a file */ void log_item(struct file_struct *file, struct stats *initial_stats, int iflags, char *hlink) -- cgit v1.2.3