@@ -63,6 +63,9 @@ FRAMEWORK_EXPORT PlatformShim* get_platform_shim(std::vector<fs::FolderManager>*
6363#if defined(HAVE___SECURE_GETENV)
6464#define __SECURE_GETENV_FUNC_NAME __secure_getenv
6565#endif
66+ #define PRINTF_FUNC_NAME printf
67+ #define FPUTS_FUNC_NAME fputs
68+ #define FPUTC_FUNC_NAME fputc
6669#elif defined(__APPLE__)
6770#define OPENDIR_FUNC_NAME my_opendir
6871#define READDIR_FUNC_NAME my_readdir
@@ -80,6 +83,8 @@ FRAMEWORK_EXPORT PlatformShim* get_platform_shim(std::vector<fs::FolderManager>*
8083#define __SECURE_GETENV_FUNC_NAME my__secure_getenv
8184#endif
8285#endif
86+ #define FPUTS_FUNC_NAME my_fputs
87+ #define FPUTC_FUNC_NAME my_fputc
8388#endif
8489
8590using PFN_OPENDIR = DIR* (*)(const char * path_name);
@@ -93,6 +98,8 @@ using PFN_GETEGID = gid_t (*)(void);
9398#if defined(HAVE_SECURE_GETENV) || defined(HAVE___SECURE_GETENV)
9499using PFN_SEC_GETENV = char * (*)(const char * name);
95100#endif
101+ using PFN_FPUTS = int (*)(const char * str, FILE* stream);
102+ using PFN_FPUTC = int (*)(int c, FILE* stream);
96103
97104#if defined(__APPLE__)
98105#define real_opendir opendir
@@ -109,6 +116,8 @@ using PFN_SEC_GETENV = char* (*)(const char* name);
109116#if defined(HAVE___SECURE_GETENV)
110117#define real__secure_getenv __secure_getenv
111118#endif
119+ #define real_fputs fputs
120+ #define real_fputc fputc
112121#else
113122PFN_OPENDIR real_opendir = nullptr ;
114123PFN_READDIR real_readdir = nullptr ;
@@ -124,6 +133,8 @@ PFN_SEC_GETENV real_secure_getenv = nullptr;
124133#if defined(HAVE___SECURE_GETENV)
125134PFN_SEC_GETENV real__secure_getenv = nullptr ;
126135#endif
136+ PFN_FPUTS real_fputs = nullptr ;
137+ PFN_FPUTC real_fputc = nullptr ;
127138#endif
128139
129140FRAMEWORK_EXPORT DIR* OPENDIR_FUNC_NAME (const char * path_name) {
@@ -327,6 +338,27 @@ FRAMEWORK_EXPORT char* __SECURE_GETENV_FUNC_NAME(const char* name) {
327338}
328339#endif
329340#endif
341+
342+ FRAMEWORK_EXPORT int FPUTS_FUNC_NAME (const char * str, FILE* stream) {
343+ #if !defined(__APPLE__)
344+ if (!real_fputs) real_fputs = (PFN_FPUTS)dlsym (RTLD_NEXT, " fputs" );
345+ #endif
346+ if (stream == stderr) {
347+ platform_shim.fputs_stderr_log += str;
348+ }
349+ return real_fputs (str, stream);
350+ }
351+
352+ FRAMEWORK_EXPORT int FPUTC_FUNC_NAME (int ch, FILE* stream) {
353+ #if !defined(__APPLE__)
354+ if (!real_fputc) real_fputc = (PFN_FPUTC)dlsym (RTLD_NEXT, " fputc" );
355+ #endif
356+ if (stream == stderr) {
357+ platform_shim.fputs_stderr_log += ch;
358+ }
359+ return real_fputc (ch, stream);
360+ }
361+
330362#if defined(__APPLE__)
331363FRAMEWORK_EXPORT CFBundleRef my_CFBundleGetMainBundle () {
332364 static CFBundleRef global_bundle{};
@@ -383,6 +415,8 @@ __attribute__((used)) static Interposer _interpose__secure_getenv MACOS_ATTRIB =
383415 VOIDP_CAST (__secure_getenv)};
384416#endif
385417#endif
418+ __attribute__ ((used)) static Interposer _interpose_fputs MACOS_ATTRIB = {VOIDP_CAST (my_fputs), VOIDP_CAST (fputs)};
419+ __attribute__ ((used)) static Interposer _interpose_fputc MACOS_ATTRIB = {VOIDP_CAST (my_fputc), VOIDP_CAST (fputc)};
386420__attribute__ ((used)) static Interposer _interpose_CFBundleGetMainBundle MACOS_ATTRIB = {VOIDP_CAST (my_CFBundleGetMainBundle),
387421 VOIDP_CAST (CFBundleGetMainBundle)};
388422__attribute__ ((used)) static Interposer _interpose_CFBundleCopyResourcesDirectoryURL MACOS_ATTRIB = {
0 commit comments