source: trunk/gsdl/src/mgpp/text/mg_errors.cpp@ 2445

Last change on this file since 2445 was 2445, checked in by jrm21, 23 years ago

needed #defines

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1/**************************************************************************
2 *
3 * mg_errors.cpp -- Error related stuff for mgquery
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: mg_errors.cpp 2445 2001-05-17 04:55:58Z jrm21 $
21 *
22 **************************************************************************/
23#define _XOPEN_SOURCE 1
24#define _XOPEN_SOURCE_EXTENDED 1
25
26#include "sysfuncs.h"
27#include "memlib.h"
28
29#include "mg_errors.h"
30
31
32
33int mg_errno = MG_NOERROR;
34
35char *mg_errorstrs[] =
36{
37 "No error",
38 "Out of memory",
39 "File \"%s\" not found",
40 "Bad magic number in \"%s\"",
41 "Error reading \"%s\"",
42 "MG_BUFTOOSMALL",
43 "Files required for level 2 and 3 inversion are missing"};
44
45
46/* [RJM 07/98: Memory Leak] -- rest of file */
47
48static char null_data[] = "";
49char *mg_error_data = null_data;
50
51
52void MgErrorData (char *s)
53{
54 /* free the current error string, unless it is the null string */
55 if ((mg_error_data != NULL) && (mg_error_data != null_data)) {
56 delete mg_error_data;
57 mg_error_data = null_data;
58 }
59
60 /* make a copy of the string */
61 mg_error_data = Xstrdup (s);
62
63 /* if the alloc failed set the error to the null string */
64 if (!mg_error_data) mg_error_data = null_data;
65}
66
67
68void MgErrorDeinit (void)
69{
70 /* free the current error string, unless it is the null string */
71 if ((mg_error_data != NULL) && (mg_error_data != null_data)) {
72 delete mg_error_data;
73 mg_error_data = null_data;
74 }
75}
Note: See TracBrowser for help on using the repository browser.