source: trunk/src/xml_error.c @ 4277

Last change on this file since 4277 was 267, checked in by ksherdy, 10 years ago

Construct and pass string literals as read only (const char *) types.

File size: 1.9 KB
Line 
1/*  xml_error.c - Error reporting for XML parsing/validation.
2    Copyright (c) 2008, Robert D. Cameron and Dan Lin.
3    Licensed to the public under the Open Software License 3.0.
4    Licensed to International Characters, Inc., under the Academic
5    Free License 3.0.
6*/
7
8#include "xml_error.h"
9
10void ShowConstraintError(XML_Constraint errCode) {
11        if (errCode < vErr_vc_roottype) {
12                fprintf(stderr, "Violation of well-formedness constraint: %s\n", XML_Constraint_Strings[errCode]);
13                exit(-1);
14        }
15        else {
16                fprintf(stderr, "Violation of validity constraint: %s\n", XML_Constraint_Strings[errCode]);
17                exit(-1);
18        }
19}
20
21void ShowSyntaxError(XML_NonTerminal errCode) {
22        fprintf(stderr, "Syntax error in production: %s\n", XML_NonTerminal_Names[errCode]);
23}
24
25
26void NoEncodingError(const char * msg) {
27        fprintf(stderr, "Error : %s\n", msg);
28        exit(-1);
29}
30
31void EncodingError(const char * msg, unsigned char * encoding, int lgth) {
32        fprintf(stderr, "Error : Illegal/unsupported %s encoding of length %i: \"", msg, lgth);
33        for (int i = 0; i < lgth; i++) fprintf(stderr, "%c", encoding[i]);
34        fprintf(stderr, "\"\n");
35        exit(-1);
36}
37
38void CharSetValidationError(const char * encoding, int err_pos) {
39        fprintf(stderr, "Error: Invalid %s character in input stream at position %i\n", encoding, err_pos);
40        exit(-1);
41}
42
43void XMLCharacterError(int err_pos) {
44        fprintf(stderr, "Illegal control character in XML input stream at position %i\n", err_pos);
45        exit(-1);
46}
47
48void IncompleteCodeUnitError() {
49        fprintf(stderr, "Error: Incomplete code unit at end of file.\n");
50        exit(-1);
51}
52
53void DeclarationError(int pos) {
54        fprintf(stderr, "Parsing error at position %i in XML or Text declaration.\n", pos);
55        exit(-1);
56}
57
58void ImplementationLimitError(const char * msg) {
59        fprintf(stderr, "Fatal implementation limit - %s\n", msg);
60        exit(-1);
61}
62
63void ContentModelError() {
64        fprintf(stderr, "Error: nondeterminism in content model.\n");
65        exit(-1);
66}
67
Note: See TracBrowser for help on using the repository browser.