WIP new scatsystem
[qpms.git] / qpms / error.c
blobf64ee9c45817a9f5e59e9c1f13d233d8e84bda0a
1 #include "qpms_error.h"
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <stdarg.h>
6 qpms_dbgmsg_flags qpms_dbgmsg_enabled = QPMS_DBGMSG_MISC;
8 qpms_dbgmsg_flags qpms_dbgmsg_enable(qpms_dbgmsg_flags types) {
9 return (qpms_dbgmsg_enabled |= types);
12 qpms_dbgmsg_flags qpms_dbgmsg_disable(qpms_dbgmsg_flags types) {
13 return (qpms_dbgmsg_enabled &= ~types);
16 void qpms_pr_error(const char *fmt, ...) {
17 fflush(stdout);
18 va_list ap;
19 va_start(ap, fmt);
20 vfprintf(stderr, fmt, ap);
21 va_end(ap);
22 fputc('\n', stderr);
23 fflush(stderr);
24 abort();
28 //void qpms_error(const char *fmt, ...);
30 void qpms_pr_error_at_line(const char *filename, unsigned int linenum,
31 const char *fmt, ...) {
32 fflush(stdout);
33 fprintf(stderr, "%s:%u: ", filename, linenum);
34 va_list ap;
35 va_start(ap, fmt);
36 vfprintf(stderr, fmt, ap);
37 va_end(ap);
38 fputc('\n', stderr);
39 fflush(stderr);
40 abort();
43 void qpms_pr_error_at_flf(const char *filename, unsigned int linenum,
44 const char *func,
45 const char *fmt, ...) {
46 fflush(stdout);
47 fprintf(stderr, "%s:%u, %s: ", filename, linenum, func);
48 va_list ap;
49 va_start(ap, fmt);
50 vfprintf(stderr, fmt, ap);
51 va_end(ap);
52 fputc('\n', stderr);
53 fflush(stderr);
54 abort();
57 void qpms_warn_at_flf(const char *filename, unsigned int linenum,
58 const char *func,
59 const char *fmt, ...) {
60 fprintf(stderr, "%s:%u, %s: ", filename, linenum, func);
61 va_list ap;
62 va_start(ap, fmt);
63 vfprintf(stderr, fmt, ap);
64 va_end(ap);
65 fputc('\n', stderr);
66 fflush(stderr);
69 void qpms_pr_debug_at_flf(const char *filename, unsigned int linenum,
70 const char *func,
71 const char *fmt, ...) {
72 fprintf(stderr, "%s:%u, %s: ", filename, linenum, func);
73 va_list ap;
74 va_start(ap, fmt);
75 vfprintf(stderr, fmt, ap);
76 va_end(ap);
77 fputc('\n', stderr);
78 fflush(stderr);
81 void qpms_debug_at_flf(const char *filename, unsigned int linenum,
82 const char *func, qpms_dbgmsg_flags type,
83 const char *fmt, ...) {
84 if (!(type & qpms_dbgmsg_enabled)) return;
85 fprintf(stderr, "%s:%u, %s: ", filename, linenum, func);
86 va_list ap;
87 va_start(ap, fmt);
88 vfprintf(stderr, fmt, ap);
89 va_end(ap);
90 fputc('\n', stderr);
91 fflush(stderr);
94 //void qpms_error_at_line(const char *filename, unsigned int linenum,
95 // const char *fmt, ...);