-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from L1ghtmann/master
Add libroot.h and update rootless.h for rootless v2
- Loading branch information
Showing
5 changed files
with
53 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
libroot/libroot.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <sys/syslimits.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
const char *_Nonnull libroot_dyn_get_root_prefix(void); | ||
const char *_Nonnull libroot_dyn_get_jbroot_prefix(void); | ||
const char *_Nonnull libroot_dyn_get_boot_uuid(void); | ||
char *_Nullable libroot_dyn_rootfspath(const char *_Nullable path, char *_Nullable resolvedPath); | ||
char *_Nullable libroot_dyn_jbrootpath(const char *_Nullable path, char *_Nullable resolvedPath); | ||
|
||
__END_DECLS | ||
|
||
#ifdef __OBJC__ | ||
|
||
#define __CONVERT_PATH_NSSTRING(converter, path) ({ \ | ||
char tmpBuf[PATH_MAX]; \ | ||
[NSString stringWithUTF8String:converter(path.fileSystemRepresentation, tmpBuf)]; \ | ||
}) | ||
|
||
#define JBROOT_PATH_NSSTRING(path) __CONVERT_PATH_NSSTRING(libroot_dyn_jbrootpath, path) | ||
#define ROOTFS_PATH_NSSTRING(path) __CONVERT_PATH_NSSTRING(libroot_dyn_rootfspath, path) | ||
|
||
#endif /* __OBJC__ */ | ||
|
||
#define __CONVERT_PATH_CSTRING(converter, path) ({ \ | ||
static char outPath[PATH_MAX]; \ | ||
converter(path, outPath); \ | ||
}) | ||
|
||
#define JBROOT_PATH_CSTRING(path) __CONVERT_PATH_CSTRING(libroot_dyn_jbrootpath, path) | ||
#define ROOTFS_PATH_CSTRING(path) __CONVERT_PATH_CSTRING(libroot_dyn_rootfspath, path) | ||
|
||
#define JBRAND libroot_dyn_get_boot_uuid() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module libroot { | ||
umbrella header "libroot.h" | ||
link "root" | ||
|
||
export * | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,11 @@ | ||
#include <sys/syslimits.h> | ||
#include <unistd.h> | ||
#include <libroot/libroot.h> | ||
|
||
#ifdef XINA_SUPPORT // Only define this for rootful compilations that need support for xina | ||
#define ROOT_PATH(cPath) !access("/var/LIY", F_OK) ? "/var/jb" cPath : cPath | ||
#define ROOT_PATH_NS(path) !access("/var/LIY", F_OK) ? @"/var/jb" path : path | ||
#define ROOT_PATH_NS_VAR(path) !access("/var/LIY", F_OK) ? [@"/var/jb" stringByAppendingPathComponent:path] : path | ||
#define ROOT_PATH_VAR(path) !access("/var/LIY", F_OK) ? ({ \ | ||
char outPath[PATH_MAX]; \ | ||
strlcpy(outPath, "/var/jb", PATH_MAX); \ | ||
strlcat(outPath, path, PATH_MAX); \ | ||
outPath; \ | ||
}) : path | ||
#else | ||
#define ROOT_PATH(cPath) THEOS_PACKAGE_INSTALL_PREFIX cPath | ||
#define ROOT_PATH_NS(path) @THEOS_PACKAGE_INSTALL_PREFIX path | ||
#define ROOT_PATH_NS_VAR(path) [@THEOS_PACKAGE_INSTALL_PREFIX stringByAppendingPathComponent:path] | ||
#define ROOT_PATH_VAR(path) sizeof(THEOS_PACKAGE_INSTALL_PREFIX) > 1 ? ({ \ | ||
char outPath[PATH_MAX]; \ | ||
strlcpy(outPath, THEOS_PACKAGE_INSTALL_PREFIX, PATH_MAX); \ | ||
strlcat(outPath, path, PATH_MAX); \ | ||
outPath; \ | ||
}) : path | ||
#endif | ||
#ifdef XINA_SUPPORT | ||
_Pragma("message(\"'XINA_SUPPORT' is deprecated. libroot will now handle this for you.\")") | ||
#endif | ||
|
||
#define ROOT_PATH(cPath) JBROOT_PATH_CSTRING(cPath) | ||
#define ROOT_PATH_VAR(cPath) JBROOT_PATH_CSTRING(cPath) | ||
|
||
#define ROOT_PATH_NS(nsPath) JBROOT_PATH_NSSTRING(nsPath) | ||
#define ROOT_PATH_NS_VAR(nsPath) JBROOT_PATH_NSSTRING(nsPath) |