1: /******************************************************************************
2: ezht - Copyright (C) 2004 Tradcrafts
3: This file is part of the ezht.
4:
5: ezht is free software; you can redistribute it and/or modify
6: it under the terms of the GNU General Public License as published by the
7: Free Software Foundation; either version 2 of the License, or (at your
8: option) any later version.
9:
10: ezht is distributed in the hope that it will be useful, but
11: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13: more details.
14:
15: You should have received a copy of the GNU General Public License along with
16: this program; see the file COPYING. If not, write to the Free Software
17: Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18: ******************************************************************************/
19:
20: #include <stdarg.h>
21: #include "reader.h"
22:
23: void error(const char *fmt, ...)
24: {
25: const char *fnam = reader.get_fnam();
26: int linenum = reader.get_linenum();
27:
28: if( fnam )
29: fprintf(stderr,"%s[%d]: ",fnam,linenum);
30:
31: va_list arg;
32: va_start(arg,fmt);
33: vfprintf(stderr,fmt,arg);
34: va_end(arg);
35:
36: fprintf(stderr,"\n");
37:
38: exit(-1);
39: }
40:
41: void warn(const char *fmt, ...)
42: {
43: const char *fnam = reader.get_fnam();
44: int linenum = reader.get_linenum();
45:
46: if( fnam )
47: fprintf(stderr,"WARNING: %s[%d]: ",fnam,linenum);
48:
49: va_list arg;
50: va_start(arg,fmt);
51: vfprintf(stderr,fmt,arg);
52: va_end(arg);
53:
54: fprintf(stderr,"\n");
55: }
56: