/**
* This is the basic printf-like function for logging a message.
* The @flags contain the log level and possibly other flag bits (like `L_SIGHANDLER`).
+ * Does not change the value of errno.
**/
void msg(uint flags, const char *fmt, ...) FORMAT_CHECK(printf,2,3);
void vmsg(uint flags, const char *fmt, va_list args); /** A vararg version of msg(). **/
* (c) 1997--2009 Martin Mares <mj@ucw.cz>
* (c) 2008 Tomas Gavenciak <gavento@ucw.cz>
* (c) 2014 Tomas Valla <tom@ucw.cz>
+ * (c) 2020 Pavel Charvat <pchar@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
void
vmsg(uint cat, const char *fmt, va_list args)
{
+ int saved_errno = errno;
struct timeval tv;
struct tm tm;
va_list args2;
/* Generate the message string */
va_copy(args2, args);
+ errno = saved_errno;
len = vsnprintf(msgbuf, sizeof(msgbuf), fmt, args2);
va_end(args2);
if (len < (int) sizeof(msgbuf) || sighandler)
else
{
m.raw_msg = xmalloc(len+1);
+ errno = saved_errno;
vsnprintf(m.raw_msg, len+1, fmt, args);
}
if (m.raw_msg != msgbuf)
xfree(m.raw_msg);
+
+ errno = saved_errno;
}
static void