aboutsummaryrefslogtreecommitdiff
path: root/libxml2-2.9.10/os400/rpgsupport.c
blob: ad4cc5dddef4a2602a4d45a5b3482b3320b21566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/**
***     Additional procedures for ILE/RPG support.
***
***     See Copyright for the status of this software.
***
***     Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
**/

#include <sys/types.h>

#include <stdarg.h>

#include "libxml/xmlmemory.h"
#include "libxml/xpath.h"
#include "libxml/parser.h"
#include "libxml/HTMLparser.h"

#include "rpgsupport.h"


/**
***     ILE/RPG cannot directly derefence a pointer and has no macros.
***     The following additional procedures supply these functions.
***     In addition, the following code is adjusted for threads control at
***             compile time via the C macros.
**/

#define THREADED_VAR(name, type)                                        \
                type __get_##name(void) { return name; }                \
                void __set_##name(type arg) { name = arg; }


THREADED_VAR(xmlFree, xmlFreeFunc)

void
__call_xmlFree(void * mem)

{
        xmlFree(mem);
}


THREADED_VAR(xmlMalloc, xmlMallocFunc)

void *
__call_xmlMalloc(size_t size)

{
        return xmlMalloc(size);
}


THREADED_VAR(xmlMallocAtomic, xmlMallocFunc)

void *
__call_xmlMallocAtomic(size_t size)

{
        return xmlMallocAtomic(size);
}


THREADED_VAR(xmlRealloc, xmlReallocFunc)

void *
__call_xmlRealloc(void * mem, size_t size)

{
        return xmlRealloc(mem, size);
}


THREADED_VAR(xmlMemStrdup, xmlStrdupFunc)

char *
__call_xmlMemStrdup(const char * str)

{
        return xmlMemStrdup(str);
}


#ifdef LIBXML_DOCB_ENABLED
THREADED_VAR(docbDefaultSAXHandler, xmlSAXHandlerV1)
#endif


#ifdef LIBXML_HTML_ENABLED
THREADED_VAR(htmlDefaultSAXHandler, xmlSAXHandlerV1)
#endif


THREADED_VAR(xmlLastError, xmlError)

THREADED_VAR(oldXMLWDcompatibility, int)
THREADED_VAR(xmlBufferAllocScheme, xmlBufferAllocationScheme)
THREADED_VAR(xmlDefaultBufferSize, int)
THREADED_VAR(xmlDefaultSAXHandler, xmlSAXHandlerV1)
THREADED_VAR(xmlDefaultSAXLocator, xmlSAXLocator)
THREADED_VAR(xmlDoValidityCheckingDefaultValue, int)

/* No caller to xmlGenericError() because the argument list is unknown. */
THREADED_VAR(xmlGenericError, xmlGenericErrorFunc)


THREADED_VAR(xmlStructuredError, xmlStructuredErrorFunc)

void
__call_xmlStructuredError(void * userData, xmlErrorPtr error)

{
        xmlStructuredError(userData, error);
}

THREADED_VAR(xmlGenericErrorContext, void *)
THREADED_VAR(xmlStructuredErrorContext, void *)
THREADED_VAR(xmlGetWarningsDefaultValue, int)
THREADED_VAR(xmlIndentTreeOutput, int)
THREADED_VAR(xmlTreeIndentString, const char *)
THREADED_VAR(xmlKeepBlanksDefaultValue, int)
THREADED_VAR(xmlLineNumbersDefaultValue, int)
THREADED_VAR(xmlLoadExtDtdDefaultValue, int)
THREADED_VAR(xmlParserDebugEntities, int)
THREADED_VAR(xmlParserVersion, const char *)
THREADED_VAR(xmlPedanticParserDefaultValue, int)
THREADED_VAR(xmlSaveNoEmptyTags, int)
THREADED_VAR(xmlSubstituteEntitiesDefaultValue, int)


THREADED_VAR(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc)

void
__call_xmlRegisterNodeDefaultValue(xmlNodePtr node)

{
        xmlRegisterNodeDefaultValue(node);
}


THREADED_VAR(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc)

void
__call_xmlDeregisterNodeDefaultValue(xmlNodePtr node)

{
        xmlDeregisterNodeDefaultValue(node);
}


THREADED_VAR(xmlParserInputBufferCreateFilenameValue, xmlParserInputBufferCreateFilenameFunc)

xmlParserInputBufferPtr
__call_xmlParserInputBufferCreateFilenameValue(const char *URI,
                                                        xmlCharEncoding enc)

{
        return xmlParserInputBufferCreateFilenameValue(URI, enc);
}


THREADED_VAR(xmlOutputBufferCreateFilenameValue, xmlOutputBufferCreateFilenameFunc)

xmlOutputBufferPtr
__call_xmlOutputBufferCreateFilenameValue(const char *URI,
                        xmlCharEncodingHandlerPtr encoder, int compression)

{
        return xmlOutputBufferCreateFilenameValue(URI, encoder, compression);
}



/**
***     va_list support.
**/

void
__xmlVaStart(char * * list, char * lastargaddr, size_t lastargsize)

{
        list[1] = lastargaddr + lastargsize;
}


void *
__xmlVaArg(char * * list, void * dest, size_t argsize)

{
        size_t align;

        if (!argsize)
                return (void *) NULL;

        for (align = 16; align > argsize; align >>= 1)
                ;

        align--;
        list[0] = list[1] + (align - (((size_t) list[0] - 1) & align));
        list[1] = list[0] + argsize;

        if (dest)
                memcpy(dest, list[0], argsize);

        return (void *) list[0];
}


void
__xmlVaEnd(char * * list)

{
        /* Nothing to do. */
}


#ifdef LIBXML_XPATH_ENABLED

int
__xmlXPathNodeSetGetLength(const xmlNodeSet * ns)

{
        return xmlXPathNodeSetGetLength(ns);
}


xmlNodePtr
__xmlXPathNodeSetItem(const xmlNodeSet * ns, int index)

{
        return xmlXPathNodeSetItem(ns, index);
}


int
__xmlXPathNodeSetIsEmpty(const xmlNodeSet * ns)

{
        return xmlXPathNodeSetIsEmpty(ns);
}

#endif


#ifdef LIBXML_HTML_ENABLED

const char *
__htmlDefaultSubelement(const htmlElemDesc * elt)

{
        return htmlDefaultSubelement(elt);
}


int
__htmlElementAllowedHereDesc(const htmlElemDesc * parent,
                                                const htmlElemDesc * elt)

{
        return htmlElementAllowedHereDesc(parent, elt);
}


const char * *
__htmlRequiredAttrs(const htmlElemDesc * elt)

{
        return htmlRequiredAttrs(elt);
}

#endif