Closed radare closed 2 years ago
Provide a simple api to work with sdb.
#include <sdb.h> #define Set(x,y) sdb_set (db, x, y, 0) #define Get(x) sdb_const_get (db, x, NULL) #define ArrayPush(x,y) sdb_array_set (db, x, -1, y, 0) #define ArrayLength(x) sdb_array_length (db, x) #define ArrayGet(x,y) sdb_array_get (db, x, y, NULL) #define Encode(x) sdb_encode(x, -1) int main() { Sdb *db = sdb_new0 (); Set ("foo", "bar"); printf ("%s\n", Get ("foo")); ArrayPush("stmt", "write"); ArrayPush("stmt", "1"); ArrayPush("stmt", Encode("\"hello world\"")); ArrayPush("stmt", "12"); printf ("SI %d\n", ArrayLength ("stmt")); printf ("--> (%s)\n", ArrayGet ("stmt", 0)); printf ("--> (%s)\n", ArrayGet ("stmt", 1)); printf ("--> (%s)\n", ArrayGet ("stmt", 2)); printf ("--> (%s)\n", ArrayGet ("stmt", 3)); sdb_free (db); return 0; }
meh, we have C for this, this should be done by the bindings. closing
Provide a simple api to work with sdb.