xref: /freebsd/contrib/expat/tests/structdata.h (revision e92ffd9b626833ebdbf2742c8ffddc6cd94b963e)
1 /* Interface to some helper routines used to accumulate and check
2    structured content.
3                             __  __            _
4                          ___\ \/ /_ __   __ _| |_
5                         / _ \\  /| '_ \ / _` | __|
6                        |  __//  \| |_) | (_| | |_
7                         \___/_/\_\ .__/ \__,_|\__|
8                                  |_| XML parser
9 
10    Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
11    Licensed under the MIT license:
12 
13    Permission is  hereby granted,  free of charge,  to any  person obtaining
14    a  copy  of  this  software   and  associated  documentation  files  (the
15    "Software"),  to  deal in  the  Software  without restriction,  including
16    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
17    distribute, sublicense, and/or sell copies of the Software, and to permit
18    persons  to whom  the Software  is  furnished to  do so,  subject to  the
19    following conditions:
20 
21    The above copyright  notice and this permission notice  shall be included
22    in all copies or substantial portions of the Software.
23 
24    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
25    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
26    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
27    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
28    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
29    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
30    USE OR OTHER DEALINGS IN THE SOFTWARE.
31 */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef XML_STRUCTDATA_H
38 #  define XML_STRUCTDATA_H 1
39 
40 #  include "expat.h"
41 
42 typedef struct {
43   const XML_Char *str;
44   int data0;
45   int data1;
46   int data2;
47 } StructDataEntry;
48 
49 typedef struct {
50   int count;     /* Number of entries used */
51   int max_count; /* Number of StructDataEntry items in `entries` */
52   StructDataEntry *entries;
53 } StructData;
54 
55 void StructData_Init(StructData *storage);
56 
57 void StructData_AddItem(StructData *storage, const XML_Char *s, int data0,
58                         int data1, int data2);
59 
60 void StructData_CheckItems(StructData *storage, const StructDataEntry *expected,
61                            int count);
62 
63 void StructData_Dispose(StructData *storage);
64 
65 #endif /* XML_STRUCTDATA_H */
66 
67 #ifdef __cplusplus
68 }
69 #endif
70