2 ** Copyright (c) 2001-2009 Expat maintainers.
4 ** Permission is hereby granted, free of charge, to any person obtaining
5 ** a copy of this software and associated documentation files (the
6 ** "Software"), to deal in the Software without restriction, including
7 ** without limitation the rights to use, copy, modify, merge, publish,
8 ** distribute, sublicense, and/or sell copies of the Software, and to
9 ** permit persons to whom the Software is furnished to do so, subject to
10 ** the following conditions:
12 ** The above copyright notice and this permission notice shall be included
13 ** in all copies or substantial portions of the Software.
15 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "expat_68k.h"
29 #include <exec/emulation.h>
30 #include <proto/exec.h>
33 static uint32 VARARGS68K
call_68k_code (struct ExecIFace
*IExec
, void *code
, int num_args
, ...) {
37 va_startlinear(vargs
, num_args
);
38 uint32
*args
= va_getlinearva(vargs
, uint32
*);
40 uint8
*stack
= IExec
->AllocVec(4096, MEMF_SHARED
);
42 uint32
*sp
= (uint32
*)(stack
+ 4096);
48 res
= IExec
->EmulateTags(code
, ET_StackPtr
, sp
, TAG_END
);
49 IExec
->FreeVec(stack
);
57 void _68k_startelementhandler(void *userdata
, const char *name
, const char **attrs
) {
58 M68kXML_Parser p
= userdata
;
59 call_68k_code(p
->IExec
, p
->startelementhandler
, 3, p
->handlerarg
, name
, attrs
);
62 void _68k_endelementhandler(void *userdata
, const char *name
) {
63 M68kXML_Parser p
= userdata
;
64 call_68k_code(p
->IExec
, p
->endelementhandler
, 2, p
->handlerarg
, name
);
67 void _68k_chardatahandler(void *userdata
, const char *s
, int len
) {
68 M68kXML_Parser p
= userdata
;
69 call_68k_code(p
->IExec
, p
->chardatahandler
, 3, p
->handlerarg
, s
, len
);
72 void _68k_procinsthandler(void *userdata
, const char *target
, const char *data
) {
73 M68kXML_Parser p
= userdata
;
74 call_68k_code(p
->IExec
, p
->procinsthandler
, 3, p
->handlerarg
, target
, data
);
77 void _68k_commenthandler(void *userdata
, const char *data
) {
78 M68kXML_Parser p
= userdata
;
79 call_68k_code(p
->IExec
, p
->commenthandler
, 2, p
->handlerarg
, data
);
82 void _68k_startcdatahandler(void *userdata
) {
83 M68kXML_Parser p
= userdata
;
84 call_68k_code(p
->IExec
, p
->startcdatahandler
, 1, p
->handlerarg
);
87 void _68k_endcdatahandler(void *userdata
) {
88 M68kXML_Parser p
= userdata
;
89 call_68k_code(p
->IExec
, p
->endcdatahandler
, 1, p
->handlerarg
);
92 void _68k_defaulthandler(void *userdata
, const char *s
, int len
) {
93 M68kXML_Parser p
= userdata
;
94 call_68k_code(p
->IExec
, p
->defaulthandler
, 3, p
->handlerarg
, s
, len
);
97 void _68k_defaulthandlerexp(void *userdata
, const char *s
, int len
) {
98 M68kXML_Parser p
= userdata
;
99 call_68k_code(p
->IExec
, p
->defaulthandlerexp
, 3, p
->handlerarg
, s
, len
);
102 int _68k_extentrefhandler(XML_Parser parser
, const char *context
, const char *base
,
103 const char *sysid
, const char *pubid
)
105 M68kXML_Parser p
= XML_GetUserData(parser
);
106 void *arg
= p
->extenthandlerarg
;
107 return (int)call_68k_code(p
->IExec
, p
->extentrefhandler
, 5, arg
? arg
: p
, context
, base
, sysid
, pubid
);
110 int _68k_unknownenchandler(void *enchandlerdata
, const char *name
, XML_Encoding
*info
) {
111 M68kXML_Parser p
= enchandlerdata
;
112 return (int)call_68k_code(p
->IExec
, p
->unknownenchandler
, 3, p
->enchandlerarg
, name
, info
);
115 void _68k_startnamespacehandler(void *userdata
, const char *prefix
, const char *uri
) {
116 M68kXML_Parser p
= userdata
;
117 call_68k_code(p
->IExec
, p
->startnamespacehandler
, 3, p
->handlerarg
, prefix
, uri
);
120 void _68k_endnamespacehandler(void *userdata
, const char *prefix
) {
121 M68kXML_Parser p
= userdata
;
122 call_68k_code(p
->IExec
, p
->endnamespacehandler
, 2, p
->handlerarg
, prefix
);
125 void _68k_xmldeclhandler(void *userdata
, const char *version
, const char *encoding
, int standalone
) {
126 M68kXML_Parser p
= userdata
;
127 call_68k_code(p
->IExec
, p
->xmldeclhandler
, 4, p
->handlerarg
, version
, encoding
, standalone
);
130 void _68k_startdoctypehandler(void *userdata
, const char *doctypename
,
131 const char *sysid
, const char *pubid
, int has_internal_subset
)
133 M68kXML_Parser p
= userdata
;
134 call_68k_code(p
->IExec
, p
->startdoctypehandler
, 5, p
->handlerarg
, doctypename
, sysid
, pubid
, has_internal_subset
);
137 void _68k_enddoctypehandler(void *userdata
) {
138 M68kXML_Parser p
= userdata
;
139 call_68k_code(p
->IExec
, p
->enddoctypehandler
, 1, p
->handlerarg
);
142 void _68k_elementdeclhandler(void *userdata
, const char *name
, XML_Content
*model
) {
143 M68kXML_Parser p
= userdata
;
144 call_68k_code(p
->IExec
, p
->elementdeclhandler
, 3, p
->handlerarg
, name
, model
);
147 void _68k_attlistdeclhandler(void *userdata
, const char *elname
, const char *attname
,
148 const char *att_type
, const char *dflt
, int isrequired
)
150 M68kXML_Parser p
= userdata
;
151 call_68k_code(p
->IExec
, p
->attlistdeclhandler
, 6, p
->handlerarg
, elname
, attname
, att_type
, dflt
, isrequired
);
154 void _68k_entitydeclhandler(void *userdata
, const char *entityname
, int is_param_entity
,
155 const char *value
, int value_length
, const char *base
, const char *sysid
, const char *pubid
,
156 const char *notationname
)
158 M68kXML_Parser p
= userdata
;
159 call_68k_code(p
->IExec
, p
->entitydeclhandler
, 9, p
->handlerarg
, entityname
, is_param_entity
,
160 value
, value_length
, base
, sysid
, pubid
, notationname
);
163 void _68k_unparseddeclhandler(void *userdata
, const char *entityname
, const char *base
,
164 const char *sysid
, const char *pubid
, const char *notationname
)
166 M68kXML_Parser p
= userdata
;
167 call_68k_code(p
->IExec
, p
->unparseddeclhandler
, 6, p
->handlerarg
, entityname
, base
, sysid
, pubid
, notationname
);
170 void _68k_notationdeclhandler(void *userdata
, const char *notationname
, const char *base
,
171 const char *sysid
, const char *pubid
)
173 M68kXML_Parser p
= userdata
;
174 call_68k_code(p
->IExec
, p
->notationdeclhandler
, 5, p
->handlerarg
, notationname
, base
, sysid
, pubid
);
177 int _68k_notstandalonehandler(void *userdata
) {
178 M68kXML_Parser p
= userdata
;
179 return (int)call_68k_code(p
->IExec
, p
->notstandalonehandler
, 1, p
->handlerarg
);
182 void _68k_skippedentityhandler(void *userdata
, const char *entityname
, int is_param_entity
) {
183 M68kXML_Parser p
= userdata
;
184 call_68k_code(p
->IExec
, p
->skippedentityhandler
, 3, p
->handlerarg
, entityname
, is_param_entity
);