source: main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mgpp/text/mg_errors.cpp@ 23508

Last change on this file since 23508 was 23508, checked in by sjm84, 13 years ago

Committing 64 bit changes into the branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 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 **************************************************************************/
21
22#define _XOPEN_SOURCE 1
23// This was added for Solaris, but it makes things worse on Solaris for me...
24// #define _XOPEN_SOURCE_EXTENDED 1
25
26#include "sysfuncs.h"
27#include "memlib.h"
28
29#include "mg_errors.h"
30
31int mg_errno = MG_NOERROR;
32
33char *mg_errorstrs[] =
34{
35 (char*)"No error",
36 (char*)"Out of memory",
37 (char*)"File \"%s\" not found",
38 (char*)"Bad magic number in \"%s\"",
39 (char*)"Error reading \"%s\"",
40 (char*)"MG_BUFTOOSMALL",
41 (char*)"Files required for level 2 and 3 inversion are missing"};
42
43
44/* [RJM 07/98: Memory Leak] -- rest of file */
45
46static char null_data[] = "";
47char *mg_error_data = null_data;
48
49
50void MgErrorData (char *s)
51{
52 /* free the current error string, unless it is the null string */
53 if ((mg_error_data != NULL) && (mg_error_data != null_data)) {
54 delete []mg_error_data;
55 mg_error_data = null_data;
56 }
57
58 /* make a copy of the string */
59 mg_error_data = Xstrdup (s);
60
61 /* if the alloc failed set the error to the null string */
62 if (!mg_error_data) mg_error_data = null_data;
63}
64
65
66void MgErrorDeinit (void)
67{
68 /* free the current error string, unless it is the null string */
69 if ((mg_error_data != NULL) && (mg_error_data != null_data)) {
70 delete []mg_error_data;
71 mg_error_data = null_data;
72 }
73}
Note: See TracBrowser for help on using the repository browser.