diff --git a/CMakeLists.txt b/CMakeLists.txt index 62b86ee36f..09b01eb862 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,6 +324,7 @@ set(WRAPPEDS "${BOX86_ROOT}/src/wrapped/wrappedfontconfig.c" "${BOX86_ROOT}/src/wrapped/wrappedfreetype.c" "${BOX86_ROOT}/src/wrapped/wrappedbz2.c" + "${BOX86_ROOT}/src/wrapped/wrappedexpat.c" "${BOX86_ROOT}/src/wrapped/wrappedlibsm.c" "${BOX86_ROOT}/src/wrapped/wrappedlibice.c" "${BOX86_ROOT}/src/wrapped/wrappedlibusb1.c" diff --git a/src/library_list.h b/src/library_list.h index f68ec38caa..3122a4edbe 100755 --- a/src/library_list.h +++ b/src/library_list.h @@ -113,6 +113,7 @@ GO("libnm-glib.so.4", libnm) GO("libnm-util.so.2", libnm) GO("libfontconfig.so.1", fontconfig) GO("libbz2.so.1", bz2) +GO("libexpat.so.1", expat) GO("libSM.so.6", libsm) GO("libICE.so.6", libice) GO("libusb-1.0.so.0", libusb1) diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index d5a7fd760c..11e870928f 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -1977,6 +1977,8 @@ wrappeddbusglib1/SuvFpppp3dbus_g_proxy_disconnect_signal wrappeddbusglib1/SuvFppppp3dbus_g_proxy_connect_signal wrappeddbusglib1/SupFpppppiV3dbus_g_proxy_begin_call wrappeddbusglib1/SupFpppppiiV3dbus_g_proxy_begin_call_with_timeout +wrappedexpat/SuvFpp3XML_SetCharacterDataHandler +wrappedexpat/SuvFppp3XML_SetElementHandler wrappedfontconfig/SuiFppiuui3FcPatternAdd wrappedfontconfig/SuiFppiuui3FcPatternAddWeak wrappedfreetype/SuiFpplp3FT_Open_Face diff --git a/src/wrapped/generated/wrappedexpattypes.h b/src/wrapped/generated/wrappedexpattypes.h new file mode 100644 index 0000000000..c451c6c81f --- /dev/null +++ b/src/wrapped/generated/wrappedexpattypes.h @@ -0,0 +1,21 @@ +/***************************************************************** + * File automatically generated by rebuild_wrappers.py (v1.2.0.09) + *****************************************************************/ +#ifndef __wrappedexpatTYPES_H_ +#define __wrappedexpatTYPES_H_ + +#ifndef LIBNAME +#error You should only #include this file inside a wrapped*.c file +#endif +#ifndef ADDED_FUNCTIONS +#define ADDED_FUNCTIONS() +#endif + +typedef void (*vFpp_t)(void*, void*); +typedef void (*vFppp_t)(void*, void*, void*); + +#define SUPER() ADDED_FUNCTIONS() \ + GO(XML_SetCharacterDataHandler, vFpp_t) \ + GO(XML_SetElementHandler, vFppp_t) + +#endif // __wrappedexpatTYPES_H_ diff --git a/src/wrapped/wrappedexpat.c b/src/wrapped/wrappedexpat.c new file mode 100755 index 0000000000..d86e64beec --- /dev/null +++ b/src/wrapped/wrappedexpat.c @@ -0,0 +1,145 @@ +#include +#include +#include +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include + +#include "wrappedlibs.h" + +#include "debug.h" +#include "wrapper.h" +#include "bridge.h" +#include "librarian/library_private.h" +#include "x86emu.h" +#include "emu/x86emu_private.h" +#include "callback.h" +#include "librarian.h" +#include "box86context.h" +#include "emu/x86emu_private.h" +#include "myalign.h" + +const char* expatName = "libexpat.so.1"; +#define LIBNAME expat +static library_t* my_lib = NULL; + +#include "generated/wrappedexpattypes.h" + +typedef struct expat_my_s { + // functions + #define GO(A, B) B A; + SUPER() + #undef GO +} expat_my_t; + +void* getExpatMy(library_t* lib) +{ + expat_my_t* my = (expat_my_t*)calloc(1, sizeof(expat_my_t)); + #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A); + SUPER() + #undef GO + return my; +} +#undef SUPER + +void freeExpatMy(void* lib) +{ + //expat_my_t *my = (expat_my_t *)lib; +} + +#define SUPER() \ +GO(0) \ +GO(1) \ +GO(2) \ +GO(3) \ +GO(4) + +// Start ... +#define GO(A) \ +static uintptr_t my_Start_fct_##A = 0; \ +static void* my_Start_##A(void* data, void* name, void* attr) \ +{ \ + return (void*)RunFunction(my_context, my_Start_fct_##A, 3, data, name, attr); \ +} +SUPER() +#undef GO +static void* find_Start_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_Start_fct_##A == (uintptr_t)fct) return my_Start_##A; + SUPER() + #undef GO + #define GO(A) if(my_Start_fct_##A == 0) {my_Start_fct_##A = (uintptr_t)fct; return my_Start_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for expat Start callback\n"); + return NULL; +} +// End ... +#define GO(A) \ +static uintptr_t my_End_fct_##A = 0; \ +static void my_End_##A(void* data, void* name) \ +{ \ + RunFunction(my_context, my_End_fct_##A, 2, data, name);\ +} +SUPER() +#undef GO +static void* find_End_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_End_fct_##A == (uintptr_t)fct) return my_End_##A; + SUPER() + #undef GO + #define GO(A) if(my_End_fct_##A == 0) {my_End_fct_##A = (uintptr_t)fct; return my_End_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for expat End callback\n"); + return NULL; +} +// CharData ... +#define GO(A) \ +static uintptr_t my_CharData_fct_##A = 0; \ +static void my_CharData_##A(void* data, void* s, int l) \ +{ \ + RunFunction(my_context, my_CharData_fct_##A, 3, data, s, l);\ +} +SUPER() +#undef GO +static void* find_CharData_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_CharData_fct_##A == (uintptr_t)fct) return my_CharData_##A; + SUPER() + #undef GO + #define GO(A) if(my_CharData_fct_##A == 0) {my_CharData_fct_##A = (uintptr_t)fct; return my_CharData_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for expat CharData callback\n"); + return NULL; +} +#undef SUPER + +EXPORT void my_XML_SetElementHandler(x86emu_t* emu, void* p, void* start, void* end) +{ + expat_my_t *my = (expat_my_t*)my_lib->priv.w.p2; + my->XML_SetElementHandler(p, find_Start_Fct(start), find_End_Fct(end)); +} + +EXPORT void my_XML_SetCharacterDataHandler(x86emu_t* emu, void* p, void* h) +{ + expat_my_t *my = (expat_my_t*)my_lib->priv.w.p2; + my->XML_SetCharacterDataHandler(p, find_CharData_Fct(h)); +} + +#define CUSTOM_INIT \ + lib->priv.w.p2 = getExpatMy(lib); \ + my_lib = lib; + +#define CUSTOM_FINI \ + freeExpatMy(lib->priv.w.p2); \ + free(lib->priv.w.p2); \ + my_lib = NULL; + +#include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedexpat_private.h b/src/wrapped/wrappedexpat_private.h new file mode 100755 index 0000000000..0fe1ba8054 --- /dev/null +++ b/src/wrapped/wrappedexpat_private.h @@ -0,0 +1,71 @@ +#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) +#error meh! +#endif + +//GO(_INTERNAL_trim_to_complete_utf8_characters, +//GO(XML_DefaultCurrent, +GO(XML_ErrorString, pFi) +//GO(XML_ExpatVersion, +//GO(XML_ExpatVersionInfo, +//GO(XML_ExternalEntityParserCreate, +//GO(XML_FreeContentModel, +//GO(XML_GetBase, +//GO(XML_GetBuffer, +//GO(XML_GetCurrentByteCount, +//GO(XML_GetCurrentByteIndex, +//GO(XML_GetCurrentColumnNumber, +GO(XML_GetCurrentLineNumber, iFp) +GO(XML_GetErrorCode, iFp) +//GO(XML_GetFeatureList, +//GO(XML_GetIdAttributeIndex, +//GO(XML_GetInputContext, +//GO(XML_GetParsingStatus, +//GO(XML_GetSpecifiedAttributeCount, +//GO(XML_MemFree, +//GO(XML_MemMalloc, +//GO(XML_MemRealloc, +GO(XML_Parse, iFppii) +//GO(XML_ParseBuffer, +GO(XML_ParserCreate, pFp) +//GO(XML_ParserCreate_MM, +//GO(XML_ParserCreateNS, +GO(XML_ParserFree, vFp) +//GO(XML_ParserReset, +//GO(XML_ResumeParser, +//GO(XML_SetAttlistDeclHandler, +//GO(XML_SetBase, +//GO(XML_SetCdataSectionHandler, +GOM(XML_SetCharacterDataHandler, vFEpp) +//GO(XML_SetCommentHandler, +//GO(XML_SetDefaultHandler, +//GO(XML_SetDefaultHandlerExpand, +//GO(XML_SetDoctypeDeclHandler, +//GO(XML_SetElementDeclHandler, +GOM(XML_SetElementHandler, vFEppp) +//GO(XML_SetEncoding, +//GO(XML_SetEndCdataSectionHandler, +//GO(XML_SetEndDoctypeDeclHandler, +//GO(XML_SetEndElementHandler, +//GO(XML_SetEndNamespaceDeclHandler, +//GO(XML_SetEntityDeclHandler, +//GO(XML_SetExternalEntityRefHandler, +//GO(XML_SetExternalEntityRefHandlerArg, +//GO(XML_SetHashSalt, +//GO(XML_SetNamespaceDeclHandler, +//GO(XML_SetNotationDeclHandler, +//GO(XML_SetNotStandaloneHandler, +//GO(XML_SetParamEntityParsing, +//GO(XML_SetProcessingInstructionHandler, +//GO(XML_SetReturnNSTriplet, +//GO(XML_SetSkippedEntityHandler, +//GO(XML_SetStartCdataSectionHandler, +//GO(XML_SetStartDoctypeDeclHandler, +//GO(XML_SetStartElementHandler, +//GO(XML_SetStartNamespaceDeclHandler, +//GO(XML_SetUnknownEncodingHandler, +//GO(XML_SetUnparsedEntityDeclHandler, +GO(XML_SetUserData, vFpp) +//GO(XML_SetXmlDeclHandler, +//GO(XML_StopParser, +//GO(XML_UseForeignDTD, +//GO(XML_UseParserAsHandlerArg,