myxce/src/lib/wrap.c

51 lines
1.3 KiB
C

#include <string.h>
#include "utils.h"
#include "xce/errnox.h"
int __wrap___xpg_strerror_r(int errnum, char* buf, size_t bufsize)
{
return xce_strerror_r(errnum, buf, bufsize);
}
static void xce_perror_(const char* s, int errnum)
{
char buf[XCE_MAX_ERRMSG_LEN];
ectx_t* ectx = get_ectx();
xce_strerror_r(errnum, buf, sizeof(buf));
if (tlog_get_root() == NULL) {
if ((ectx->file != NULL) && (ectx->func != NULL) && (ectx->line > 0)
&& (ectx->code == errnum)) {
fprintf(stderr, "%s: %s at %s:%d %s\n", s, buf, ectx->file,
ectx->line, ectx->func);
} else {
fprintf(stderr, "%s: %s", s, buf);
}
} else {
if ((ectx->file != NULL) && (ectx->func != NULL) && (ectx->line > 0)
&& (ectx->code == errnum)) {
tlog_error("%s: %s at %s:%d %s\n", s, buf, ectx->file, ectx->line,
ectx->func);
} else {
tlog_error("%s: %s", s, buf);
}
}
}
void xce_perror(const char* s) { xce_perror_(s, errno); }
void __wrap_perror(const char* s) { xce_perror(s); }
int __wrap_printf(const char* fmt, ...)
{
va_list ap;
int rc;
va_start(ap, fmt);
rc = xce_vprintf(fmt, ap);
va_end(ap);
return rc;
}