#include #include #include #include #include #include // Path to file where data will be stored. // It will be created if it doesn't exist #define DB_PATH "./store.db" // Binary commands between Erlang VM and Driver #define CMD_SQL_EXEC 2 // #define CMD_DEL 3 // Number of bytes for each key // (160 bits for SHA1 hash) #define KEY_SIZE 20 // Define struct to hold state across calls typedef struct _bdb_drv_t { ErlDrvPort port; struct sqlite3 *db; } sqlite3_drv_t; static ErlDrvData start(ErlDrvPort port, char* cmd); static void stop(ErlDrvData handle); static int control(ErlDrvData drv_data, unsigned int command, char *buf, int len, char **rbuf, int rlen); static void ready_async(ErlDrvData drv_data, ErlDrvThreadData thread_data); static int sql_exec(sqlite3_drv_t *drv, char *buf, int len); // static void get(bdb_drv_t *bdb_drv, ErlIOVec *ev); // static void del(bdb_drv_t *bdb_drv, ErlIOVec *ev); static int unknown(sqlite3_drv_t *bdb_drv, char *buf, int len);