File: error.c

package info (click to toggle)
keytouch 2.2.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,212 kB
  • ctags: 1,399
  • sloc: ansic: 9,195; sh: 3,630; makefile: 399
file content (90 lines) | stat: -rw-r--r-- 2,433 bytes parent folder | download | duplicates (5)
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
/*-------------------------------------------------------------------------------
Name               : error.c
Author             : Marvin Raaijmakers
Description        : Error message handler
Date of last change: 24-Jun-2006
History            : 24-Jun-2006 Added XmlSetErrorMsg() and XmlGetErrorMsg()

    Copyright (C) 2005-2006 Marvin Raaijmakers

    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
    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

    You can contact me at: marvinr(at)users(dot)sf(dot)net
    (replace (at) by @ and (dot) by .)
---------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <mxml.h>

static char *error_msg = NULL;

void
XmlError (char *message)
/*
Input:
	message	- The error message to print.
Output:
	-
Returns:
	-
Description:
	This function prints the error message 'message' to the stderr.
*/
{
	fprintf (stderr, "libMXml: %s\n", message);
}

void
XmlSetErrorMsg (char *msg)
/*
Input:
	msg		- The error message to store.
Global output:
	error_msg	- A copy of the string 'msg'.
Description:
	This function lets 'error_msg' point to a copy of the string 'msg'. If
	'error_msg' does not point to NULL, this function will free the memory
	pointed to by 'error_msg'. The value of 'error_msg' can be retrieved by
	calling XmlGetErrorMsg().
*/
{
	if (error_msg)
	{
		free (error_msg);
	}
	error_msg = strdup (msg);
	if (error_msg == NULL)
	{
		fputs ("libMXml: Did not have enough memory for"
		       "copying the following error message:", stderr);
		fputs (msg, stderr);
		error_msg = NULL;
	}
}


char
*XmlGetErrorMsg (void)
/*
Global input:
	error_msg	- This pointer will be returned
Returns:
	The error message that was contructed by the latest XmlSetErrorMsg() call.
*/
{
	return error_msg;
}