Apache HTTPD
common.h
Go to the documentation of this file.
1/* Commonly used functions for the Expat test suite
2 __ __ _
3 ___\ \/ /_ __ __ _| |_
4 / _ \\ /| '_ \ / _` | __|
5 | __// \| |_) | (_| | |_
6 \___/_/\_\ .__/ \__,_|\__|
7 |_| XML parser
8
9 Copyright (c) 2001-2006 Fred L. Drake, Jr. <[email protected]>
10 Copyright (c) 2003 Greg Stein <[email protected]>
11 Copyright (c) 2005-2007 Steven Solie <[email protected]>
12 Copyright (c) 2005-2012 Karl Waclawek <[email protected]>
13 Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>
14 Copyright (c) 2017-2022 Rhodri James <[email protected]>
15 Copyright (c) 2017 Joe Orton <[email protected]>
16 Copyright (c) 2017 José Gutiérrez de la Concha <[email protected]>
17 Copyright (c) 2018 Marco Maggi <[email protected]>
18 Copyright (c) 2019 David Loffredo <[email protected]>
19 Copyright (c) 2020 Tim Gates <[email protected]>
20 Copyright (c) 2021 Donghee Na <[email protected]>
21 Copyright (c) 2023 Sony Corporation / Snild Dolkow <[email protected]>
22 Licensed under the MIT license:
23
24 Permission is hereby granted, free of charge, to any person obtaining
25 a copy of this software and associated documentation files (the
26 "Software"), to deal in the Software without restriction, including
27 without limitation the rights to use, copy, modify, merge, publish,
28 distribute, sublicense, and/or sell copies of the Software, and to permit
29 persons to whom the Software is furnished to do so, subject to the
30 following conditions:
31
32 The above copyright notice and this permission notice shall be included
33 in all copies or substantial portions of the Software.
34
35 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
38 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
39 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
40 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
41 USE OR OTHER DEALINGS IN THE SOFTWARE.
42*/
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#ifndef XML_COMMON_H
49# define XML_COMMON_H
50
51# include "expat_config.h"
52# include "minicheck.h"
53# include "chardata.h"
54
55# ifdef XML_LARGE_SIZE
56# define XML_FMT_INT_MOD "ll"
57# else
58# define XML_FMT_INT_MOD "l"
59# endif
60
61# ifdef XML_UNICODE_WCHAR_T
62# define XML_FMT_STR "ls"
63# include <wchar.h>
64# define xcstrlen(s) wcslen(s)
65# define xcstrcmp(s, t) wcscmp((s), (t))
66# define xcstrncmp(s, t, n) wcsncmp((s), (t), (n))
67# define XCS(s) _XCS(s)
68# define _XCS(s) L##s
69# else
70# ifdef XML_UNICODE
71# error "No support for UTF-16 character without wchar_t in tests"
72# else
73# define XML_FMT_STR "s"
74# define xcstrlen(s) strlen(s)
75# define xcstrcmp(s, t) strcmp((s), (t))
76# define xcstrncmp(s, t, n) strncmp((s), (t), (n))
77# define XCS(s) s
78# endif /* XML_UNICODE */
79# endif /* XML_UNICODE_WCHAR_T */
80
81extern XML_Parser g_parser;
82
85
86extern int g_chunkSize;
87
88extern const char *long_character_data_text;
89extern const char *long_cdata_text;
90extern const char *get_buffer_test_text;
91
94
95extern void basic_teardown(void);
96
97extern void _xml_failure(XML_Parser parser, const char *file, int line);
98
99# define xml_failure(parser) _xml_failure((parser), __FILE__, __LINE__)
100
101extern enum XML_Status _XML_Parse_SINGLE_BYTES(XML_Parser parser, const char *s,
102 int len, int isFinal);
103
104extern void _expect_failure(const char *text, enum XML_Error errorCode,
105 const char *errorMessage, const char *file,
106 int lineno);
107
108# define expect_failure(text, errorCode, errorMessage) \
109 _expect_failure((text), (errorCode), (errorMessage), __FILE__, __LINE__)
110
111/* Support functions for handlers to collect up character and attribute data.
112 */
113
114extern void _run_character_check(const char *text, const XML_Char *expected,
115 const char *file, int line);
116
117# define run_character_check(text, expected) \
118 _run_character_check(text, expected, __FILE__, __LINE__)
119
120extern void _run_attribute_check(const char *text, const XML_Char *expected,
121 const char *file, int line);
122
123# define run_attribute_check(text, expected) \
124 _run_attribute_check(text, expected, __FILE__, __LINE__)
125
131
132extern void _run_ext_character_check(const char *text, ExtTest *test_data,
133 const XML_Char *expected, const char *file,
134 int line);
135
136# define run_ext_character_check(text, test_data, expected) \
137 _run_ext_character_check(text, test_data, expected, __FILE__, __LINE__)
138
139# define ALLOC_ALWAYS_SUCCEED (-1)
140# define REALLOC_ALWAYS_SUCCEED (-1)
141
142extern int g_allocation_count;
143extern int g_reallocation_count;
144
145extern void *duff_allocator(size_t size);
146
147extern void *duff_reallocator(void *ptr, size_t size);
148
149#endif /* XML_COMMON_H */
150
151#ifdef __cplusplus
152}
153#endif
const char apr_size_t len
Definition ap_regex.h:187
void tcase_add_test__if_xml_ge(TCase *tc, tcase_test_function test)
Definition common.c:159
const char * long_cdata_text
Definition common.c:83
void tcase_add_test__ifdef_xml_dtd(TCase *tc, tcase_test_function test)
Definition common.c:149
void basic_teardown(void)
Definition common.c:169
int g_chunkSize
Definition common.c:144
int g_reallocation_count
Definition common.c:276
XML_Parser g_parser
Definition runtests.c:62
enum XML_Status _XML_Parse_SINGLE_BYTES(XML_Parser parser, const char *s, int len, int isFinal)
Definition common.c:193
XML_Bool g_abortable
Definition common.c:141
const char * long_character_data_text
Definition common.c:59
void * duff_reallocator(void *ptr, size_t size)
Definition common.c:290
void _xml_failure(XML_Parser parser, const char *file, int line)
Definition common.c:181
void _run_character_check(const char *text, const XML_Char *expected, const char *file, int line)
Definition common.c:226
void _expect_failure(const char *text, enum XML_Error errorCode, const char *errorMessage, const char *file, int lineno)
Definition common.c:214
void _run_attribute_check(const char *text, const XML_Char *expected, const char *file, int line)
Definition common.c:240
const char * get_buffer_test_text
Definition common.c:112
int g_allocation_count
Definition common.c:275
void * duff_allocator(size_t size)
Definition common.c:280
XML_Bool g_resumable
Definition common.c:138
void _run_ext_character_check(const char *text, ExtTest *test_data, const XML_Char *expected, const char *file, int line)
Definition common.c:254
unsigned char XML_Bool
Definition expat.h:57
XML_Error
Definition expat.h:83
XML_Status
Definition expat.h:74
char XML_Char
apr_text_header const char * text
Definition apr_xml.h:78
apr_xml_parser ** parser
Definition apr_xml.h:228
apr_size_t size
const char apr_file_t * file
const char * s
Definition apr_strings.h:95
void(* tcase_test_function)(void)
Definition minicheck.h:97
const XML_Char * encoding
Definition common.h:128
CharData * storage
Definition common.h:129
const char * parse_text
Definition common.h:127