Oninit® Log Ripper — C API Reference
Per-function reference for the public C API exposed by
liboni_ripper.so . The single public header is
<oni_ripper.h> , installed at
/usr/include/ ; opaque oni_config_t and
oni_engine_t handles, programmatic config builder
mirroring every YAML key, engine lifecycle, two callback shapes
(per-transaction delivery, log line delivery), and a stats
accessor. See the
Embed Ripper overview
for the worked example, build / link instructions, signal-handling
contract, and installed-files reference.
Convention for return values: every int -returning function
returns 0 on success, -1 on error unless noted
otherwise. Pointer-returning functions return NULL on
failure with an error string written to errbuf when
provided.
Version
oni_version
const char *oni_version(void);
Returns a static "MAJOR.MINOR.PATCH (flavor)" string. The
flavor token signals the release channel.
Config builder
oni_config_new
oni_config_t *oni_config_new(void);
Allocate an empty config with the same defaults the YAML loader
would apply (cdc_timeout=5 , sessions_per_thread=10 ,
max_threads=4 , log_keep=5 , etc.). Returns
NULL on out-of-memory. Free with
oni_config_free() .
oni_config_load_yaml
oni_config_t *oni_config_load_yaml(const char *path,
char *errbuf, size_t errbuflen);
Parse a YAML file using the same loader the CLI uses; every key the
CLI accepts is honored. On failure, errbuf receives a
one-line description and NULL is returned.
oni_config_free
void oni_config_free(oni_config_t *cfg);
Release a config handle. Safe to call after
oni_engine_new() — the engine takes a deep copy.
oni_config_set_source
int oni_config_set_source(oni_config_t *cfg,
const char *db, const char *server,
const char *user, const char *pass);
Set the source Informix database, server, and credentials. Pass
NULL or "" for user /pass to fall
back to OS authentication.
oni_config_add_table
int oni_config_add_table(oni_config_t *cfg, const char *pattern);
Append a glob pattern ("customer" , "order*" ) to the
captured-tables list. Prefix with "!" to exclude. Repeated
calls accumulate.
oni_config_add_column_filter
int oni_config_add_column_filter(oni_config_t *cfg,
const char *table_pattern,
const char *col_pattern);
Attach a per-column include / exclude pattern to a previously-added
table entry. table_pattern must match an earlier
oni_config_add_table() . Prefix col_pattern with
"!" to exclude that column.
oni_config_set_threading
int oni_config_set_threading(oni_config_t *cfg,
int sessions_per_thread, int max_threads,
int cdc_timeout_sec, int max_recs_per_read);
Override the threading defaults. Values ≤ 0 for any
parameter leave that knob at its existing value.
oni_config_set_state_file
int oni_config_set_state_file(oni_config_t *cfg, const char *path);
Persist min(last_committed_lsn) to path on
shutdown; reload it on startup so the next run resumes from the same
LSN. Empty path disables the feature.
oni_config_set_schema_archive_dir
int oni_config_set_schema_archive_dir(oni_config_t *cfg, const char *dir);
Directory holding archived
<db>_<tab>.sql DDL files used by the schema-drift
recovery path and the startup
[ARCHIVE-CMP] safety net.
oni_config_set_control_dir
int oni_config_set_control_dir(oni_config_t *cfg, const char *dir);
Directory polled by workers for
release_<tab> / acquire_<tab>
sentinel files. Empty disables live release / re-acquire.
Output mode
oni_config_output_embed
int oni_config_output_embed(oni_config_t *cfg,
oni_tx_cb_t cb, void *user);
Pick in-process callback delivery. Every committed transaction is
handed to cb(user, &tx) . cb must be non-NULL.
The engine writes nowhere else.
oni_config_output_file
int oni_config_output_file(oni_config_t *cfg, const char *dir);
Pick file mode — one .sql file per committed
transaction under dir .
oni_config_output_json
int oni_config_output_json(oni_config_t *cfg, const char *dir);
Pick JSON mode — one RFC 8259 .json file per
committed transaction under dir .
oni_config_output_csv
int oni_config_output_csv(oni_config_t *cfg, const char *dir,
char delimiter, int include_header);
Pick CSV mode — one RFC 4180 .csv file per committed
transaction. delimiter is a single character (default
',' ); include_header controls whether the column-
name row is written at the top of every file.
oni_config_output_kafka
int oni_config_output_kafka(oni_config_t *cfg,
const char *brokers, const char *topic);
Pick Kafka mode — one librdkafka message per CDC record. Both
brokers and topic are required. Additional Kafka
tunables (compression, acks, SASL, etc.) come from
oni_config_load_yaml() .
oni_config_output_informix
int oni_config_output_informix(oni_config_t *cfg,
const char *target_db,
const char *target_server,
const char *user, const char *pass);
Pick Informix direct mode. target_server may be
NULL when target_db uses the
db@server form. user / pass may be
NULL for OS authentication.
oni_config_output_odbc
int oni_config_output_odbc(oni_config_t *cfg, const char *dsn,
const char *user, const char *pass);
Pick ODBC mode pointing at dsn from /etc/odbc.ini .
Logging
oni_config_set_logging
int oni_config_set_logging(oni_config_t *cfg, int verbose,
int debug_trace, int debug_sql, int debug_cdc,
int debug_detail, int debug_hex,
int status_interval);
Equivalent of the logging: YAML block. Each debug_*
flag is 0 or 1 ; status_interval is
seconds between [STATUS] + [LSN] reports
(0 = off).
oni_config_set_log_callback
int oni_config_set_log_callback(oni_config_t *cfg,
oni_log_cb_t cb, void *user);
Route every tagged log line into the host's logging framework. Pass
NULL to revert to the default stderr output.
Engine lifecycle
oni_engine_new
oni_engine_t *oni_engine_new(const oni_config_t *cfg,
char *errbuf, size_t errbuflen);
Build an engine from a frozen config. The engine takes a deep copy;
the caller may free cfg immediately after. On failure
NULL is returned and errbuf describes the problem.
oni_engine_start
int oni_engine_start(oni_engine_t *e);
Connect to the source, resolve tables, initialize output, spawn
worker threads. Returns immediately — workers run on their own
threads. Failure leaves the engine in a clean stopped state.
oni_engine_reload
int oni_engine_reload(oni_engine_t *e);
Re-apply the runtime-tunable subset of the config (verbose,
debug_* , status_interval , log_maxsize ,
log_keep , cdc_timeout ) — equivalent of
SIGHUP. Source / tables / output mode require stop+new.
oni_engine_stop
int oni_engine_stop(oni_engine_t *e);
Graceful shutdown — drains in-flight transactions as
_NO_COMMIT , persists the LSN checkpoint, closes the output,
joins worker threads. Idempotent.
oni_engine_free
void oni_engine_free(oni_engine_t *e);
Release the engine handle. Calls oni_engine_stop()
internally if the engine is still running.
Introspection
oni_engine_stats
int oni_engine_stats(const oni_engine_t *e, oni_stats_t *out);
Snapshot of cumulative counters: records, transactions, bytes read,
last_committed_lsn , source LSN, active workers, recovery
events. Returns 0 on success.
oni_engine_last_error
const char *oni_engine_last_error(const oni_engine_t *e);
Returns the last error string for this engine, or NULL if
none. Pointer is valid until the next library call on the same
engine.
Callback signatures
oni_tx_cb_t
typedef int (*oni_tx_cb_t)(void *user, const oni_tx_t *tx);
Per-transaction callback registered via
oni_config_output_embed() . The callback runs on the worker
thread that captured the transaction. Returning 0 acks: the
worker's last_committed_lsn advances. Returning non-zero
halts the engine without advancing the LSN, so the next start
replays from the same source position. The
oni_tx_t / oni_record_t struct shapes are defined
on the
Embed Ripper page.
oni_log_cb_t
typedef void (*oni_log_cb_t)(void *user, int severity,
const char *tag, const char *msg);
Log-line callback registered via
oni_config_set_log_callback() . severity is one of
ONI_LOG_TRACE (0), ONI_LOG_INFO (1),
ONI_LOG_WARN (2), ONI_LOG_CRITICAL (3).
tag is the bracketed prefix ("STATUS" ,
"LSN" , "TX" , etc.); msg is the formatted
line body with no leading [TAG] and no trailing newline.