From e449bdd2c5820c9c7241a395f7cec4715aacda36 Mon Sep 17 00:00:00 2001 From: SuperNovaa41 Date: Wed, 31 Jan 2024 11:56:34 -0500 Subject: [PATCH] Cleans up some code and adds documentation --- src/db.h | 22 ++++++++++++++++++++++ src/main.c | 7 ------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/db.h b/src/db.h index 389c71d..035d94e 100644 --- a/src/db.h +++ b/src/db.h @@ -13,13 +13,35 @@ enum DB_OPTIONS { * VA args * - Expects book_t if option is ADD * - Expects int if option is REMOVE + * + * Handles the whole process of interacting with the database */ void do_db_entry(enum DB_OPTIONS option, ...); +/** + * void setup_db + * sqlite3* db - The database + * + * Just creates the database if it doesn't exist. + */ void setup_db(sqlite3* db); +/** + * void add_to_db + * book_t* book - The struct full of book information + * sqlite3* db - The database + * + * Adds the book information to the database + */ void add_to_db(book_t* book, sqlite3* db); +/** + * void remove_from_db + * int id - The id of the book to remove + * sqlite3* db - The database + * + * Removes the given ID (and its associated book) from the database. + */ void remove_from_db(int id, sqlite3* db); #endif diff --git a/src/main.c b/src/main.c index 4c6e78c..7cbbda2 100644 --- a/src/main.c +++ b/src/main.c @@ -12,10 +12,6 @@ #define MAX_BUF_LEN 1024 -/** - * TODO: we need to check the csv file for duplicates - * TODO: allow us to remove a book from the csv and update the ids - */ void do_ISBN_get(char* argv[]) { // want to hold a max of 14 so we can hold up to ISBN13s @@ -70,7 +66,6 @@ void print_help_menu(char* program) puts("remove [id] -- Removes a book with the given ID from the book database."); } - void process_args(char* argv[]) { int id; @@ -95,8 +90,6 @@ void process_args(char* argv[]) } } - - int main(int argc, char* argv[]) { if (1 == argc) {