+
+ return ext;
+}
+
+/* static */
+wxDllType
+wxDllLoader::GetProgramHandle(void)
+{
+#if defined( HAVE_DLOPEN ) && !defined(__EMX__)
+ // optain handle for main program
+ return dlopen(NULL, RTLD_NOW/*RTLD_LAZY*/);
+#elif defined (HAVE_SHL_LOAD)
+ // shl_findsymbol with NULL handle looks up in main program
+ return 0;
+#else
+ wxFAIL_MSG( wxT("This method is not implemented under Windows or OS/2"));
+ return 0;
+#endif
+}
+
+/* static */
+wxDllType
+wxDllLoader::LoadLibrary(const wxString & libname, bool *success)
+{
+ wxDllType handle;
+
+#if defined(__WXMAC__) && !defined(__UNIX__)
+ FSSpec myFSSpec ;
+ Ptr myMainAddr ;
+ Str255 myErrName ;
+
+ wxMacFilename2FSSpec( libname , &myFSSpec ) ;
+ if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
+ myErrName ) != noErr )
+ {
+ p2cstr( myErrName ) ;
+ wxLogSysError( _("Failed to load shared library '%s' Error '%s'") , libname.c_str() , (char*)myErrName ) ;
+ handle = NULL ;
+ }
+#elif defined(__WXPM__) || defined(__EMX__)
+ char zError[256] = "";
+ wxDllOpen(zError, libname, handle);
+#else // !Mac
+ handle = wxDllOpen(libname);
+#endif // OS
+
+ if ( !handle )
+ {
+ wxString msg(_("Failed to load shared library '%s'"));
+
+#ifdef HAVE_DLERROR
+ const char *errmsg = dlerror();
+ if ( errmsg )
+ {
+ // the error string format is "libname: ...", but we already have
+ // libname, so cut it off
+ const char *p = strchr(errmsg, ':');
+ if ( p )
+ {
+ if ( *++p == ' ' )
+ p++;
+ }
+ else
+ {
+ p = errmsg;
+ }
+
+ msg += _T(" (%s)");
+ wxLogError(msg, libname.c_str(), p);
+ }
+ else
+#endif // HAVE_DLERROR
+ {
+ wxLogSysError(msg, libname.c_str());
+ }
+ }
+
+ if ( success )
+ {
+ *success = handle != 0;
+ }
+
+ return handle;
+}
+
+
+/* static */
+void
+wxDllLoader::UnloadLibrary(wxDllType handle)
+{
+ wxDllClose(handle);
+}
+
+/* static */
+void *
+wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name)
+{
+ void *symbol = NULL; // return value
+
+#if defined(__WXMAC__) && !defined(__UNIX__)
+ Ptr symAddress ;
+ CFragSymbolClass symClass ;
+ Str255 symName ;
+
+#if TARGET_CARBON
+ c2pstrcpy( (StringPtr) symName , name ) ;
+#else
+ strcpy( (char *) symName , name ) ;
+ c2pstr( (char *) symName ) ;
+#endif
+
+ if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
+ symbol = (void *)symAddress ;
+#elif defined( __WXPM__ ) || defined(__EMX__)
+ wxDllGetSymbol(dllHandle, symbol);
+#else
+ // mb_str() is necessary in Unicode build
+ symbol = wxDllGetSymbol(dllHandle, name.mb_str());
+#endif
+
+ if ( !symbol )
+ {
+ wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
+ name.c_str());
+ }
+ return symbol;