comparison Sources/Plugin.cpp @ 47:42de8b600c0c

Support of Apple OS X
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Aug 2020 15:32:49 +0200
parents fd58eb5749ed
children 70abe3ebbbfc
comparison
equal deleted inserted replaced
46:3e2ff3616e57 47:42de8b600c0c
34 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" 34 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
35 35
36 #include <boost/algorithm/string/predicate.hpp> 36 #include <boost/algorithm/string/predicate.hpp>
37 #include <boost/filesystem.hpp> 37 #include <boost/filesystem.hpp>
38 38
39 #if !defined(_WIN32) 39
40 # include <dlfcn.h> 40 // The "dl_iterate_phdr()" function (to walk through shared libraries)
41 // is not available on Microsoft Windows and Apple OS X
42 #if defined(_WIN32)
43 # define HAS_DL_ITERATE 0
44 #elif defined(__APPLE__) && defined(__MACH__)
45 # define HAS_DL_ITERATE 0
46 #else
47 # define HAS_DL_ITERATE 1
41 #endif 48 #endif
42 49
43 50
44 51
45 static bool pythonEnabled_ = false; 52 static bool pythonEnabled_ = false;
118 } 125 }
119 } 126 }
120 127
121 128
122 129
123 130 #if HAS_DL_ITERATE == 1
124 131
125 #if !defined(_WIN32) 132 #include <dlfcn.h>
126
127 #include <link.h> // For dl_phdr_info 133 #include <link.h> // For dl_phdr_info
128 134
129 static int ForceImportCallback(struct dl_phdr_info *info, size_t size, void *data) 135 static int ForceImportCallback(struct dl_phdr_info *info, size_t size, void *data)
130 { 136 {
131 /** 137 /**
231 237
232 /** 238 /**
233 * Initialization of Python 239 * Initialization of Python
234 **/ 240 **/
235 241
236 #if !defined(_WIN32) 242 #if HAS_DL_ITERATE == 1
237 dl_iterate_phdr(ForceImportCallback, NULL); 243 dl_iterate_phdr(ForceImportCallback, NULL);
238 #endif 244 #endif
239 245
240 SetupGlobalFunctions(); 246 SetupGlobalFunctions();
241 PythonLock::GlobalInitialize("orthanc", "Exception", 247 PythonLock::GlobalInitialize("orthanc", "Exception",