summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/xdbms.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/include/xdbms.c b/src/include/xdbms.c
index eb6193e..36ad7da 100644
--- a/src/include/xdbms.c
+++ b/src/include/xdbms.c
@@ -1,9 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "engine/engine.h"
-#include "xml/xml.h"
#include "xdbms.h"
+#include "xml/xml.h"
static tablist_t *db;
@@ -25,7 +26,41 @@ void xdb_close(void) {
char *xdb_stmt(char *stmt) {
map_t *decoded = decode(stmt);
- printf("%s\n", encode(decoded));
+
+ if (!strcmp(decoded->tag, "get")) {
+ int id = -1, len = 0;
+ char **keys = NULL;
+ if (decoded->n_attrs > 0)
+ id = atoi(decoded->attrs[0].value);
+ tablist_t *tmp = getkeys(db, id, keys, len);
+ for (int i = 0; i < tmp[0].len; ++i) {
+ printf("{ id: %d ", tmp[0].len > 1 ? i : id);
+ for (int j = 0; tmp[i].tab[j].flag; ++j) {
+ printf("%s: ", tmp[i].tab[j].key);
+ switch (tmp[i].tab[j].flag) {
+ case 1:
+ printf("%g ", tmp[i].tab[j].value.num);
+ break;
+ case 2:
+ printf("%s ",
+ tmp[i].tab[j].value.boolean ? "true" : "false");
+ break;
+ case 3:
+ printf("%s ", tmp[i].tab[j].value.str);
+ break;
+ }
+ }
+ printf("}\n");
+ }
+ free(tmp);
+ } else if (!strcmp(decoded->tag, "set")) {
+ ;
+ } else if (!strcmp(decoded->tag, "del")) {
+ ;
+ } else {
+ printf("Unknown request: %s\n", decoded->tag);
+ }
+
freemap(decoded);
return NULL;
}