1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
/****************************************************************
Copyright (C) 1986-2000 by
F6FBB - Jean-Paul ROUBELAT
6, rue George Sand
31120 - Roquettes - France
jpr@f6fbb.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Parts of code have been taken from many other softwares.
Thanks for the help.
****************************************************************/
#include <serv.h>
#undef fopen
/*
* Writes an error message in ERROR.SYS file
*
* Do not Overlay !
*
*/
static int error_type = 0;
static int erreur = 0;
void boot_prg (void)
{
FILE *fichier;
if ((fichier = fopen ("ERROR.SYS", "a+")) != NULL)
{
#ifdef ENGLISH
fprintf (fichier, "> *** System boot on %s *** \n", strdate (time (NULL)));
#else
fprintf (fichier, "> *** Boot systeme le %s ***\n", strdate (time (NULL)));
#endif
fclose (fichier);
}
}
void err_alloc (unsigned numero)
{
fbb_error (ERR_MEMORY, "malloc", numero);
}
static void fbb_w (unsigned type, char *texte, unsigned numero)
{
FILE *fichier;
int nbfiles = 0;
static char *type_error[] =
{
"WARNING :",
"FATAL :",
"EXCEPTION :",
};
static char *text_error[] =
{
"Cannot open file",
"Cannot create file",
"Cannot close file",
"Cannot resynchronize TNC",
"Not enough memory",
"Wrong channel selection",
"Wrong procedure level",
"Cannot write to file",
"Syntax error",
"Error communication/TNC",
"Pointer already allocated",
"XMS/EMS error",
"Divide by zero",
"Memory exception",
};
if (error_type == 1)
nbfiles = fbb_fcloseall ();
if ((fichier = fopen ("ERROR.SYS", "a+")) != NULL)
{
fprintf (fichier, "> %s Station %s, Ch:%d (%d-%d-%d) %s\n Version %s (%s)\n",
type_error[error_type], pvoie->sta.indicatif.call,
voiecur, pvoie->niv1, pvoie->niv2, pvoie->niv3,
strdate (time (NULL)), version(), date ());
if (error_type == 1)
fprintf (fichier, " %d open files\n", nbfiles);
fprintf (fichier, " %s %u, errno %d=%s %s\n\n",
texte, numero, erreur, strerror (erreur), text_error[type]);
/*
#if FBB_DEBUG
fbb_printfiles(fichier);
if (error_type)
{
print_stack(numero, fichier);
}
#endif
*/
fclose (fichier);
}
}
void fbb_error (unsigned type, char *texte, unsigned numero)
{
erreur = errno;
error_type = 2;
fbb_w (type, texte, numero);
port_log (0, 0, 'S', "Q *** BBS Quit");
ferme_log ();
#ifdef __WINDOWS__
fbb_quit (0);
#else
sleep (5);
exit (0);
#endif
}
void fbb_except (unsigned type, char *texte, unsigned numero)
{
erreur = errno;
error_type = 1;
port_log (0, 0, 'S', "Q *** BBS Quit");
fbb_w (type, texte, numero);
ferme_log ();
}
void fbb_warning (unsigned type, char *texte, unsigned numero)
{
erreur = errno;
error_type = 0;
fbb_w (type, texte, numero);
}
void win_message (int temps, char *texte)
{
#ifdef __WINDOWS__
WinMessage (temps, texte);
#endif
#ifdef __linux__
WinMessage (temps, texte);
#endif
#ifdef __FBBDOS__
fen *fen_ptr;
deb_io ();
fen_ptr = open_win (15, 7, 15 + strlen (texte) + 3, 9, INIT, "message");
_wscroll = 0;
cputs (texte);
putch ('\a');
_wscroll = 1;
sleep_ (temps);
close_win (fen_ptr);
fin_io ();
#endif
}
void write_error (char *filename)
{
int i;
char text[256];
sprintf (text, "Cannot access to %s", filename);
for (i = 0; i < 5; i++)
{
deb_io ();
win_message (2, text);
#ifdef __FBBDOS__
putch ('\a');
#endif
fin_io ();
}
fbb_error (ERR_WRITE, filename, 0);
}
|