/*- Author: Brian Tiffin Dedicated to the public domain Date started: December 2016 Modified: 2016-12-02/19:55-0500 +*/ /* univedis-v1.c, trial for vedis embedding in Unicon tectonics: gcc -o univedis-v1.so -shared -fpic univedis-v1.c vedis.c */ #include #include "vedis.h" #include "icall.h" /* open a vedis data store (":mem:" for in-memory) */ int VedisOpen(int argc, descriptor argv[]) { int rc; vedis *vp; ArgString(1) rc = vedis_open(&vp, StringVal(argv[1])); if (rc != VEDIS_OK) Error(500); RetInteger((long)vp); } /* close a vedis connection */ int VedisClose(int argc, descriptor argv[]) { int rc; vedis *vp; /* argv[1] is vedis handle */ ArgInteger(1); rc = vedis_close((vedis *)IntegerVal(argv[1])); RetInteger(rc); } /* execute a vedis command */ int Vedis(int argc, descriptor argv[]) { int rc; vedis *vp; vedis_value *rp; const char *result; /* argv[1] is vedis handle */ ArgInteger(1); /* argv[2] is vedis command as string - single result */ ArgString(2); vp = (vedis *)IntegerVal(argv[1]); rc = vedis_exec(vp, StringVal(argv[2]), -1); vedis_exec_result(vp, &rp); result = vedis_value_to_string(rp, 0); RetString((char *)result); }