]> git.saurik.com Git - apple/dyld.git/blob - dyld3/PathOverrides.h
dyld-551.4.tar.gz
[apple/dyld.git] / dyld3 / PathOverrides.h
1 /*
2 * Copyright (c) 2017 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25
26 #ifndef __DYLD_PATH_OVERRIDES_H__
27 #define __DYLD_PATH_OVERRIDES_H__
28
29 #include <stdint.h>
30
31 #if !DYLD_IN_PROCESS
32 #include <vector>
33 #include <string>
34 #endif
35
36 #include "Logging.h"
37 #include "MachOParser.h"
38
39
40 namespace dyld3 {
41
42 class VIS_HIDDEN PathOverrides
43 {
44 public:
45 #if !BUILDING_LIBDYLD
46 // libdyld is never unloaded
47 ~PathOverrides();
48 #endif
49
50 #if DYLD_IN_PROCESS
51 void setEnvVars(const char* envp[]);
52 void forEachPathVariant(const char* initialPath, void (^handler)(const char* possiblePath, bool& stop)) const;
53 #else
54 PathOverrides(const std::vector<std::string>& env);
55 void forEachPathVariant(const char* initialPath, Platform platform, void (^handler)(const char* possiblePath, bool& stop)) const;
56 #endif
57
58 uint32_t envVarCount() const;
59 void forEachEnvVar(void (^handler)(const char* envVar)) const;
60 void forEachInsertedDylib(void (^handler)(const char* dylibPath)) const;
61
62 private:
63 void forEachInColonList(const char* list, void (^callback)(const char* path));
64 const char** parseColonListIntoArray(const char* list);
65 void freeArray(const char** array);
66 void addEnvVar(const char* keyEqualsValue);
67 const char* getFrameworkPartialPath(const char* path) const;
68 static const char* getLibraryLeafName(const char* path);
69 void handleListEnvVar(const char* key, const char** list, void (^handler)(const char* envVar)) const;
70 void handleEnvVar(const char* key, const char* value, void (^handler)(const char* envVar)) const;
71 void forEachDylibFallback(Platform platform, void (^handler)(const char* fallbackDir, bool& stop)) const;
72 void forEachFrameworkFallback(Platform platform, void (^handler)(const char* fallbackDir, bool& stop)) const;
73
74 const char** _dylibPathOverrides = nullptr;
75 const char** _frameworkPathOverrides = nullptr;
76 const char** _dylibPathFallbacks = nullptr;
77 const char** _frameworkPathFallbacks = nullptr;
78 const char** _insertedDylibs = nullptr;
79 const char* _imageSuffix = nullptr;
80 const char* _rootPath = nullptr; // simulator only
81 };
82
83 #if BUILDING_LIBDYLD
84 extern PathOverrides gPathOverrides;
85 #endif
86
87
88 } // namespace dyld3
89
90 #endif // __DYLD_PATH_OVERRIDES_H__
91
92