This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathmsghandling.c
64 lines (58 loc) · 1.53 KB
/
msghandling.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "msghandling.h"
#include "../include/GL/gl.h"
#include "zgl.h"
#include <stdarg.h>
#ifdef __TINYC__
#define NO_DEBUG_OUTPUT
#endif
#ifndef NO_DEBUG_OUTPUT
#include <stdio.h>
#endif
/* Use this function to output messages when something unexpected
happens (which might be an indication of an error). *Don't* use it
when there's GLinternal errors in the code - these should be handled
by asserts. */
void tgl_warning(const char* format, ...) {
#ifndef NO_DEBUG_OUTPUT
va_list args;
va_start(args, format);
fprintf(stderr, "*WARNING* ");
vfprintf(stderr, format, args);
va_end(args);
#endif /* !NO_DEBUG_OUTPUT */
}
/* This function should be used for debug output only. */
void tgl_trace(const char* format, ...) {
#ifndef NO_DEBUG_OUTPUT
va_list args;
va_start(args, format);
fprintf(stderr, "*DEBUG* ");
vfprintf(stderr, format, args);
va_end(args);
#endif /* !NO_DEBUG_OUTPUT */
}
/* Use this function to output info about things in the code which
should be fixed (missing handling of special cases, important
features not implemented, known bugs/buglets, ...). */
void tgl_fixme(const char* format, ...) {
#ifndef NO_DEBUG_OUTPUT
va_list args;
va_start(args, format);
fprintf(stderr, "*FIXME* ");
vfprintf(stderr, format, args);
va_end(args);
#endif /* !NO_DEBUG_OUTPUT */
}
void gl_fatal_error(char* format, ...) {
#ifndef NO_DEBUG_OUTPUT
va_list ap;
va_start(ap, format);
fprintf(stderr, "TinyGL: fatal error: ");
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
exit(1);
va_end(ap);
#else
exit(1);
#endif
}