Kaydet (Commit) 84537dff authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Improve error handling

Change-Id: Id8661cb315f2f3a1bb398bce4f898342d5cce338
üst 78c2c450
...@@ -23,6 +23,8 @@ extern "C" ...@@ -23,6 +23,8 @@ extern "C"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#ifndef _WIN32 #ifndef _WIN32
#include "dlfcn.h" #include "dlfcn.h"
#ifdef _AIX #ifdef _AIX
...@@ -71,6 +73,8 @@ extern "C" ...@@ -71,6 +73,8 @@ extern "C"
#else #else
#include <io.h>
#include <windows.h> #include <windows.h>
#define TARGET_LIB "sofficeapp" ".dll" #define TARGET_LIB "sofficeapp" ".dll"
#define TARGET_MERGED_LIB "mergedlo" ".dll" #define TARGET_MERGED_LIB "mergedlo" ".dll"
...@@ -172,13 +176,23 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p ...@@ -172,13 +176,23 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p
dlhandle = _dlopen(imp_lib); dlhandle = _dlopen(imp_lib);
if (!dlhandle) if (!dlhandle)
{ {
// If TARGET_LIB exists, but dlopen failed for some reason,
// don't try TARGET_MERGED_LIB.
if (access(imp_lib, F_OK) == 0)
{
fprintf(stderr, "failed to open library '%s': %s\n",
imp_lib, _dlerror());
free(imp_lib);
return NULL;
}
strcpy(imp_lib + partial_length, TARGET_MERGED_LIB); strcpy(imp_lib + partial_length, TARGET_MERGED_LIB);
dlhandle = _dlopen(imp_lib); dlhandle = _dlopen(imp_lib);
if (!dlhandle) if (!dlhandle)
{ {
fprintf(stderr, "failed to open library '%s' or '%s' in '%s/': %s\n", fprintf(stderr, "failed to open library '%s': %s\n",
TARGET_LIB, TARGET_MERGED_LIB, install_path, _dlerror()); imp_lib, _dlerror());
free(imp_lib); free(imp_lib);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment