summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authoryuzu-eva <cafebabe@disroot.org>2025-06-08 14:33:02 +0200
committeryuzu-eva <cafebabe@disroot.org>2025-06-08 14:33:02 +0200
commit390cbf31635951e46a49ed8657cd2a1635757f19 (patch)
tree89f1d51b926017cc5bbcdd88ad503fb20743223c /main.c
parentb7e05ac5c2cb8f169b1cf66926faddcf7f15b7cc (diff)
changed project structure, adjusted Makefilerefactor
Diffstat (limited to 'main.c')
-rw-r--r--main.c74
1 files changed, 0 insertions, 74 deletions
diff --git a/main.c b/main.c
deleted file mode 100644
index 9dfe71d..0000000
--- a/main.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <stdint.h>
-
-#include "dbhandling.h"
-#include "enum.h"
-
-const uint8_t PATH_MAX = 64;
-const char *filepath = ".local/share/sqlite";
-const char *filename = "library.db";
-
-void print_help(void)
-{
- printf("\n");
- printf("usage: myal MODE TARGET NAME [EPISODE|CHAPTER] \n");
- printf("possible modes are: get|set|add \n");
- printf("possible targets are: anime|manga|book \n");
- printf("EXAMPLES: myal get anime %% | Prints all anime \n");
- printf(" myal set manga Murcielago 10 | Set chapter of " \
- "Murcielago to 10\n");
- printf("mode get is fuzzy; set and add have to match exactly \n");
- printf("See more examples in the readme. \n");
- printf("\n");
-}
-
-int main(int argc, char **argv)
-{
- if (argc < 3) {
- fprintf(stderr, "missing argument...\n");
- print_help();
- exit(69);
- }
-
- args_e mode;
- mode = str2enum(argv[1]);
- args_e target;
- target = str2enum(argv[2]);
- entry_t *entry = malloc(sizeof(entry_t));
- entry->name = malloc(MAX_NAME_LEN);
- entry->author = malloc(MAX_AUTHOR_LEN);
- entry->value = malloc(MAX_VALUE_LEN);
- entry->status = malloc(MAX_STATUS_LEN);
-
- char fullpath[PATH_MAX];
- snprintf(fullpath, PATH_MAX, "%s/%s/%s", getenv("HOME"), filepath, filename);
-
- sqlite3 *db;
- int rc;
-
- rc = sqlite3_open(fullpath, &db);
-
- if (rc) {
- exit_with_error(db, "Can't open database: ");
- }
-
- switch (mode) {
- case GET:
- select_from_table(db, target, entry);
- break;
- case SET:
- update_entry(db, target, entry);
- break;
- case ADD:
- add_entry(db, target, entry);
- break;
- default:
- fprintf(stderr, "unknown option...\n");
- print_help();
- sqlite3_close(db);
- exit(69);
- }
-
- sqlite3_close(db);
- free(entry);
- return 0;
-}