source: trunk/src/core/scew/error.c @ 5673

Last change on this file since 5673 was 5673, checked in by ldelgass, 9 years ago

Fix line endings, set eol-style to native on all C/C++ sources.

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/**
2 *
3 * @file     error.c
4 * @author   Aleix Conchillo Flaque <aleix@member.fsf.org>
5 * @date     Mon May 05, 2003 10:35
6 * @brief    SCEW error handling
7 *
8 * $Id: error.c,v 1.4 2004/05/25 20:23:04 aleix Exp $
9 *
10 * @if copyright
11 *
12 * Copyright (C) 2003, 2004 Aleix Conchillo Flaque
13 *
14 * SCEW is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SCEW is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
27 *
28 * @endif
29 */
30
31#include "error.h"
32
33#include "str.h"
34
35#include "xerror.h"
36#include "xparser.h"
37
38#include <assert.h>
39
40
41scew_error
42scew_error_code()
43{
44    return get_last_error();
45}
46
47XML_Char const*
48scew_error_string(scew_error code)
49{
50    static const XML_Char *message[] = {
51        _XT("No error"),
52        _XT("Out of memory"),
53        _XT("Input/Output error"),
54        _XT("Callback error"),
55        _XT("Internal Expat parser error")
56    };
57
58    assert(sizeof(message) / sizeof(message[0]) == scew_error_count);
59
60    if ((code < 0) || (code > scew_error_count))
61    {
62        // This is not thread safe. Even though, no one should get in
63        // here.
64        static XML_Char unk_message[35];
65        scew_sprintf(unk_message, _XT("Unknown error code (%d)"), code);
66        return unk_message;
67    }
68    else
69    {
70        return message[code];
71    }
72}
73
74enum XML_Error
75scew_error_expat_code(scew_parser* parser)
76{
77    assert(parser != NULL);
78
79    return XML_GetErrorCode(parser->parser);
80}
81
82XML_Char const*
83scew_error_expat_string(enum XML_Error code)
84{
85    return XML_ErrorString(code);
86}
87
88int
89scew_error_expat_line(scew_parser* parser)
90{
91    assert(parser != NULL);
92
93    return XML_GetCurrentLineNumber(parser->parser);
94}
95
96int
97scew_error_expat_column(scew_parser* parser)
98{
99    assert(parser != NULL);
100
101    return XML_GetCurrentColumnNumber(parser->parser);
102}
Note: See TracBrowser for help on using the repository browser.