tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / sal / osl / unx / system.cxx
blob19c32226df2f0c95a061fcedac6b26fe8ef724ab
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <unistd.h>
21 #include <string.h>
23 #include <config_features.h>
25 #include "system.hxx"
27 #ifdef NO_PTHREAD_RTL
29 #if defined(MACOSX)
31 #include <premac.h>
32 #include <Foundation/Foundation.h>
33 #include <postmac.h>
36 * Add support for resolving Mac native alias files (not the same as unix alias files)
37 * (what are "unix alias files"?)
38 * returns 0 on success.
40 int macxp_resolveAlias(char *path, int buflen)
42 #if HAVE_FEATURE_MACOSX_SANDBOX
43 /* Avoid unnecessary messages in the system.log:
45 * soffice(57342) deny file-read-data /Users/tml/Documents/b.odt/..namedfork/rsrc
46 * etc.
48 * Just don't bother with resolving aliases. I doubt its usefulness anyway.
50 (void) path;
51 (void) buflen;
52 return 0;
53 #else
54 CFStringRef cfpath;
55 CFURLRef cfurl;
56 CFErrorRef cferror;
57 CFDataRef cfbookmark;
59 // Don't even try anything for files inside the app bundle. Just a
60 // waste of time.
62 static const char * const appBundle = [[[NSBundle mainBundle] bundlePath] UTF8String];
64 const size_t appBundleLen = strlen(appBundle);
65 if (strncmp(path, appBundle, appBundleLen) == 0 && path[appBundleLen] == '/')
66 return 0;
68 char *unprocessedPath = path;
70 if ( *unprocessedPath == '/' )
71 unprocessedPath++;
73 int nRet = 0;
74 while ( !nRet && unprocessedPath && *unprocessedPath )
76 unprocessedPath = strchr( unprocessedPath, '/' );
77 if ( unprocessedPath )
78 *unprocessedPath = '\0';
80 cfpath = CFStringCreateWithCString( nullptr, path, kCFStringEncodingUTF8 );
81 cfurl = CFURLCreateWithFileSystemPath( nullptr, cfpath, kCFURLPOSIXPathStyle, false );
82 CFRelease( cfpath );
83 cferror = nullptr;
84 cfbookmark = CFURLCreateBookmarkDataFromFile( nullptr, cfurl, &cferror );
85 CFRelease( cfurl );
87 if ( cfbookmark == nullptr )
89 if(cferror)
91 CFRelease( cferror );
94 else
96 Boolean isStale;
97 cfurl = CFURLCreateByResolvingBookmarkData( nullptr, cfbookmark, kCFBookmarkResolutionWithoutUIMask,
98 nullptr, nullptr, &isStale, &cferror );
99 CFRelease( cfbookmark );
100 if ( cfurl == nullptr )
102 CFRelease( cferror );
104 else
106 cfpath = CFURLCopyFileSystemPath( cfurl, kCFURLPOSIXPathStyle );
107 CFRelease( cfurl );
108 if ( cfpath != nullptr )
110 char tmpPath[ PATH_MAX ];
111 if ( CFStringGetCString( cfpath, tmpPath, PATH_MAX, kCFStringEncodingUTF8 ) )
113 int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 );
114 if ( nLen < buflen && nLen < PATH_MAX )
116 if ( unprocessedPath )
118 int nTmpPathLen = strlen( tmpPath );
119 strcat( tmpPath, "/" );
120 strcat( tmpPath, unprocessedPath + 1 );
121 strcpy( path, tmpPath);
122 unprocessedPath = path + nTmpPathLen;
124 else if ( !unprocessedPath )
126 strcpy( path, tmpPath );
129 else
131 errno = ENAMETOOLONG;
132 nRet = -1;
135 CFRelease( cfpath );
140 if ( unprocessedPath )
141 *unprocessedPath++ = '/';
144 return nRet;
145 #endif
148 #endif /* defined MACOSX */
150 #endif /* NO_PTHREAD_RTL */
152 //might be useful on other platforms, but doesn't compiler under MACOSX anyway
153 #if defined(__GNUC__) && defined(LINUX)
154 //force the __data_start symbol to exist in any executables that link against
155 //libuno_sal so that dlopening of the libgcj provided libjvm.so on some
156 //platforms where it needs that symbol will succeed. e.g. Debian mips/lenny
157 //with gcc 4.3. With this in place the smoketest succeeds with libgcj provided
158 //java. Quite possibly also required/helpful for s390x and maybe some
159 //others. Without it the dlopen of libjvm.so will fail with __data_start
160 //not found
161 extern int __data_start[] __attribute__((weak));
162 extern int data_start[] __attribute__((weak));
163 extern int _end[] __attribute__((weak));
164 static void *dummy[] __attribute__((used)) = {__data_start, data_start, _end};
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */