annotate lwlib/lw_error.c @ 361:105393e31f20

Generic memory mode insns
author lost@starbug
date Thu, 01 Apr 2010 20:44:57 -0600
parents ed3553296580
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
329
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
1 /*
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
2 lw_error.c
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
3
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
4 Copyright © 2010 William Astle
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
5
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
6 This file is part of LWTOOLS.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
7
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
11 version.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
12
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
16 more details.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
17
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
20 */
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
21
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
22 #include <config.h>
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
23
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
24 #define ___lw_error_c_seen___
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
25 #include <lw_error.h>
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
26
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
27 #include <stdio.h>
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
28 #include <stdlib.h>
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
29 #include <stdarg.h>
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
30
331
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
31 static void (*lw_error_func)(const char *fmt, ...) = NULL;
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
32
329
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
33 void lw_error(const char *fmt, ...)
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
34 {
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
35 va_list args;
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
36 va_start(args, fmt);
331
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
37 if (lw_error_func)
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
38 (*lw_error_func)(fmt, args);
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
39 else
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
40 vfprintf(stderr, fmt, args);
329
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
41 va_end(args);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
42 exit(1);
c15cca3ae6a2 Created first pass of input layer
lost
parents:
diff changeset
43 }
331
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
44
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
45 void lw_error_setfunc(void (*f)(const char *fmt, ...))
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
46 {
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
47 lw_error_func = f;
ed3553296580 Port manual forward with corrections from Jason Law
lost
parents: 329
diff changeset
48 }