Yet Another Intercepting Proxy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
781 B

#include "database.h"
sqlite3 *db_open(char *file){
sqlite3 *db;
/* Open database */
int rc = sqlite3_open(file, &db);
if( rc ) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
return NULL;
} else {
fprintf(stderr, "Opened database successfully\n");
return db;
}
}
bool db_file_exists(char *file){
FILE *fp;
if ( (fp = fopen(file, "r")) != NULL) {
fclose(fp);
return true;
} else {
return false;
}
}
bool db_create(char *file){
FILE *fp = fopen(file, "a");
if(fp == NULL) {
printf("file can't be opened\n");
return false;
}
fclose(fp);
sqlite3 *db = db_open(file);
// Do stuff here to create the tables.
// Will probably need Requests and Responses - maybe others
sqlite3_close(db);
return true;
}