[mw-devel] MARVIN r79 - in branches: . sqlite3
welshbyte at sucs.org
welshbyte at sucs.org
Mon May 29 11:39:12 BST 2006
Author: welshbyte
Date: 2006-05-29 11:39:09 +0100 (Mon, 29 May 2006)
New Revision: 79
Added:
branches/sqlite3/
Modified:
branches/sqlite3/Makefile
branches/sqlite3/sqlite.c
branches/sqlite3/users.db
Log:
Branched to get marvin using sqlite3. Converted users.db to v3 format too but still seems to be some problems with recognising passwords.
Copied: branches/sqlite3 (from rev 78, trunk)
Modified: branches/sqlite3/Makefile
===================================================================
--- trunk/Makefile 2006-05-18 18:20:26 UTC (rev 78)
+++ branches/sqlite3/Makefile 2006-05-29 10:39:09 UTC (rev 79)
@@ -2,7 +2,7 @@
CFLAGS = -std=gnu99 -g -O2 -Wall -Werror -ggdb -fPIC
DEFS = -DHAVE_CONFIG_H -Dunix -DSLANG $(XMLCFLAGS)
LDFLAGS = -s -ggdb
-LIBS = -lxml2 -lsqlite -lslang -lreadline -ltermcap -lcrypt
+LIBS = -lxml2 -lsqlite3 -lslang -lreadline -ltermcap -lcrypt
SERVEROBJS = server.o socket.o session.o xml.o slang.o sqlite.o
CLIENTOBJS = client.o socket.o session.o xml.o slang.o sqlite.o
Modified: branches/sqlite3/sqlite.c
===================================================================
--- trunk/sqlite.c 2006-05-18 18:20:26 UTC (rev 78)
+++ branches/sqlite3/sqlite.c 2006-05-29 10:39:09 UTC (rev 79)
@@ -1,5 +1,5 @@
#include "marvin.h"
-#include <sqlite.h>
+#include <sqlite3.h>
#include <slang/slang.h>
int sldebug = 0;
@@ -23,14 +23,13 @@
int
db_open(char *dbname)
{
- sqlite *db;
- char *error = NULL;
- db = sqlite_open(dbname, O_RDWR, &error);
- if (db == NULL && error != NULL) {
- printf("Error opening db %s: %s\n", dbname, error);
- free(error);
- return 0;
+ sqlite3 *db;
+ int error = sqlite3_open(dbname, &db);
+
+ if (error != SQLITE_OK) {
+ printf("Error opening db %s: %s\n", dbname, sqlite3_errmsg(db));
+ return -1;
}
if (sldebug) printf("SQLite: Opened database as pointer %p\n", db);
return (int)db;
@@ -83,7 +82,7 @@
int db_query(int *db, char *query)
{
- sqlite *sdb = (sqlite *)*db;
+ sqlite3 *sdb = (sqlite3 *)*db;
struct db_result *new;
int ret;
char *error = NULL;
@@ -97,16 +96,17 @@
new->data = NULL;
if (sldebug) printf("SQLite: Creating query result=%p on db=%p\n", new, sdb);
-
- if ((ret=sqlite_exec(sdb, query, db_callback, new, &error))) {
- printf("Error %s (%d) on query %s\n", error, ret, query);
+
+ ret = sqlite3_exec(sdb, query, db_callback, new, &error);
+ if (ret != SQLITE_OK) {
+ printf("Error %s (%d) on query: %s\n", error, ret, query);
free(error);
- return 0;
+ return -1;
}
return (int)new;
}
-/* how many rows int hat result */
+/* how many rows in that result */
int db_numrows(int *result_handle)
{
struct db_result *result = (struct db_result *)*result_handle;
@@ -186,8 +186,8 @@
void db_close(int *db)
{
- sqlite *sdb = (sqlite *)*db;
+ sqlite3 *sdb = (sqlite3 *)*db;
printf("Closing database %p\n", sdb);
- sqlite_close(sdb);
+ sqlite3_close(sdb);
}
Modified: branches/sqlite3/users.db
===================================================================
(Binary files differ)
More information about the mw-devel
mailing list