[dovecot-cvs] dovecot/src/lib failures.c,1.3,1.4 strfuncs.c,1.16,1.17 strfuncs.h,1.7,1.8
cras at procontrol.fi
cras at procontrol.fi
Mon Nov 4 07:33:50 EET 2002
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv19567
Modified Files:
failures.c strfuncs.c strfuncs.h
Log Message:
Added printf_string_fix_format() which currently just replaces %m with
strerror(errno). i_panic, i_fatal, i_error and i_warning didn't expand the
%m before when not writing to syslog.
Index: failures.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/failures.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- failures.c 20 Oct 2002 03:15:16 -0000 1.3
+++ failures.c 4 Nov 2002 05:33:48 -0000 1.4
@@ -64,7 +64,7 @@
write_prefix();
fputs("Panic: ", log_fd);
- vfprintf(log_fd, format, args);
+ vfprintf(log_fd, printf_string_fix_format(format), args);
fputc('\n', log_fd);
abort();
@@ -75,7 +75,7 @@
write_prefix();
fputs("Fatal: ", log_fd);
- vfprintf(log_fd, format, args);
+ vfprintf(log_fd, printf_string_fix_format(format), args);
fputc('\n', log_fd);
exit(98);
@@ -87,9 +87,11 @@
write_prefix();
+ t_push();
fputs("Error: ", log_fd);
- vfprintf(log_fd, format, args);
+ vfprintf(log_fd, printf_string_fix_format(format), args);
fputc('\n', log_fd);
+ t_pop();
fflush(log_fd);
@@ -102,9 +104,11 @@
write_prefix();
+ t_push();
fputs("Warning: ", log_fd);
- vfprintf(log_fd, format, args);
- fputc('\n', log_fd);
+ vfprintf(log_fd, printf_string_fix_format(format), args);
+ fputc('\n', log_fd);
+ t_pop();
fflush(log_fd);
Index: strfuncs.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strfuncs.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- strfuncs.c 23 Oct 2002 13:19:56 -0000 1.16
+++ strfuncs.c 4 Nov 2002 05:33:48 -0000 1.17
@@ -373,7 +373,7 @@
}
/* replace %m with strerror() */
-static const char *fix_format(const char *fmt)
+const char *printf_string_fix_format(const char *fmt)
{
const char *p;
@@ -397,7 +397,7 @@
t_push();
va_start(args, format);
- ret = vsnprintf(str, max_chars, fix_format(format), args);
+ ret = vsnprintf(str, max_chars, printf_string_fix_format(format), args);
va_end(args);
t_pop();
@@ -419,7 +419,7 @@
t_push();
va_start(args, format);
- format = fix_format(format);
+ format = printf_string_fix_format(format);
buf = t_buffer_get(printf_string_upper_bound(format, args));
va_end(args);
@@ -601,7 +601,7 @@
if (format == NULL)
return NULL;
- format = fix_format(format);
+ format = printf_string_fix_format(format);
VA_COPY(temp_args, args);
Index: strfuncs.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strfuncs.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- strfuncs.h 8 Sep 2002 13:20:28 -0000 1.7
+++ strfuncs.h 4 Nov 2002 05:33:48 -0000 1.8
@@ -5,6 +5,7 @@
((str) == NULL || (str)[0] == '\0')
size_t printf_string_upper_bound(const char *format, va_list args);
+const char *printf_string_fix_format(const char *fmt);
int i_snprintf(char *str, size_t max_chars, const char *format, ...)
__attr_format__(3, 4);
More information about the dovecot-cvs
mailing list