Hack, hack... moving code

This commit is contained in:
Maas-Maarten Zeeman
2011-10-13 21:05:17 +02:00
parent c5c9eae03d
commit 4780a4eed3
2 changed files with 26 additions and 1 deletions

View File

@@ -6,6 +6,31 @@
#include "sqlite3.h"
#define MAX_PATHNAME 512 /* unfortunately not in sqlite.h */
/*
* Open database. Expects utf-8 input
*/
static ERL_NIF_TERM eisqlite_open_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
int rc;
char filename[MAX_PATHNAME];
sqlite3
/* TODO ignore the utf-8 stuff for now */
if(!enif_get_string(env, argv[0], filename, MAX_PATHNAME, ERL_NIF_LATIN1))
return enif_make_badarg(env);
rc = sqlite3_open(filename, &db);
if( rc ) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
/* maak een error tuple */
}
}
static int on_load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info)
{

View File

@@ -1,3 +1,3 @@
{vrequire_otp_vsn, "R14"}.
{require_otp_vsn, "R14"}.
{port_sources, ["c_src/*.c"]}.
{so_name, "esqlite_nif.so"}.