source: trunk/src/xml_error.c @ 4138

Last change on this file since 4138 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
RevLine 
[112]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]);
[121]13                exit(-1);
[112]14        }
[124]15        else {
16                fprintf(stderr, "Violation of validity constraint: %s\n", XML_Constraint_Strings[errCode]);
17                exit(-1);
18        }
[112]19}
20
21void ShowSyntaxError(XML_NonTerminal errCode) {
22        fprintf(stderr, "Syntax error in production: %s\n", XML_NonTerminal_Names[errCode]);
23}
24
25
[267]26void NoEncodingError(const char * msg) {
[112]27        fprintf(stderr, "Error : %s\n", msg);
28        exit(-1);
29}
30
[267]31void EncodingError(const char * msg, unsigned char * encoding, int lgth) {
[112]32        fprintf(stderr, "Error : Illegal/unsupported %s encoding of length %i: \"", msg, lgth);
[121]33        for (int i = 0; i < lgth; i++) fprintf(stderr, "%c", encoding[i]);
[267]34        fprintf(stderr, "\"\n");
[112]35        exit(-1);
36}
37
[267]38void CharSetValidationError(const char * encoding, int err_pos) {
[120]39        fprintf(stderr, "Error: Invalid %s character in input stream at position %i\n", encoding, err_pos);
[112]40        exit(-1);
41}
42
[120]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
[112]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
[267]58void ImplementationLimitError(const char * msg) {
[112]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}
[120]67
Note: See TracBrowser for help on using the repository browser.