diff --git a/include/msgapi.h b/include/msgapi.h index 27df757..38ccf70 100644 --- a/include/msgapi.h +++ b/include/msgapi.h @@ -109,11 +109,21 @@ MsgGetDir(MsgApiDirectory directory, char *buffer, size_t buffer_size); #define MSGSQL_STMT_SLEEP_MS 250 MsgSQLHandle *MsgSQLOpen(char *path, BongoMemStack *memstack, int locktimeoutms); -void MsgSQLClose(MsgSQLHandle *handle); BongoMemStack *MsgSQLGetMemStack(MsgSQLHandle *handle); -void MsgSQLSetMemStack(MsgSQLHandle *handle, BongoMemStack *memstack); -void MsgSQLSetLockTimeout(MsgSQLHandle *handle, int timeoutms); MsgSQLStatement *MsgSQLPrepare(MsgSQLHandle *handle, const char *statement, MsgSQLStatement *stmt); +void MsgSQLClose(MsgSQLHandle *handle); +void MsgSQLSetMemStack(MsgSQLHandle *handle, BongoMemStack *memstack); +void MsgSQLSetLockTimeout(MsgSQLHandle *handle, int timeoutms); +void MsgSQLReset(MsgSQLHandle *handle); +int MsgSQLBeginTransaction(MsgSQLHandle *handle); +int MsgSQLCommitTransaction(MsgSQLHandle *handle); +int MsgSQLAbortTransaction(MsgSQLHandle *handle); +int MsgSQLCancelTransactions(MsgSQLHandle *handle); +int MsgSQLBindString(MsgSQLStatement *stmt, int var, const char *str, BOOL nullify); +int MsgSQLExecute(MsgSQLHandle *handle, MsgSQLStatement *_stmt); +int MsgSQLResults(MsgSQLHandle *handle, MsgSQLStatement *_stmt); +void MsgSQLFinalize(MsgSQLStatement *stmt); + // Misc. util functions diff --git a/src/libs/msgapi/Bongo.rules b/src/libs/msgapi/Bongo.rules index e6d0e6c..23e8e9f 100644 --- a/src/libs/msgapi/Bongo.rules +++ b/src/libs/msgapi/Bongo.rules @@ -41,7 +41,8 @@ auth_std_libadd = \ auth_LTLIBRARIES = libauthsqlite3.la -libauthsqlite3_la_SOURCES = \ +libauthsqlite3_la_SOURCES = \ + src/libs/msgapi/auth-backends/sqlite.h \ src/libs/msgapi/auth-backends/sqlite.c libauthsqlite3_la_CPPFLAGS = $(AM_CPPFLAGS) $(SQLITE_CFLAGS) diff --git a/src/libs/msgapi/auth-backends/sqlite.c b/src/libs/msgapi/auth-backends/sqlite.c index a4ae8d5..ac7bc38 100644 --- a/src/libs/msgapi/auth-backends/sqlite.c +++ b/src/libs/msgapi/auth-backends/sqlite.c @@ -12,6 +12,8 @@ #include #include +#include "sqlite.h" + typedef struct { MsgSQLStatement find_user; MsgSQLStatement auth_user; @@ -52,7 +54,7 @@ AuthSqlite_Install(void) MsgSQLHandle *handle; struct stat buf; - AuthSqlite_GetDbPath(&path, XPL_MAX_PATH); + AuthSqlite_GetDbPath(path, XPL_MAX_PATH); if (stat(path, &buf) == 0) { // FIXME: db already exists - for now, remove, but could/should be more gentle unlink(path); @@ -95,7 +97,7 @@ AuthSqlite_FindUser(const char *user) MsgSQLHandle *handle; int users = -1; - AuthSqlite_GetDbPath(&path, XPL_MAX_PATH); + AuthSqlite_GetDbPath(path, XPL_MAX_PATH); handle = MsgSQLOpen(path, NULL, 1000); // Log error? @@ -142,7 +144,7 @@ AuthSqlite_VerifyPassword(const char *user, const char *password) if (AuthSqlite_GenerateHash(user, password, hash, XPLHASH_SHA1_LENGTH + 1) != 0) return 1; - AuthSqlite_GetDbPath(&path, XPL_MAX_PATH); + AuthSqlite_GetDbPath(path, XPL_MAX_PATH); handle = MsgSQLOpen(path, NULL, 1000); // Log error? @@ -188,7 +190,7 @@ AuthSqlite_AddUser(const char *user) char path[XPL_MAX_PATH + 1]; MsgSQLHandle *handle; - AuthSqlite_GetDbPath(&path, XPL_MAX_PATH); + AuthSqlite_GetDbPath(path, XPL_MAX_PATH); handle = MsgSQLOpen(path, NULL, 1000); if (NULL == handle) { Log(LOG_ERROR, "Cannot open user db '%s'", path); @@ -223,7 +225,7 @@ AuthSqlite_SetPassword(const char *user, const char *password) if (AuthSqlite_GenerateHash(user, password, hash, XPLHASH_SHA1_LENGTH + 1) != 0) return -1; - AuthSqlite_GetDbPath(&path, XPL_MAX_PATH); + AuthSqlite_GetDbPath(path, XPL_MAX_PATH); handle = MsgSQLOpen(path, NULL, 1000); if (NULL == handle) { Log(LOG_ERROR, "Cannot open user db '%s'", path); diff --git a/src/libs/msgapi/auth-backends/sqlite.h b/src/libs/msgapi/auth-backends/sqlite.h new file mode 100644 index 0000000..2f2f8b1 --- /dev/null +++ b/src/libs/msgapi/auth-backends/sqlite.h @@ -0,0 +1,11 @@ + +int AuthSqlite_GetDbPath(char *path, size_t size); +int AuthSqlite_GenerateHash(const char *username, const char *password, char *result, size_t result_len); +int AuthSqlite_Install(void); +int AuthSqlite_FindUser(const char *user); +int AuthSqlite_VerifyPassword(const char *user, const char *password); +int AuthSqlite_AddUser(const char *user); +int AuthSqlite_SetPassword(const char *user, const char *password); +int AuthSqlite_GetUserStore(const char *user, struct sockaddr_in *store); +int AuthSqlite_UserList(BongoArray **list); +int AuthSqlite_InterfaceVersion(void);