source: golgotha/src/i4/error/alert.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.8 KB
Line 
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
13extern FILE *i4_error_mirror_file;
14
15int 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
42i4_alert_function_type i4_alert_function=i4_default_alert;
43
44void 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
73void i4_set_alert_function(i4_alert_function_type fun)
74{
75  i4_alert_function=fun;
76}
77
78
Note: See TracBrowser for help on using the repository browser.