chore: formalize module loading error codes
* Define Constants: Added STK_MOD_LIBRARY_LOAD_ERROR and STK_MOD_SYMBOL_NOT_FOUND_ERROR to the public header. * Update module.c: Swapped out the -1 and -2 placeholders for the new named constants in stk_module_load.
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
/* Modules */
|
/* Modules */
|
||||||
#define STK_MOD_INIT_SUCCESS 0
|
#define STK_MOD_INIT_SUCCESS 0
|
||||||
#define STK_MOD_INIT_FAILURE 1
|
#define STK_MOD_INIT_FAILURE 1
|
||||||
|
#define STK_MOD_LIBRARY_LOAD_ERROR 2
|
||||||
|
#define STK_MOD_SYMBOL_NOT_FOUND_ERROR 3
|
||||||
|
|
||||||
#if defined(__linux__) || defined(_WIN32)
|
#if defined(__linux__) || defined(_WIN32)
|
||||||
#define STK_EVENT_BUFFER 4096
|
#define STK_EVENT_BUFFER 4096
|
||||||
|
|||||||
+2
-2
@@ -91,7 +91,7 @@ int stk_module_load(const char *path, int index)
|
|||||||
|
|
||||||
handle = platform_load_library(path);
|
handle = platform_load_library(path);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return -1;
|
return STK_MOD_LIBRARY_LOAD_ERROR;
|
||||||
|
|
||||||
u.obj = platform_get_symbol(handle, stk_mod_init_name);
|
u.obj = platform_get_symbol(handle, stk_mod_init_name);
|
||||||
init_func = u.init_func;
|
init_func = u.init_func;
|
||||||
@@ -101,7 +101,7 @@ int stk_module_load(const char *path, int index)
|
|||||||
|
|
||||||
if (!init_func || !shutdown_func) {
|
if (!init_func || !shutdown_func) {
|
||||||
platform_unload_library(handle);
|
platform_unload_library(handle);
|
||||||
return -2;
|
return STK_MOD_SYMBOL_NOT_FOUND_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_module_id(path, module_id);
|
extract_module_id(path, module_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user