libopc
helper.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, Florian Reuter
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15  * Neither the name of Florian Reuter nor the names of its contributors
16  may be used to endorse or promote products derived from this
17  software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30  OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
39 #include <mce/config.h>
40 
41 #ifndef MCE_HELPER_H
42 #define MCE_HELPER_H
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
51  typedef struct MCE_QNAME_LEVEL {
52  xmlChar *ns;
53  xmlChar *ln;
54  puint32_t level;
55  puint32_t flag; // used by mceTextWriter
57 
60  typedef enum MCE_SKIP_STATE_ENUM {
61  MCE_SKIP_STATE_IGNORE,
62  MCE_SKIP_STATE_ALTERNATE_CONTENT,
63  MCE_SKIP_STATE_CHOICE_MATCHED
64  } mceSkipState_t;
65 
69  typedef struct MCE_SKIP_ITEM {
70  puint32_t level_start;
71  puint32_t level_end;
72  mceSkipState_t state;
73  } mceSkipItem_t;
74 
78  typedef struct MCE_QNAME_LEVEL_SET {
79  mceQNameLevel_t *list_array;
80  puint32_t list_items;
81  puint32_t max_level;
83 
87  typedef struct MCE_SKIP_STACK {
88  mceSkipItem_t *stack_array;
89  puint32_t stack_items;
91 
92 
93  typedef enum MCE_ERROR_ENUM {
94  MCE_ERROR_NONE,
95  MCE_ERROR_XML,
96  MCE_ERROR_MUST_UNDERSTAND,
97  MCE_ERROR_VALIDATION,
98  MCE_ERROR_MEMORY
99  } mceError_t;
100 
104  typedef struct MCE_CONTEXT {
105  mceQNameLevelSet_t ignorable_set;
106  mceQNameLevelSet_t understands_set;
107  mceQNameLevelSet_t processcontent_set;
108  mceQNameLevelSet_t suspended_set;
109 #if (MCE_NAMESPACE_SUBSUMPTION_ENABLED)
110  mceQNameLevelSet_t subsume_namespace_set;
111  mceQNameLevelSet_t subsume_exclude_set;
112  mceQNameLevelSet_t subsume_prefix_set;
113 #endif
114  mceSkipStack_t skip_stack;
115  mceError_t error;
116  pbool_t mce_disabled;
117  puint32_t suspended_level;
118  } mceCtx_t;
119 
124  pbool_t mceQNameLevelAdd(mceQNameLevelSet_t *qname_level_set, const xmlChar *ns, const xmlChar *ln, puint32_t level);
125 
129  mceQNameLevel_t* mceQNameLevelLookup(mceQNameLevelSet_t *qname_level_set, const xmlChar *ns, const xmlChar *ln, pbool_t ignore_ln);
130 
134  pbool_t mceQNameLevelCleanup(mceQNameLevelSet_t *qname_level_set, puint32_t level);
135 
139  pbool_t mceSkipStackPush(mceSkipStack_t *skip_stack, puint32_t level_start, puint32_t level_end, mceSkipState_t state);
140 
144  void mceSkipStackPop(mceSkipStack_t *skip_stack);
145 
150 
154  pbool_t mceSkipStackSkip(mceSkipStack_t *skip_stack, puint32_t level);
155 
159  pbool_t mceCtxInit(mceCtx_t *ctx);
160 
164  pbool_t mceCtxCleanup(mceCtx_t *ctx);
165 
169  pbool_t mceCtxUnderstandsNamespace(mceCtx_t *ctx, const xmlChar *ns);
170 
174  pbool_t mceCtxSuspendProcessing(mceCtx_t *ctx, const xmlChar *ns, const xmlChar *ln);
175 
176 
177 
178 #if (MCE_NAMESPACE_SUBSUMPTION_ENABLED)
179 
182  pbool_t mceCtxSubsumeNamespace(mceCtx_t *ctx, const xmlChar *prefix_new, const xmlChar *ns_new, const xmlChar *ns_old);
183 #endif
184 
185 #ifdef __cplusplus
186 } /* extern "C" */
187 #endif
188 
189 #endif /* MCE_HELPER_H */
pbool_t mceCtxSuspendProcessing(mceCtx_t *ctx, const xmlChar *ns, const xmlChar *ln)
Definition: helper.c:143
struct MCE_SKIP_ITEM mceSkipItem_t
struct MCE_CONTEXT mceCtx_t
pbool_t mceSkipStackPush(mceSkipStack_t *skip_stack, puint32_t level_start, puint32_t level_end, mceSkipState_t state)
Definition: helper.c:73
Definition: helper.h:69
Definition: helper.h:104
pbool_t mceCtxCleanup(mceCtx_t *ctx)
Definition: helper.c:109
Definition: helper.h:87
struct MCE_QNAME_LEVEL_SET mceQNameLevelSet_t
pbool_t mceCtxInit(mceCtx_t *ctx)
Definition: helper.c:103
struct MCE_QNAME_LEVEL mceQNameLevel_t
mceQNameLevel_t * mceQNameLevelLookup(mceQNameLevelSet_t *qname_level_set, const xmlChar *ns, const xmlChar *ln, pbool_t ignore_ln)
Definition: helper.c:20
Definition: helper.h:78
Definition: helper.h:51
void mceSkipStackPop(mceSkipStack_t *skip_stack)
Definition: helper.c:88
pbool_t mceSkipStackSkip(mceSkipStack_t *skip_stack, puint32_t level)
Definition: helper.c:97
pbool_t mceQNameLevelAdd(mceQNameLevelSet_t *qname_level_set, const xmlChar *ns, const xmlChar *ln, puint32_t level)
Definition: helper.c:25
struct MCE_SKIP_STACK mceSkipStack_t
pbool_t mceQNameLevelCleanup(mceQNameLevelSet_t *qname_level_set, puint32_t level)
Definition: helper.c:50
pbool_t mceCtxUnderstandsNamespace(mceCtx_t *ctx, const xmlChar *ns)
Definition: helper.c:139
mceSkipItem_t * mceSkipStackTop(mceSkipStack_t *skip_stack)
Definition: helper.c:93