From 390cbf31635951e46a49ed8657cd2a1635757f19 Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Sun, 8 Jun 2025 14:33:02 +0200 Subject: changed project structure, adjusted Makefile --- main.c | 74 ------------------------------------------------------------------ 1 file changed, 74 deletions(-) delete mode 100644 main.c (limited to 'main.c') 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 - -#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; -} -- cgit v1.2.3