From 32e648c9663d61c13c8480ee4d6612df8c804a91 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Thu, 4 Jun 2026 07:57:12 -0700 Subject: [PATCH] target: add startup and plugin hooks Add narrow target hooks for early startup handling and plugin lookup. Unix needs these integration points for Qt startup commands and local plugin discovery without embedding Unix paths in common code. --- dlopen.cpp | 14 +++++++++----- include/target_dlopen.h | 10 ++++++++++ include/target_main.h | 13 +++++++++++++ main.cpp | 5 +++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 include/target_dlopen.h create mode 100644 include/target_main.h diff --git a/dlopen.cpp b/dlopen.cpp index ed04fc3e..b83be9dc 100644 --- a/dlopen.cpp +++ b/dlopen.cpp @@ -3,6 +3,7 @@ #include "uae/api.h" #include "uae/dlopen.h" #include "uae/log.h" +#include "target_dlopen.h" #ifdef _WIN32 #include "windows.h" @@ -76,13 +77,16 @@ UAE_DLHANDLE uae_dlopen_plugin(const TCHAR *name) _tcscat(path, LT_MODULE_EXT); UAE_DLHANDLE handle = WIN32_LoadLibrary(path); #else - TCHAR path[MAX_DPATH]; - _tcscpy(path, name); + TCHAR path[MAX_DPATH] = { 0 }; + UAE_DLHANDLE handle; + if (!target_dlopen_plugin(name, path, MAX_DPATH, &handle)) { + _tcscpy(path, name); #ifdef _WIN64 - _tcscat(path, _T("_x64")); + _tcscat(path, _T("_x64")); #endif - _tcscat(path, LT_MODULE_EXT); - UAE_DLHANDLE handle = uae_dlopen(path); + _tcscat(path, LT_MODULE_EXT); + handle = uae_dlopen(path); + } #endif if (handle) { write_log(_T("DLOPEN: Loaded plugin %s\n"), path); diff --git a/include/target_dlopen.h b/include/target_dlopen.h new file mode 100644 index 00000000..23fffb39 --- /dev/null +++ b/include/target_dlopen.h @@ -0,0 +1,10 @@ +#ifndef UAE_TARGET_DLOPEN_H +#define UAE_TARGET_DLOPEN_H + +static inline bool target_dlopen_plugin(const TCHAR *, TCHAR *, size_t, + UAE_DLHANDLE *) +{ + return false; +} + +#endif /* UAE_TARGET_DLOPEN_H */ diff --git a/include/target_main.h b/include/target_main.h new file mode 100644 index 00000000..2e2a1e72 --- /dev/null +++ b/include/target_main.h @@ -0,0 +1,13 @@ +#ifndef UAE_TARGET_MAIN_H +#define UAE_TARGET_MAIN_H + +static inline void target_main_set_args(int, TCHAR **) +{ +} + +static inline int target_main_handle_early(int, TCHAR **) +{ + return -1; +} + +#endif /* UAE_TARGET_MAIN_H */ diff --git a/main.cpp b/main.cpp index fc73b2d9..c207c593 100644 --- a/main.cpp +++ b/main.cpp @@ -28,6 +28,7 @@ #include "inputdevice.h" #include "keybuf.h" #include "gui.h" +#include "target_main.h" #include "zfile.h" #include "autoconf.h" #include "native2amiga.h" @@ -1340,6 +1341,10 @@ void real_main (int argc, TCHAR **argv) #ifndef NO_MAIN_IN_MAIN_C int main (int argc, TCHAR **argv) { + target_main_set_args(argc, argv); + const int early_exit = target_main_handle_early(argc, argv); + if (early_exit >= 0) + return early_exit; real_main (argc, argv); return 0; } -- 2.47.3