Skip to content

C API Integration

Joel Guerra edited this page Jun 11, 2026 · 1 revision

SnoutDB provides an experimental C ABI for embedding local analytics in native applications and languages with a C foreign-function interface.

Build

./scripts/build-cabi.sh

Outputs:

  • macOS: libsnout.dylib
  • Linux: libsnout.so

Public header: include/snoutdb.h

Basic Lifecycle

#include "snoutdb.h"

SnoutTable *table = snout_import_csv("calls.csv");
if (table == NULL) {
    fprintf(stderr, "%s\n", snout_last_error());
    return 1;
}

printf("rows: %lld\n", (long long)snout_row_count(table));
snout_close(table);

Query

SnoutResult *result = snout_query(
    table,
    "region",
    "avg=jitter_ms count=rows",
    NULL,
    0,
    "avg=jitter_ms desc",
    10
);

if (result == NULL) {
    fprintf(stderr, "%s\n", snout_last_error());
}

snout_result_free(result);

Ownership Rules

  • Free every SnoutTable* with snout_close.
  • Free every SnoutResult* with snout_result_free.
  • Returned string pointers are temporary; copy them before the next relevant API call when they must be retained.
  • Do not share one handle between threads without external synchronization.

Examples

The ABI is experimental and may change before v1.0.0.

Clone this wiki locally