fix(c): Wrap library API functions in ifdef UNSANDBOX_LIBRARY

Library API functions now only compile when building as library.
CLI builds without library API, just the main() function.
This commit is contained in:
russell@unturf.com 2026-01-17 09:12:25 -05:00
parent f72b6b4704
commit b6d6f162d0
2 changed files with 7 additions and 1 deletions

View file

@ -67,7 +67,7 @@ cli: $(CLI)
$(CLI): $(SRC) $(HEADER)
@echo "Building CLI binary..."
$(CC) $(CFLAGS_LIB) -o $@ $(SRC) $(LDFLAGS)
$(CC) $(CFLAGS) -o $@ $(SRC) $(LDFLAGS)
@echo "$(GREEN)$(NC) Built: $@"
lib: $(SRC) $(HEADER)

View file

@ -5710,6 +5710,11 @@ int unsandbox_health_check(void) {
return (http_code == 200) ? 1 : 0;
}
#ifdef UNSANDBOX_LIBRARY
/* ============================================================================
* Library API - Only compiled when UNSANDBOX_LIBRARY is defined
* ============================================================================ */
/* Memory management */
void unsandbox_free_result(unsandbox_result_t *result) {
if (!result) return;
@ -8177,6 +8182,7 @@ void unsandbox_free_trusted_keys(char **keys, size_t count) {
const char *unsandbox_last_error(void) {
return unsandbox_error_buffer[0] ? unsandbox_error_buffer : NULL;
}
#endif /* UNSANDBOX_LIBRARY - end of library API */
#ifndef UNSANDBOX_LIBRARY
int main(int argc, char *argv[]) {