2009-09-17 13:06:04 +00:00
|
|
|
#ifndef DYNAMICLOADER_H
|
|
|
|
#define DYNAMICLOADER_H
|
|
|
|
|
|
|
|
#include "macho_global.h"
|
|
|
|
|
2016-11-19 16:23:39 +01:00
|
|
|
typedef std::list<std::string> StringList;
|
2009-09-17 13:06:04 +00:00
|
|
|
|
|
|
|
class MachOArchitecture;
|
|
|
|
class DynamicLoader
|
|
|
|
{
|
|
|
|
public:
|
2016-11-19 16:23:39 +01:00
|
|
|
DynamicLoader();
|
|
|
|
virtual ~DynamicLoader();
|
2009-09-17 13:06:04 +00:00
|
|
|
|
2016-11-19 16:23:39 +01:00
|
|
|
std::string replacePlaceholder(const std::string& name, const MachOArchitecture* architecture) const;
|
|
|
|
std::string getPathname(const std::string& name, const MachOArchitecture* architecture, const std::string& workingDirectory) const;
|
2009-09-17 13:06:04 +00:00
|
|
|
|
|
|
|
private:
|
2016-11-19 16:23:39 +01:00
|
|
|
class EnvironmentPathVariable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EnvironmentPathVariable();
|
|
|
|
EnvironmentPathVariable(const char* homePath, const std::string& name, const StringList& defaultValues = StringList());
|
|
|
|
|
|
|
|
bool isEmpty() const;
|
|
|
|
const StringList& getPaths() const { return paths; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void setPaths(const StringList& paths);
|
|
|
|
void addPath(const std::string& path);
|
|
|
|
bool replaceHomeDirectory(std::string& path);
|
|
|
|
StringList paths;
|
|
|
|
static const char PATHS_SEPARATOR;
|
2011-04-24 19:31:31 +00:00
|
|
|
const char* homePath;
|
2016-11-19 16:23:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
LdLibraryPath,
|
|
|
|
DyldFrameworkPath,
|
|
|
|
DyldLibraryPath,
|
|
|
|
DyldFallbackFrameworkPath,
|
|
|
|
DyldFallbackLibraryPath,
|
|
|
|
DyldImageSuffix,
|
|
|
|
NumEnvironmentVariables
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Placeholder {
|
|
|
|
ExecutablePath,
|
|
|
|
LoaderPath,
|
|
|
|
Rpath,
|
|
|
|
NumPlaceholders
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char* PLACEHOLDERS[NumPlaceholders];
|
|
|
|
static const char* ENVIRONMENT_VARIABLE_NAMES[NumEnvironmentVariables];
|
|
|
|
static const char* PATH_SEPARATOR;
|
|
|
|
static const StringList ENVIRONMENT_VARIABLE_DEFAULT_VALUES[NumEnvironmentVariables];
|
|
|
|
|
|
|
|
static const char* DEFAULT_FRAMEWORK_PATH[];
|
|
|
|
static const char* DEFAULT_LIBRARY_PATH[];
|
|
|
|
const char* homePath;
|
|
|
|
|
|
|
|
EnvironmentPathVariable environmentVariables[NumEnvironmentVariables];
|
|
|
|
|
|
|
|
std::string getFrameworkName(const std::string& name, const bool strippedSuffix = false) const;
|
|
|
|
const char* getUserHomeDirectory() const;
|
2009-09-17 13:06:04 +00:00
|
|
|
|
2016-11-19 16:23:39 +01:00
|
|
|
std::string getExistingPathname(const std::string& name, const EnvironmentPathVariable& environmentPathVariable, const std::string& workingPath) const;
|
|
|
|
std::string getExistingPathname(const std::string& name, const std::string& directory, const std::string& workingPath) const;
|
|
|
|
std::string getExistingPathname(const std::string& name, const std::string& workingPath, bool withSuffix=true) const;
|
2009-09-17 13:06:04 +00:00
|
|
|
|
2016-11-19 16:23:39 +01:00
|
|
|
static bool endsWith(const std::string& str, const std::string& substr);
|
2009-09-17 13:06:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DYNAMICLOADER_H
|