Files
stk/include/stk.h
T
anth64 4250f91969 feat(stk.h, module, stk): improve dependency failure logging
- Add STK_MOD_DEP_LOG_BUFFER (2048) to stk.h for the dep failure message
buffer size.

- Add stk_log_dependency_failures(index, action) to module.c. Walks all
deps for the given module, skips satisfied ones, and builds a single
log line listing every unmet dep with its reason: "not found" or
"requires <constraint>, have <version>". The action parameter
("Deferring" / "Unloading") lets call sites produce contextually
appropriate messages:

  - Deferring 'test_mod_dep': unmet deps: test_mod (not found)
  - Unloading 'test_mod_dep': unmet deps: test_mod (not found), renderer (requires ^2.0.0, have 1.3.0)

- Replace the silent defer at init and the vague "unmet dependencies"
cascade log in stk_poll() with calls to stk_log_dependency_failures().
2026-03-07 11:34:23 +01:00

100 lines
2.4 KiB
C

#ifndef STK_H
#define STK_H
#include "stk_version.h"
#include <stdlib.h>
/* Buffers */
#define STK_LOG_PREFIX_BUFFER 64
#define STK_MOD_DEP_OPERATOR_BUFFER 3
#define STK_MOD_DEP_LOG_BUFFER 2048
#define STK_MOD_DESC_BUFFER 256
#define STK_MOD_DIR_BUFFER 256
#define STK_MOD_ID_BUFFER 64
#define STK_MOD_NAME_BUFFER 128
#define STK_MOD_VERSION_BUFFER 32
#define STK_PATH_MAX 256
#define STK_PATH_MAX_OS 4096
/* Initialization return codes */
#define STK_INIT_SUCCESS 0
#define STK_INIT_MEMORY_ERROR 1
#define STK_INIT_TMPDIR_ERROR 2
#define STK_INIT_WATCH_ERROR 3
/* Module loading return codes */
#define STK_MOD_INIT_SUCCESS 0
#define STK_MOD_INIT_FAILURE 1
#define STK_MOD_LIBRARY_LOAD_ERROR 2
#define STK_MOD_SYMBOL_NOT_FOUND_ERROR 3
#define STK_MOD_REALLOC_FAILURE 4
#define STK_MOD_DEP_NOT_FOUND_ERROR 5
#define STK_MOD_DEP_VERSION_MISMATCH_ERROR 6
#define STK_MOD_DEP_CIRCULAR_ERROR 7
/* Platform return codes */
#define STK_PLATFORM_OPERATION_SUCCESS 0
#define STK_PLATFORM_FILE_COPY_ERROR 1
#define STK_PLATFORM_MKDIR_ERROR 2
#define STK_PLATFORM_REMOVE_DIR_ERROR 3
#define STK_PLATFORM_REMOVE_FILE_ERROR 4
/* Settings flags */
#define STK_FLAG_INITIALIZED 0x01
#define STK_FLAG_LOGGING_ENABLED 0x02
/* Dependency constraint operators */
#define STK_DEP_MIN 0
#define STK_DEP_EXACT 1
#define STK_DEP_COMPAT 2
#if defined(__linux__) || defined(_WIN32)
#define STK_EVENT_BUFFER 4096
#endif
#if defined(_WIN32)
#define STK_MODULE_EXT ".dll"
#elif defined(__APPLE__)
#define STK_MODULE_EXT ".dylib"
#else
#define STK_MODULE_EXT ".so"
#endif
#define STK_MODULE_EXT_LEN (sizeof(STK_MODULE_EXT) - 1)
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
STK_MOD_LOAD,
STK_MOD_UNLOAD,
STK_MOD_RELOAD
} stk_module_event_t;
typedef struct {
char id[STK_MOD_ID_BUFFER];
char version[STK_MOD_VERSION_BUFFER];
} stk_dep_t;
unsigned char stk_init(void);
void stk_shutdown(void);
size_t stk_module_count(void);
size_t stk_poll(void);
void stk_set_mod_dir(const char *path);
void stk_set_tmp_dir_name(const char *name);
void stk_set_module_init_fn(const char *name);
void stk_set_module_shutdown_fn(const char *name);
void stk_set_logging_enabled(unsigned char enabled);
void stk_set_module_name_fn(const char *name);
void stk_set_module_version_fn(const char *name);
void stk_set_module_description_fn(const char *name);
void stk_set_module_deps_sym(const char *name);
unsigned char stk_is_logging_enabled(void);
#ifdef __cplusplus
}
#endif
#endif /* STK_H */