Cleans up some code and adds documentation

This commit is contained in:
SuperNovaa41 2024-01-31 11:56:34 -05:00
parent ba2acb23ec
commit e449bdd2c5
2 changed files with 22 additions and 7 deletions

View File

@ -13,13 +13,35 @@ enum DB_OPTIONS {
* VA args * VA args
* - Expects book_t if option is ADD * - Expects book_t if option is ADD
* - Expects int if option is REMOVE * - Expects int if option is REMOVE
*
* Handles the whole process of interacting with the database
*/ */
void do_db_entry(enum DB_OPTIONS option, ...); 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 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 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); void remove_from_db(int id, sqlite3* db);
#endif #endif

View File

@ -12,10 +12,6 @@
#define MAX_BUF_LEN 1024 #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[]) void do_ISBN_get(char* argv[])
{ {
// want to hold a max of 14 so we can hold up to ISBN13s // 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."); puts("remove [id] -- Removes a book with the given ID from the book database.");
} }
void process_args(char* argv[]) void process_args(char* argv[])
{ {
int id; int id;
@ -95,8 +90,6 @@ void process_args(char* argv[])
} }
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (1 == argc) { if (1 == argc) {