Added db_init function. It's still a dummy
FossilOrigin-Name: de651c3fa38336b5870cea41368110282ce8a6afda703941e305e4e06116c5ce
This commit is contained in:
		
							
								
								
									
										30
									
								
								src/ac/db.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								src/ac/db.c
									
									
									
									
									
								
							@ -1,6 +1,36 @@
 | 
			
		||||
 | 
			
		||||
#include <sqlite3.h>
 | 
			
		||||
 | 
			
		||||
#include "cw_log.h"
 | 
			
		||||
 | 
			
		||||
static sqlite3 *handle;
 | 
			
		||||
 | 
			
		||||
int db_init()
 | 
			
		||||
{
 | 
			
		||||
	const char * filename="ac.sqlite3";
 | 
			
		||||
	
 | 
			
		||||
	cw_log_debug0("Initi sqlite3 db: %s",filename);
 | 
			
		||||
	int rc = sqlite3_open(filename,&handle);
 | 
			
		||||
	if (rc)
 | 
			
		||||
	{
 | 
			
		||||
		perror ("sqlite");	
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const char * cmd = "CREATE TABLE IF NOT EXISTS aclist (acid TEXT PRIMARY KEY,pass TEXT NOT NULL,activated INTEGER)";
 | 
			
		||||
	rc = sqlite3_exec(handle,cmd,0,0,0);
 | 
			
		||||
	if (rc)
 | 
			
		||||
	{
 | 
			
		||||
		const char *em = sqlite3_errmsg(handle);
 | 
			
		||||
		cw_log(LOG_ERR,"Error executing sql \"%s\" - Error msg: %s",cmd, em);
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user