source: tags/ms_r18q1/TREEGEN/defines.c

Last change on this file was 16766, checked in by westram, 6 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 935 bytes
Line 
1#include "defines.h"
2#include <stdlib.h>
3#include <stdarg.h>
4
5#define MAXERRLEN 500
6
7void error(cstr message) {
8    fprintf(stderr, "Error: %s\n", message);
9    exit(1);
10}
11void warning(cstr message) {
12    fprintf(stderr, "Warning: %s\n", message);
13}
14void errorf(cstr format, ...) {
15    char    errBuf[MAXERRLEN];
16    va_list argptr;
17
18    va_start(argptr, format);
19    vsprintf(errBuf, format, argptr);
20    va_end(argptr);
21
22    error(errBuf);
23}
24void warningf(cstr format, ...) {
25    char    warnBuf[MAXERRLEN];
26    va_list argptr;
27
28    va_start(argptr, format);
29    vsprintf(warnBuf, format, argptr);
30    va_end(argptr);
31
32    warning(warnBuf);
33}
34void def_outOfMemory(cstr source, int lineno) {
35    errorf("Out of memory (in %s, #%i)", source, lineno);
36}
37void def_assert(cstr whatFailed, cstr source, int lineno, int cnt) {
38    errorf("Assertion (%s) failed in %s (Line: %i ; Pass: %i)\n",
39           whatFailed, source, lineno, cnt);
40}
Note: See TracBrowser for help on using the repository browser.