about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedxml2.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-23 15:25:53 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-04-23 15:25:53 +0200
commit66abc0525955dcc2f2f215ff82f30d905c878d4b (patch)
tree83af14a4bad4e859a6131215ad66e0443d8cf5d5 /src/wrapped/wrappedxml2.c
parent5b04c49e7498d9520ea8f4c37c8caf99c65a10dd (diff)
downloadbox64-66abc0525955dcc2f2f215ff82f30d905c878d4b.tar.gz
box64-66abc0525955dcc2f2f215ff82f30d905c878d4b.zip
Added a bunch of wrapped functions (for #725)
Diffstat (limited to 'src/wrapped/wrappedxml2.c')
-rwxr-xr-xsrc/wrapped/wrappedxml2.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/wrapped/wrappedxml2.c b/src/wrapped/wrappedxml2.c
index bcf0391a..e9f8dff8 100755
--- a/src/wrapped/wrappedxml2.c
+++ b/src/wrapped/wrappedxml2.c
@@ -16,6 +16,7 @@
 #include "box64context.h"
 #include "librarian.h"
 #include "callback.h"
+#include "myalign.h"
 
 const char* xml2Name =
 #ifdef ANDROID
@@ -1215,6 +1216,29 @@ static void* find_xmlOutputOpenCallback_Fct(void* fct) // this one have a VAArg
     return NULL;
 }
 
+// xmlTextReaderErrorFunc ...
+#define GO(A)   \
+static uintptr_t my_xmlTextReaderErrorFunc_fct_##A = 0;                         \
+static void my_xmlTextReaderErrorFunc_##A(void* a, void* b, int c, void* d)     \
+{                                                                               \
+    RunFunction(my_context, my_xmlTextReaderErrorFunc_fct_##A, 4, a, b, c, d);  \
+}
+SUPER()
+#undef GO
+static void* find_xmlTextReaderErrorFunc_Fct(void* fct) // this one have a VAArg
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_xmlTextReaderErrorFunc_fct_##A == (uintptr_t)fct) return my_xmlTextReaderErrorFunc_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_xmlTextReaderErrorFunc_fct_##A == 0) {my_xmlTextReaderErrorFunc_fct_##A = (uintptr_t)fct; return my_xmlTextReaderErrorFunc_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for libxml2 xmlTextReaderErrorFunc callback\n");
+    return NULL;
+}
+
 #undef SUPER
 
 EXPORT void* my_xmlHashCopy(x64emu_t* emu, void* table, void* f)
@@ -1438,6 +1462,34 @@ EXPORT int my_xmlRegisterOutputCallbacks(x64emu_t* emu, void* match, void* open,
     return my->xmlRegisterOutputCallbacks(find_xmlOutputMatchCallback_Fct(match), find_xmlOutputOpenCallback_Fct(open), find_xmlOutputWriteCallback_Fct(write), find_xmlOutputCloseCallback_Fct(close));
 }
 
+EXPORT int my_xmlTextWriterWriteVFormatAttribute(x64emu_t* emu, void* writer, void* name, void* fmt, x64_va_list_t b)
+{
+    #ifdef CONVERT_VALIST
+    CONVERT_VALIST(b);
+    #else
+    myStackAlignValist(emu, (const char*)fmt, emu->scratch, b);
+    PREPARE_VALIST;
+    #endif
+    return my->xmlTextWriterWriteVFormatAttribute(writer, name, fmt, VARARGS);
+}
+
+EXPORT int my_xmlTextWriterWriteFormatAttribute(x64emu_t* emu, void* writer, void* name, void* fmt, void* b)
+{
+    myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 2);
+    PREPARE_VALIST;
+    return my->xmlTextWriterWriteVFormatAttribute(writer, name, fmt, VARARGS);
+}
+
+EXPORT void* my_xmlReaderForIO(void *emu, void * ioread, void * ioclose, void * ioctx, char * URL, char * encoding, int  options)
+{
+    return my->xmlReaderForIO(find_xmlInputReadCallback_Fct(ioread), find_xmlInputCloseCallback_Fct(ioclose), ioctx, URL, encoding, options);
+}
+
+EXPORT void my_xmlTextReaderSetErrorHandler(x64emu_t* emu, void* reader, void* f, void* arg)
+{
+    my->xmlTextReaderSetErrorHandler(reader, find_xmlTextReaderErrorFunc_Fct(f), arg);
+}
+
 #define CUSTOM_INIT \
     getMy(lib);