1 /*
2 Ming, an SWF output library
3 Copyright (C) 2002 Opaque Industries - http://www.opaque.net/
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 /* $Id$ */
21
22 #include <stdio.h>
23 #include <stdlib.h> // for exit()
24 #include <stdarg.h>
25 #include "error.h"
26 #include "libming.h"
27
28
29 void
warn_default(const char * msg,...)30 warn_default(const char *msg, ...)
31 {
32 va_list args;
33
34 va_start(args, msg);
35 vfprintf(stderr, msg, args);
36 va_end(args);
37 }
38
39
40 void
error_default(const char * msg,...)41 error_default(const char *msg, ...)
42 {
43 va_list args;
44
45 va_start(args, msg);
46 vfprintf(stderr, msg, args);
47 va_end(args);
48 exit(EXIT_FAILURE);
49 }
50
51
52 SWFMsgFunc _SWF_warn = warn_default; //NULL;
53 SWFMsgFunc _SWF_error = error_default;
54
55 SWFMsgFunc
setSWFWarnFunction(SWFMsgFunc warnfunc)56 setSWFWarnFunction(SWFMsgFunc warnfunc)
57 {
58 SWFMsgFunc old = _SWF_warn;
59 _SWF_warn = warnfunc;
60 return old;
61 }
62
63
64 SWFMsgFunc
setSWFErrorFunction(SWFMsgFunc errorfunc)65 setSWFErrorFunction(SWFMsgFunc errorfunc)
66 {
67 SWFMsgFunc old = _SWF_error;
68 _SWF_error = errorfunc;
69 return old;
70 }
71
72 #if 0
73 void (*SWF_warn)(const char *msg, ...) = warn_default;
74 void (*SWF_error)(const char *msg, ...) = error_default;
75
76 void
77 setSWFWarnFunction(void (*warnfunc)(const char *msg, ...))
78 {
79 SWF_warn = warnfunc;
80 }
81
82
83 void
84 setSWFErrorFunction(void (*errorfunc)(const char *msg, ...))
85 {
86 SWF_error = errorfunc;
87 }
88 #endif
89
90
91
92
93
94
95 /*
96 * Local variables:
97 * tab-width: 2
98 * c-basic-offset: 2
99 * End:
100 */
101