1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "error/alert.hh"
|
---|
10 | #include <stdio.h>
|
---|
11 |
|
---|
12 |
|
---|
13 | extern FILE *i4_error_mirror_file;
|
---|
14 |
|
---|
15 | int i4_default_alert(const i4_const_str &ret)
|
---|
16 | //{{{
|
---|
17 | {
|
---|
18 | #ifdef __MAC__
|
---|
19 | printf("Alert : ");
|
---|
20 | i4_const_str::iterator s=ret.begin();
|
---|
21 | while (s!=ret.end())
|
---|
22 | {
|
---|
23 | printf("%c",s.get().value());
|
---|
24 | ++s;
|
---|
25 | }
|
---|
26 | printf("\n");
|
---|
27 | #else
|
---|
28 | fprintf(stderr,"Alert : ");
|
---|
29 | i4_const_str::iterator s=ret.begin();
|
---|
30 | while (s!=ret.end())
|
---|
31 | {
|
---|
32 | fprintf(stderr,"%c",s.get().value());
|
---|
33 | ++s;
|
---|
34 | }
|
---|
35 | fprintf(stderr,"\n");
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | return 0;
|
---|
39 | }
|
---|
40 | //}}}
|
---|
41 |
|
---|
42 | i4_alert_function_type i4_alert_function=i4_default_alert;
|
---|
43 |
|
---|
44 | void i4_alert(const i4_const_str &format, w32 max_length, ...)
|
---|
45 | {
|
---|
46 | va_list ap;
|
---|
47 | va_start(ap, max_length);
|
---|
48 |
|
---|
49 | i4_str *ret=format.vsprintf(500,ap);
|
---|
50 | (*i4_alert_function)(*ret);
|
---|
51 |
|
---|
52 | #if defined(WIN32)
|
---|
53 | if (!i4_error_mirror_file)
|
---|
54 | i4_error_mirror_file = fopen("error.out","wt");
|
---|
55 | if (i4_error_mirror_file)
|
---|
56 | {
|
---|
57 | fprintf(i4_error_mirror_file,"Alert : ");
|
---|
58 | i4_const_str::iterator s=ret->begin();
|
---|
59 | while (s!=ret->end())
|
---|
60 | {
|
---|
61 | fprintf(i4_error_mirror_file,"%c",s.get().value());
|
---|
62 | ++s;
|
---|
63 | }
|
---|
64 | fprintf(i4_error_mirror_file,"\n");
|
---|
65 | }
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | delete ret;
|
---|
69 | va_end(ap);
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | void i4_set_alert_function(i4_alert_function_type fun)
|
---|
74 | {
|
---|
75 | i4_alert_function=fun;
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|