gargoyle/src/delusion.c

36 lines
893 B
C

#include <gargoyle/delusion.h>
#include <gargoyle/twine.h>
#include <stdarg.h>
#include <stdio.h>
void gargoyle_emit_err(struct gargoyle_err *err) {
fprintf(stderr, "%s(%u): ", err->func, err->code);
if(err->errno_code) {
fprintf(stderr, "%s(%d): ", err->errno_func, err->errno_code);
}
fprintf(stderr, "%s\n", err->msg);
}
void gargoyle_fill_err(struct gargoyle_err *err, gargoyle_err_type code, int errno_code, const char *func, const char *errno_func, const char *fmt, ...) {
err->code = code;
err->errno_code = errno_code;
if(func) {
gargoyle_cpy(err->func, func, GARGOYLE_MAX_FUNC_SZ, GARGOYLE_FLG_FILL0);
}
if(errno_func) {
gargoyle_cpy(err->errno_func, errno_func, GARGOYLE_MAX_FUNC_SZ, GARGOYLE_FLG_FILL0);
}
if(fmt) {
va_list args;
va_start(args, fmt);
vsnprintf(err->msg, GARGOYLE_MAX_ERR_SZ, fmt, args);
va_end(args);
}
}