Introduce __imlib_perror() to produce error messages

This commit is contained in:
Kim Woelders 2023-05-08 12:10:13 +02:00
parent c44f3a4124
commit 11cef49cef
3 changed files with 24 additions and 0 deletions

View File

@ -107,6 +107,9 @@ unsigned int __imlib_time_us(void);
#endif /* IMLIB2_DEBUG */
#define E(fmt...) __imlib_perror(DBG_PFX, fmt)
__PRINTF_2__ void __imlib_perror(const char *pfx, const char *fmt, ...);
/* image.h */
/* 32767 is the maximum pixmap dimension and ensures that

View File

@ -69,7 +69,26 @@ __imlib_printf(const char *pfx, const char *fmt, ...)
fmt = fmtx;
}
vfprintf(opt_fout, fmt, args);
va_end(args);
}
#endif /* IMLIB2_DEBUG */
__EXPORT__ void
__imlib_perror(const char *pfx, const char *fmt, ...)
{
char fmtx[1024];
va_list args;
va_start(args, fmt);
if (pfx)
{
snprintf(fmtx, sizeof(fmtx), "ERROR: %-4s: %s", pfx, fmt);
fmt = fmtx;
}
vfprintf(stderr, fmt, args);
va_end(args);
}

View File

@ -33,4 +33,6 @@ unsigned int __imlib_time_us(void);
#endif /* IMLIB2_DEBUG */
__PRINTF_2__ void __imlib_perror(const char *pfx, const char *fmt, ...);
#endif /* IMLIB2_DEDUG_H */