summaryrefslogtreecommitdiff
path: root/include/LibreOfficeKit/LibreOfficeKitInit.h
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-04-23 16:40:18 +0300
committerTor Lillqvist <tml@collabora.com>2015-04-23 16:56:31 +0300
commit84537dffd422ee854a0ba5478baca08c1398bb6e (patch)
treefde21c737ab3dd6d1baaccd71e0990ffc7a8f359 /include/LibreOfficeKit/LibreOfficeKitInit.h
parent78c2c450d900c8a57d75377d45463b20d2528875 (diff)
Improve error handling
Change-Id: Id8661cb315f2f3a1bb398bce4f898342d5cce338
Diffstat (limited to 'include/LibreOfficeKit/LibreOfficeKitInit.h')
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitInit.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 4230cd05e071..203fd9f8cf61 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -23,6 +23,8 @@ extern "C"
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
#ifndef _WIN32
#include "dlfcn.h"
#ifdef _AIX
@@ -71,6 +73,8 @@ extern "C"
#else
+ #include <io.h>
+
#include <windows.h>
#define TARGET_LIB "sofficeapp" ".dll"
#define TARGET_MERGED_LIB "mergedlo" ".dll"
@@ -172,13 +176,23 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p
dlhandle = _dlopen(imp_lib);
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);
dlhandle = _dlopen(imp_lib);
if (!dlhandle)
{
- fprintf(stderr, "failed to open library '%s' or '%s' in '%s/': %s\n",
- TARGET_LIB, TARGET_MERGED_LIB, install_path, _dlerror());
+ fprintf(stderr, "failed to open library '%s': %s\n",
+ imp_lib, _dlerror());
free(imp_lib);
return NULL;
}