diff options
author | bpc2003 <wpesfriendnva@gmail.com> | 2025-04-24 17:08:08 -0400 |
---|---|---|
committer | bpc2003 <wpesfriendnva@gmail.com> | 2025-04-24 17:08:08 -0400 |
commit | 2b7a3a815fb5d0b5155deec5f613730e898e4100 (patch) | |
tree | 00db87ef554335e1c9871330703d86d0247a4ee8 /src | |
parent | 5b0d930e9e2605add559a70591573ffaa2fd8404 (diff) |
Update Documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/include/engine/delkeys.c (renamed from src/lib/delkeys.c) | 21 | ||||
-rw-r--r-- | src/include/engine/engine.h (renamed from src/lib/mdb.h) | 4 | ||||
-rw-r--r-- | src/include/engine/file.c (renamed from src/lib/file.c) | 8 | ||||
-rw-r--r-- | src/include/engine/getkeys.c (renamed from src/lib/getkeys.c) | 2 | ||||
-rw-r--r-- | src/include/engine/setkeys.c (renamed from src/lib/setkeys.c) | 2 | ||||
-rw-r--r-- | src/include/engine/utils.c (renamed from src/lib/utils.c) | 0 | ||||
-rw-r--r-- | src/include/engine/utils.h (renamed from src/lib/utils.h) | 2 | ||||
-rw-r--r-- | src/include/mdb.h | 6 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/test.c | 2 |
10 files changed, 26 insertions, 23 deletions
diff --git a/src/lib/delkeys.c b/src/include/engine/delkeys.c index a828e8d..ad9c228 100644 --- a/src/lib/delkeys.c +++ b/src/include/engine/delkeys.c @@ -2,14 +2,13 @@ #include <stdlib.h> #include <string.h> -#include "mdb.h" +#include "engine.h" #include "utils.h" static int delkey_helper(void *thr_data); static int delkey(tablist_t *, int, char *); static struct params *pass(mtx_t *mtx, tablist_t *list, char **keys, int len, int id); - struct params { mtx_t *mtx; tablist_t *copy; @@ -27,14 +26,14 @@ int delkeys(tablist_t *list, int id, char **keys, int len) if (mtx_init(&mtx, mtx_plain) != thrd_success) return -2; int rc = 0; - tablist_t *delkey_copy = calloc(list[0].len, sizeof(tablist_t)); - copytab(delkey_copy, list); + tablist_t *copy = calloc(list[0].len, sizeof(tablist_t)); + copytab(copy, list); if (id == -1) { thrd_t *thrds = calloc(list[0].len, sizeof(thrd_t)); - for (int i = 0; i < delkey_copy[0].len; ++i) - thrd_create(&thrds[i], delkey_helper, pass(&mtx, delkey_copy, keys, len, i)); - for (int i = 0; i < delkey_copy[0].len; ++i) { + for (int i = 0; i < copy[0].len; ++i) + thrd_create(&thrds[i], delkey_helper, pass(&mtx, copy, keys, len, i)); + for (int i = 0; i < copy[0].len; ++i) { if (rc) thrd_join(thrds[i], NULL); else @@ -42,15 +41,15 @@ int delkeys(tablist_t *list, int id, char **keys, int len) } free(thrds); } else - rc = delkey_helper(pass(&mtx, delkey_copy, keys, len, id)); + rc = delkey_helper(pass(&mtx, copy, keys, len, id)); if (!rc) { dellist(list); - memmove(list, delkey_copy, delkey_copy[0].len * sizeof(tablist_t)); + memmove(list, copy, copy[0].len * sizeof(tablist_t)); } else - dellist(delkey_copy); + dellist(copy); mtx_destroy(&mtx); - free(delkey_copy); + free(copy); return rc; } diff --git a/src/lib/mdb.h b/src/include/engine/engine.h index cb0502d..d233bdd 100644 --- a/src/lib/mdb.h +++ b/src/include/engine/engine.h @@ -1,5 +1,5 @@ -#ifndef MDB_H -#define MDB_H +#ifndef ENGINE_H +#define ENGINE_H #define TABLEN 1024 diff --git a/src/lib/file.c b/src/include/engine/file.c index 8b0c715..4da8b2d 100644 --- a/src/lib/file.c +++ b/src/include/engine/file.c @@ -2,13 +2,11 @@ #include <stdlib.h> #include <string.h> -#include "mdb.h" +#include "engine.h" static char *getpair(int *c, FILE *fp); -// readdb - reads the given file into a key table list -// if fp returns NULL it will return the empty list -// if readdb fails it will return NULL +// TODO: reimplement this to read file in FI format tablist_t *readdb(char *filename) { int len = 2; @@ -51,7 +49,7 @@ fail: return NULL; } -// writedb - writes a keytablist to a given file +// TODO: rewrite this function to write data in FI format void writedb(char *filename, tablist_t *list) { FILE *fp = fopen(filename, "wb"); diff --git a/src/lib/getkeys.c b/src/include/engine/getkeys.c index ab1cb2f..ae2eb73 100644 --- a/src/lib/getkeys.c +++ b/src/include/engine/getkeys.c @@ -3,7 +3,7 @@ #include <ctype.h> #include <threads.h> -#include "mdb.h" +#include "engine.h" #include "utils.h" static tabidx_t getkey(tablist_t *list, int id, char *key); diff --git a/src/lib/setkeys.c b/src/include/engine/setkeys.c index f52ab48..34ef3d2 100644 --- a/src/lib/setkeys.c +++ b/src/include/engine/setkeys.c @@ -3,7 +3,7 @@ #include <stdlib.h> #include <threads.h> -#include "mdb.h" +#include "engine.h" #include "utils.h" static int setkey_helper(void *thr_data); diff --git a/src/lib/utils.c b/src/include/engine/utils.c index 909c123..909c123 100644 --- a/src/lib/utils.c +++ b/src/include/engine/utils.c diff --git a/src/lib/utils.h b/src/include/engine/utils.h index 99a8efa..54bfc17 100644 --- a/src/lib/utils.h +++ b/src/include/engine/utils.h @@ -1,7 +1,7 @@ #ifndef UTILS_H #define UTILS_H -#include "mdb.h" +#include "engine.h" // dellist: deletes the provided table void dellist(tablist_t *list); diff --git a/src/include/mdb.h b/src/include/mdb.h new file mode 100644 index 0000000..cba4aa8 --- /dev/null +++ b/src/include/mdb.h @@ -0,0 +1,6 @@ +#ifndef MDB_H +#define MDB_H + +#include "engine/engine.h" + +#endif @@ -3,7 +3,7 @@ #include <string.h> #include <ctype.h> -#include "lib/mdb.h" +#include "include/mdb.h" #include "cmd.h" int getid(char *selector); @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> -#include "lib/mdb.h" +#include "include/mdb.h" void test_setkeys(void) { |