/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if (pAbsPath)
{ /* Convert from path to url. */ if (osl_getFileURLFromSystemPath (pAbsPath, ppFileURL) == osl_File_E_None)
{ /* Success. */
result = osl_Process_E_None;
}
rtl_uString_release (pAbsPath);
}
}
}
return result;
}
}
#else #include <dlfcn.h>
namespace {
oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL)
{ #ifdef EMSCRIPTEN // Just return some dummy file: URL for now to see what happens
OUString fileURL = "vnd.sun.star.pathname:/instdir/program/soffice";
rtl_uString_acquire(fileURL.pData);
*ppFileURL = fileURL.pData; return osl_Process_E_None; #else
oslProcessError result = osl_Process_E_NotFound;
#ifdef ANDROID /* Now with just a single DSO, this one from lo-bootstrap.c is as good as
* any */ void * addr = dlsym (RTLD_DEFAULT, "JNI_OnLoad"); #else #ifdefined __linux // The below code looking for "main" with dlsym() will typically // fail, as there is little reason for "main" to be exported, in // the dlsym() sense, from an executable. But Linux has // /proc/self/exe, try using that. char buf[PATH_MAX]; int rc = readlink("/proc/self/exe", buf, sizeof(buf)); if (rc > 0 && rc < PATH_MAX)
{
buf[rc] = '\0';
OUString path = OUString::fromUtf8(buf);
OUString fileURL; if (osl::File::getFileURLFromSystemPath(path, fileURL) == osl::File::E_None)
{
rtl_uString_acquire(fileURL.pData);
*ppFileURL = fileURL.pData; return osl_Process_E_None;
}
} #endif /* Determine address of "main()" function. */ void * addr = dlsym (RTLD_DEFAULT, "main"); #endif if (addr != nullptr)
{ /* Determine module URL. */ if (osl_getModuleURLFromAddress (addr, ppFileURL))
{ /* Success. */
result = osl_Process_E_None;
}
}
rtl_string_acquire(pBuffer); // argument to putenv must leak on success
if (putenv(rtl_string_getStr(pBuffer)) == 0)
result = osl_Process_E_None; else
rtl_string_release(pBuffer); #elif (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) // MacOSX baseline is 10.4, which has an old-school void return // for unsetenv. // See: http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/10.4/man3/unsetenv.3.html?useVersion=10.4
unsetenv(rtl_string_getStr(pstr_env_var));
result = osl_Process_E_None; #else if (unsetenv(rtl_string_getStr(pstr_env_var)) == 0)
result = osl_Process_E_None; #endif
rtl_string_release(pstr_env_var);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.