Skip to content

Commit

Permalink
Move libroot.h to libroot/libroot.h, added module support
Browse files Browse the repository at this point in the history
  • Loading branch information
leptos-null committed Feb 17, 2024
1 parent ad25190 commit a7226d2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 44 deletions.
27 changes: 0 additions & 27 deletions libroot.h

This file was deleted.

1 change: 1 addition & 0 deletions libroot.h
29 changes: 29 additions & 0 deletions libroot/libroot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <sys/syslimits.h>

const char *libroot_dyn_get_root_prefix(void);
const char *libroot_dyn_get_jbroot_prefix(void);
const char *libroot_dyn_get_boot_uuid(void);
char *libroot_dyn_rootfspath(const char *path, char *resolvedPath);
char *libroot_dyn_jbrootpath(const char *path, char *resolvedPath);

#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()
6 changes: 6 additions & 0 deletions libroot/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module libroot {
umbrella header "libroot.h"
link "root"

export *
}
26 changes: 9 additions & 17 deletions rootless.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
// TODO: remove this file
// #include <sys/syslimits.h>
// #include <unistd.h>
#include "libroot.h"
#include <libroot/libroot.h>

#ifdef XINA_SUPPORT
_Pragma("message(\"'XINA_SUPPORT' is deprecated. libroot will now handle this for you.\")")
#endif
// #define ROOT_PATH(cPath) THEOS_PACKAGE_INSTALL_PREFIX cPath
// #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
#define ROOT_PATH(cPath) _Pragma("message(\"'ROOT_PATH' is deprecated. Please import libroot.h and use 'JBROOT_PATH_CSTRING' instead.\")") JBROOT_PATH_CSTRING(cPath)
#define ROOT_PATH_VAR(path) _Pragma("message(\"'ROOT_PATH_VAR' is deprecated. Please import libroot.h and use 'JBROOT_PATH_CSTRING' instead.\")") JBROOT_PATH_CSTRING(path)

// #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_NS(path) _Pragma("message(\"'ROOT_PATH_NS' is deprecated. Please import libroot.h and use 'JBROOT_PATH_NSSTRING' instead.\")") JBROOT_PATH_NSSTRING(path)
#define ROOT_PATH_NS_VAR(path) _Pragma("message(\"'ROOT_PATH_NS_VAR' is deprecated. Please import libroot.h and use 'JBROOT_PATH_NSSTRING' instead.\")") JBROOT_PATH_NSSTRING(path)
// compatibility header
// use libroot/libroot.h directly in the future

#define ROOT_PATH(cPath) JBROOT_PATH_CSTRING(cPath)
#define ROOT_PATH_VAR(path) JBROOT_PATH_CSTRING(path)

#define ROOT_PATH_NS(path) JBROOT_PATH_NSSTRING(path)
#define ROOT_PATH_NS_VAR(path) JBROOT_PATH_NSSTRING(path)

0 comments on commit a7226d2

Please sign in to comment.