From aa9bb5d3f1f7059bd9dd69d6b5f99acd68d439c2 Mon Sep 17 00:00:00 2001 From: bpc2003 Date: Fri, 14 Mar 2025 09:29:38 -0400 Subject: Added some documentation --- src/lib/keytab.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib/keytab.c') diff --git a/src/lib/keytab.c b/src/lib/keytab.c index 5d0c7dd..74dc47f 100644 --- a/src/lib/keytab.c +++ b/src/lib/keytab.c @@ -5,10 +5,9 @@ #include "mdb.h" -static const struct keytablist empty; - static int hash(char *key); +// getkeys - gets every single key in a key table int *getkeys(struct keytablist *list, int id) { int len = 2; @@ -24,6 +23,8 @@ int *getkeys(struct keytablist *list, int id) return indexes; } +// getkey - gets a single key from a keytable +// if it can't find the key it will return an empty table index struct keytab getkey(struct keytablist *list, int id, char *key) { int idx = hash(key); @@ -37,6 +38,8 @@ struct keytab getkey(struct keytablist *list, int id, char *key) return list[id].tab[idx]; } +// setkey - adds the given pair to the given key table +// if setkey fails it will return 1 otherwise 0 int setkey(struct keytablist **list, int id, char *pair) { if (id >= (*list)[0].len) { @@ -87,6 +90,7 @@ int setkey(struct keytablist **list, int id, char *pair) return 0; } +// delkey - removes the given key from the given key table void delkey(struct keytablist *list, int id, char *key) { int idx = hash(key); -- cgit v1.2.3