static VALUE mTokyoMessenger_ext(VALUE vself, VALUE vext, VALUE vkey, VALUE vvalue){ int vsiz; char *vbuf; TCRDB *db = mTokyoMessenger_getdb(vself); vext = StringValueEx(vext); vkey = StringValueEx(vkey); vvalue = StringValueEx(vvalue); if(!(vbuf = tcrdbext(db, RSTRING_PTR(vext), 0, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vvalue), RSTRING_LEN(vvalue), &vsiz))){ return Qnil; } else { return rb_str_new(vbuf, vsiz); } }
static int rdb_ext(lua_State *L){ TCRDB *rdb = rdb_getrdb(L, 1); size_t nsiz = 0; size_t ksiz = 0; size_t vsiz = 0; int sp; const char *name = rdb_getarg(L, 2, &nsiz); const char *key = rdb_getarg(L, 3, &ksiz); const char *value = rdb_getarg(L, 4, &vsiz); int opts = luaL_optint(L, 5, 0); char *res = (char*)tcrdbext(rdb, name, opts, key, ksiz, value, vsiz, &sp); lua_pushlstring(L, res, sp); free(res); return 1; }