/* vlrengine.h - engine-side bridge to vlrlib (task #72, module 3.6b, slice 1).
 * The seam the ISQL query engine calls for VLR tables. Callers pass ABSOLUTE
 * table paths (the engine resolves them, keeping vlrlib cwd-safe re #39) and a
 * row as an array of field values; this translates to/from VLR_RECBUF.
 * Activation is gated by GlobalCfg.VlrEnabled (default 0) at the call sites. */
#ifndef VLRENGINE_H
#define VLRENGINE_H

#include "vlr.h"

#ifdef __cplusplus
extern "C" {
#endif

/* one field value in a row being inserted */
typedef struct IsqlVlrField {
    const char *val;   /* value bytes (ignored if isnull) */
    KINT64      len;
    int         isnull;
} IsqlVlrField;

int         IsqlVlrIsFile   (const char *abspath);   /* 1 if the file is VLR-format */
VLR_TABLE  *IsqlVlrCreate   (const char *abspath, int nfields, int encrypted);
VLR_TABLE  *IsqlVlrOpen     (const char *abspath);
int         IsqlVlrClose    (VLR_TABLE *t);
KINT64      IsqlVlrInsertRow(VLR_TABLE *t, const IsqlVlrField *fields, int nfields);
int         IsqlVlrFetchRow (VLR_TABLE *t, KINT64 recno, VLR_RECBUF *out);
int         IsqlVlrUpdateRow(VLR_TABLE *t, KINT64 recno, const IsqlVlrField *fields, int nfields);
int         IsqlVlrDeleteRow(VLR_TABLE *t, KINT64 recno);

#ifdef __cplusplus
}
#endif
#endif /* VLRENGINE_H */
