[856] | 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 856 2000-01-14 02:26:25Z sjboddie $
|
---|
| 21 | *
|
---|
| 22 | **************************************************************************/
|
---|
| 23 |
|
---|
| 24 | #include "sysfuncs.h"
|
---|
| 25 | #include "memlib.h"
|
---|
| 26 |
|
---|
| 27 | #include "mg_errors.h"
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | int mg_errno = MG_NOERROR;
|
---|
| 32 |
|
---|
| 33 | char *mg_errorstrs[] =
|
---|
| 34 | {
|
---|
| 35 | "No error",
|
---|
| 36 | "Out of memory",
|
---|
| 37 | "File \"%s\" not found",
|
---|
| 38 | "Bad magic number in \"%s\"",
|
---|
| 39 | "Error reading \"%s\"",
|
---|
| 40 | "MG_BUFTOOSMALL",
|
---|
| 41 | "Files required for level 2 and 3 inversion are missing"};
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | /* [RJM 07/98: Memory Leak] -- rest of file */
|
---|
| 45 |
|
---|
| 46 | static char null_data[] = "";
|
---|
| 47 | char *mg_error_data = null_data;
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | void 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 |
|
---|
| 66 | void 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 | }
|
---|