he -> hi
This commit is contained in:
34
src/hiload.c
34
src/hiload.c
@@ -1,5 +1,5 @@
|
||||
#include "hiload/hiload.h"
|
||||
#include "hiload/symbols.h"
|
||||
#include "symbols.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -51,7 +51,7 @@ static int gather_module_infos_callback(struct dl_phdr_info *info, size_t size,
|
||||
infos->handles[infos->count] =
|
||||
dlopen(info->dlpi_name, RTLD_LAZY | RTLD_NOLOAD);
|
||||
|
||||
if (he_create_symbol_info(&infos->symbols[infos->count], info) != CREATE_SUCCESS) {
|
||||
if (hi_create_symbol_info(&infos->symbols[infos->count], info) != CREATE_SUCCESS) {
|
||||
fprintf(stderr, "Failed to create symbol info for %s\n", infos->names[infos->count]);
|
||||
}
|
||||
infos->count++;
|
||||
@@ -65,7 +65,7 @@ static void free_module_infos(ModuleInfos *modules) {
|
||||
for (size_t i = 0; i < modules->count; i++) {
|
||||
if (modules->names[i])
|
||||
free(modules->names[i]);
|
||||
he_free_symbol_info(&modules->symbols[i]);
|
||||
hi_free_symbol_info(&modules->symbols[i]);
|
||||
}
|
||||
|
||||
free(modules->names);
|
||||
@@ -110,7 +110,7 @@ static ModuleInfos *gather_shared_libraries(void) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int he_init() {
|
||||
int hi_init() {
|
||||
assert(!module_infos);
|
||||
|
||||
ModuleInfos *infos = gather_shared_libraries();
|
||||
@@ -125,7 +125,7 @@ int he_init() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void he_deinit() { free_module_infos(module_infos); }
|
||||
void hi_deinit() { free_module_infos(module_infos); }
|
||||
|
||||
/**
|
||||
* Reloads a shared library module
|
||||
@@ -138,7 +138,7 @@ void he_deinit() { free_module_infos(module_infos); }
|
||||
static ReloadResult reload_module(ModuleInfos *modules, const char *filename,
|
||||
void **updated_handle) {
|
||||
if (!modules || !filename) {
|
||||
return RELOAD_NOT_FOUND;
|
||||
return HI_RELOAD_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Find the module by filename
|
||||
@@ -165,20 +165,20 @@ static ReloadResult reload_module(ModuleInfos *modules, const char *filename,
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return RELOAD_NOT_FOUND;
|
||||
return HI_RELOAD_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Save the full path
|
||||
char *fullpath = strdup(modules->names[index]);
|
||||
if (!fullpath) {
|
||||
return RELOAD_OPEN_ERROR;
|
||||
return HI_RELOAD_OPEN_ERROR;
|
||||
}
|
||||
|
||||
// Close the old handle
|
||||
if (modules->handles[index]) {
|
||||
if (dlclose(modules->handles[index]) != 0) {
|
||||
free(fullpath);
|
||||
return RELOAD_CLOSE_ERROR;
|
||||
return HI_RELOAD_CLOSE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ static ReloadResult reload_module(ModuleInfos *modules, const char *filename,
|
||||
if (!new_handle) {
|
||||
fprintf(stderr, "Error reloading module: %s\n", dlerror());
|
||||
free(fullpath);
|
||||
return RELOAD_OPEN_ERROR;
|
||||
return HI_RELOAD_OPEN_ERROR;
|
||||
}
|
||||
|
||||
// Update the handle in our structure
|
||||
@@ -199,23 +199,23 @@ static ReloadResult reload_module(ModuleInfos *modules, const char *filename,
|
||||
}
|
||||
|
||||
free(fullpath);
|
||||
return RELOAD_SUCCESS;
|
||||
return HI_RELOAD_SUCCESS;
|
||||
}
|
||||
/**
|
||||
* Helper function to print the result of a module reload
|
||||
*/
|
||||
static void print_reload_result(ReloadResult result, const char *filename) {
|
||||
switch (result) {
|
||||
case RELOAD_SUCCESS:
|
||||
case HI_RELOAD_SUCCESS:
|
||||
printf("Successfully reloaded module: %s\n", filename);
|
||||
break;
|
||||
case RELOAD_NOT_FOUND:
|
||||
case HI_RELOAD_NOT_FOUND:
|
||||
printf("Module not found: %s\n", filename);
|
||||
break;
|
||||
case RELOAD_CLOSE_ERROR:
|
||||
case HI_RELOAD_CLOSE_ERROR:
|
||||
printf("Error closing module: %s\n", filename);
|
||||
break;
|
||||
case RELOAD_OPEN_ERROR:
|
||||
case HI_RELOAD_OPEN_ERROR:
|
||||
printf("Error reopening module: %s\n", filename);
|
||||
break;
|
||||
default:
|
||||
@@ -223,7 +223,7 @@ static void print_reload_result(ReloadResult result, const char *filename) {
|
||||
}
|
||||
}
|
||||
|
||||
ReloadResult he_reload_module(const char *module_name) {
|
||||
ReloadResult hi_reload_module(const char *module_name) {
|
||||
assert(module_infos);
|
||||
|
||||
void *new_handle = NULL;
|
||||
@@ -233,7 +233,7 @@ ReloadResult he_reload_module(const char *module_name) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void he_print_module_infos() {
|
||||
void hi_print_module_infos() {
|
||||
assert(module_infos);
|
||||
|
||||
const ModuleInfos *modules = module_infos;
|
||||
|
||||
Reference in New Issue
Block a user