diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3942e5b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.14..3.31 FATAL_ERROR) + +project(Hotwire + VERSION 1 + LANGUAGES C) + +add_library(hotwire src/dlopen.c) +add_library(hotwire::Hotwire ALIAS hotwire) + +target_include_directories(hotwire PUBLIC include) diff --git a/include/dlopen.h b/include/dlopen.h new file mode 100644 index 0000000..2e68778 --- /dev/null +++ b/include/dlopen.h @@ -0,0 +1,42 @@ +#pragma once +#include + +#if defined(__APPLE__) +#include +#endif + +#if defined(__linux__) +#include +#endif + +#if defined(_WIN32) +#include +#include +#endif + +// Platform specific code functions + +#if defined(_WIN32) +void hw_platform_win32_get_last_error(LPTSTR lpszFunction); +#endif + +enum hotwire_status_code { Failed, Success, NoPlatform }; + +struct hotwire_dll_t { +#if defined(__linux__) || defined(__APPLE__) + void *dll_handle; +#endif + +#if defined(_WIN32) + HINSTANCE dll_handle; +#endif +}; + +// Function arguments are based off the dlopen() api on POSIX based operating +// systems Loads dll from library +struct hotwire_dll_t hw_dlopen(const char *file, int flags); + +// Loads symbol from DLL +void *hw_dlsym(struct hotwire_dll_t dll, const char *symbol); + +enum hotwire_status_code hw_dlclose(struct hotwire_dll_t handle);