summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbpc2003 <wpesfriendnva@gmail.com>2025-04-21 18:01:57 -0400
committerbpc2003 <wpesfriendnva@gmail.com>2025-04-21 18:01:57 -0400
commitdc83060f785031f1607dc4152e678472bff06b8a (patch)
tree93455eea782710ed38ff9cd6c31183597711295d
parent6722eaf826a14b7f2c21a2cbfb24c21389a4818e (diff)
Update documentation in mdb.h
-rw-r--r--src/lib/batch.c2
-rw-r--r--src/lib/delkeys.c0
-rw-r--r--src/lib/getkeys.c6
-rw-r--r--src/lib/keytab.c2
-rw-r--r--src/lib/mdb.h21
-rw-r--r--src/lib/setkeys.c0
6 files changed, 23 insertions, 8 deletions
diff --git a/src/lib/batch.c b/src/lib/batch.c
index 2d75083..0534daf 100644
--- a/src/lib/batch.c
+++ b/src/lib/batch.c
@@ -5,6 +5,8 @@
#include "mdb.h"
+// TODO: move these functions into seperate files
+
static int setkey_helper(void *thr_data);
static int delkey_helper(void *thr_data);
static int *clone(int n);
diff --git a/src/lib/delkeys.c b/src/lib/delkeys.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/lib/delkeys.c
diff --git a/src/lib/getkeys.c b/src/lib/getkeys.c
index 85b3ba1..98442a3 100644
--- a/src/lib/getkeys.c
+++ b/src/lib/getkeys.c
@@ -5,6 +5,8 @@
#include "mdb.h"
+extern tabidx_t getkey(tablist_t *list, int id, char *key);
+
static int getkeys_helper(void *data);
struct params {
@@ -44,9 +46,9 @@ tablist_t *getkeys(tablist_t *list, int id, char **keys, int klen)
}
mtx_destroy(&mtx);
- if (!rc) {
+ if (!rc)
return indexes;
- } else {
+ else {
free(indexes);
return NULL;
}
diff --git a/src/lib/keytab.c b/src/lib/keytab.c
index 9ef4089..e9f744a 100644
--- a/src/lib/keytab.c
+++ b/src/lib/keytab.c
@@ -4,6 +4,8 @@
#include "mdb.h"
+// TODO: move all these functions into seperate files
+
static int hash(char *key);
static char **getkv(char *pair);
diff --git a/src/lib/mdb.h b/src/lib/mdb.h
index f1284b7..cb0502d 100644
--- a/src/lib/mdb.h
+++ b/src/lib/mdb.h
@@ -18,17 +18,26 @@ typedef struct {
tabidx_t tab[TABLEN];
} tablist_t;
-// Table operations
-// TODO: Make this private
-tabidx_t getkey(tablist_t *list, int id, char *key);
+/* getkeys: gets the provided keys from the provided id,
+ * if the id is set to -1, it will get the provided key from every document,
+ * if keys is NULL, it will get every key. */
+tablist_t *getkeys(tablist_t *list, int id, char **keys, int len);
-// Batch Operations
-tablist_t *getkeys(tablist_t *list, int id, char **keys, int len); // TODO: Reimplement getkeys
+/* setkeys: sets the provided key-value pairs in the provided object,
+ * if the id is -1, it will set the provided pairs in every object. */
int setkeys(tablist_t **list, int id, char **pairs, int len);
+
+/* delkeys: deletes the provided keys from the provided id,
+ * if the id is -1, it will delete the provided key from every document,
+ * if keys is NULL it, will delete every key. */
int delkeys(tablist_t *list, int id, char **keys, int len);
-// file operations
+/* readdb: reads the provided db file,
+ * if the filename is NULL, it will return an empty table list,
+ * if the file format is invalid, it will return NULL. */
tablist_t *readdb(char *filename);
+
+/* writedb: writes a table list to a database file. */
void writedb(char *filename, tablist_t *list);
#endif
diff --git a/src/lib/setkeys.c b/src/lib/setkeys.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/lib/setkeys.c