[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - include/LibreOfficeKit

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 18 08:32:05 UTC 2018


 include/LibreOfficeKit/LibreOfficeKitInit.h |   40 +++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 4 deletions(-)

New commits:
commit 805bf3ffa493180f06512495b407865a4f9a7fe5
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Jul 6 17:41:58 2018 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Jul 18 10:31:43 2018 +0200

    lok: export preinit helper, and share code variously.
    
    Change-Id: I09f2992c4ba45ce91190a9f61dd0fedd0eb8a581
    Reviewed-on: https://gerrit.libreoffice.org/57145
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/57327
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index a0c111a9e0e2..5617a4eaa522 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -17,6 +17,12 @@ extern "C"
 {
 #endif
 
+#if defined __GNUC__ || defined __clang__
+#  define LOK_TOLERATE_UNUSED __attribute__((used))
+#else
+#  define LOK_TOLERATE_UNUSED
+#endif
+
 #if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) ||\
     defined(_WIN32) || defined(__APPLE__) || defined (__NetBSD__) ||\
     defined (__sun) || defined(__OpenBSD__)
@@ -290,15 +296,41 @@ static LibreOfficeKit *lok_init_2( const char *install_path,  const char *user_p
     return pSym2( install_path, user_profile_url );
 }
 
-static
-#if defined __GNUC__ || defined __clang__
-__attribute__((used))
-#endif
+static LOK_TOLERATE_UNUSED
 LibreOfficeKit *lok_init( const char *install_path )
 {
     return lok_init_2( install_path, NULL );
 }
 
+#if !defined(IOS)
+static LOK_TOLERATE_UNUSED
+int lok_preinit( const char *install_path,  const char *user_profile_url )
+{
+    void *dlhandle;
+    char *imp_lib;
+    LokHookPreInit *pSym;
+
+    dlhandle = lok_dlopen(install_path, &imp_lib);
+    if (!dlhandle)
+        return -1;
+
+    pSym = (LokHookPreInit *) lok_dlsym(dlhandle, "lok_preinit");
+    if (!pSym)
+    {
+        fprintf( stderr, "failed to find pre-init hook in library '%s'\n", imp_lib );
+        lok_dlclose( dlhandle );
+        free( imp_lib );
+        return -1;
+    }
+
+    free( imp_lib );
+
+    // dlhandle is "leaked"
+    // coverity[leaked_storage]
+    return pSym( install_path, user_profile_url );
+}
+#endif
+
 #undef SEPARATOR // It is used at least in enum class MenuItemType
 
 #endif // defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || defined(_WIN32) || defined(__APPLE__)


More information about the Libreoffice-commits mailing list