Skip to content

Commit

Permalink
replaced PRINT_DLERROR with a function and added windows variant
Browse files Browse the repository at this point in the history
  • Loading branch information
lynxlynxlynx committed Oct 19, 2016
1 parent 677e60e commit f31b81a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gemrb/core/PluginLoader.cpp
Expand Up @@ -88,15 +88,20 @@ static inline voidvoid my_dlsym(void *handle, const char *symbol)
#ifdef WIN32
#define FREE_PLUGIN( handle ) FreeLibrary( handle )
#define GET_PLUGIN_SYMBOL( handle, name ) GetProcAddress( handle, name )
#define PRINT_DLERROR
#else
#define FREE_PLUGIN( handle ) dlclose( handle )
#define GET_PLUGIN_SYMBOL( handle, name ) my_dlsym( handle, name )
#define PRINT_DLERROR Log(MESSAGE, "PluginLoader", "Error: %s", dlerror() )
#endif

/** Return names of all *.so or *.dll files in the given directory */
#ifdef WIN32
static void PrintDLError()
{
char buffer[_MAX_PATH*2];
_strerror_s(buffer, NULL);
Log(DEBUG, "PluginLoader", "Error: %s", buffer);
}

static bool FindFiles( char* path, std::list<char*> &files )
{
//The windows _findfirst/_findnext functions allow the use of wildcards so we'll use them :)
Expand All @@ -121,6 +126,11 @@ static bool FindFiles( char* path, std::list<char*> &files )

#else // ! WIN32

static void PrintDLError()
{
Log(DEBUG, "PluginLoader", "Error: %s", dlerror());
}

bool static FindFiles( char* path, std::list<char*> &files )
{
DirectoryIterator dir(path);
Expand Down Expand Up @@ -192,7 +202,7 @@ void LoadPlugins(char* pluginpath)
#endif
if (hMod == NULL) {
Log(ERROR, "PluginLoader", "Cannot Load \"%s\", skipping...", path);
PRINT_DLERROR;
PrintDLError();
continue;
}

Expand Down

0 comments on commit f31b81a

Please sign in to comment.