Provide dlopen() path searching hook to senseApi libs

This commit is contained in:
2025-07-24 02:12:31 -04:00
parent 064dc43fbc
commit 1bf5f46404
4 changed files with 58 additions and 6 deletions
+28 -1
View File
@@ -4,6 +4,8 @@
#include <preprocessor.h>
#include <stdbool.h>
#include <user/senseDeviceSpec.h>
#include <optional>
#include <string>
namespace smo {
namespace sense_api {
@@ -13,6 +15,27 @@ typedef int (sal_mlo_finalizeIndFn)(void);
typedef int (sal_mlo_attachDeviceReqFn)(const device::SenseDeviceSpec &desc);
typedef int (sal_mlo_detachDeviceReqFn)(const device::SenseDeviceSpec &desc);
/**
* @brief Hooks provided by Salmanoff to senseApi libraries.
* This structure contains function pointers that senseApi libraries can use
* to interact with Salmanoff's functionality, such as searching for commonLibs.
*/
struct SalmanoffCallbacks
{
/**
* @brief Search for a library in Salmanoff's search paths
* @param libraryPath The relative filename of the library to search for
* @return Optional containing the full path if found, nullopt if not found
*
* This function searches for the given library in the same search paths
* that Salmanoff uses when loading senseApi libraries (user-specified
* paths via -p option, current directory, and executable directory).
*/
std::optional<std::string> (*searchForLibInSmoSearchPaths)(
const std::string& libraryPath);
};
struct Sal_Mgmt_LibOps
{
/* When Salmanoff loads a sense API lib, it calls this function to initialize
@@ -105,8 +128,12 @@ public:
* Smo what implexors can be used with it & what APIs it exports.
* The SenseApiDesc struct also gives Smo pointers to API functions
* to invoke for communication between Smo and the library.
*
* The SalmanoffCallbacks parameter provides the library with access to
* Salmanoff's hooks.
*/
typedef const SenseApiDesc &(SMO_GET_SENSE_API_DESC_FN_TYPEDEF)(void);
typedef const SenseApiDesc &(SMO_GET_SENSE_API_DESC_FN_TYPEDEF)(
const SalmanoffCallbacks& callbacks);
} // namespace sense_api
} // namespace smo