X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/832ed81ad97ebb44edbd9d61bfb5e28e9f073c32..1e75ec9c7de9517cee3952a469bd4157378e3f81:/bandb/rsdb_sqlite3.c diff --git a/bandb/rsdb_sqlite3.c b/bandb/rsdb_sqlite3.c index 2df2bf6c..97eff0e6 100644 --- a/bandb/rsdb_sqlite3.c +++ b/bandb/rsdb_sqlite3.c @@ -3,7 +3,7 @@ * * Copyright (C) 2003-2006 Lee Hardy * Copyright (C) 2003-2006 ircd-ratbox development team - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -27,8 +27,6 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: rsdb_sqlite3.c 26182 2008-11-11 02:52:41Z androsyn $ */ #include "stdinc.h" #include "rsdb.h" @@ -47,7 +45,7 @@ mlog(const char *errstr, ...) char buf[256]; va_list ap; va_start(ap, errstr); - rb_vsnprintf(buf, sizeof(buf), errstr, ap); + vsnprintf(buf, sizeof(buf), errstr, ap); va_end(ap); error_cb(buf); } @@ -58,31 +56,31 @@ mlog(const char *errstr, ...) int rsdb_init(rsdb_error_cb * ecb) { - const char *bandb_dpath; + const char *bandb_dbpath_env; char dbpath[PATH_MAX]; char errbuf[128]; error_cb = ecb; /* try a path from the environment first, useful for basedir overrides */ - bandb_dpath = getenv("BANDB_DPATH"); + bandb_dbpath_env = getenv("BANDB_DBPATH"); - if(bandb_dpath != NULL) - rb_snprintf(dbpath, sizeof(dbpath), "%s/etc/ban.db", bandb_dpath); + if(bandb_dbpath_env != NULL) + rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath)); else rb_strlcpy(dbpath, DBPATH, sizeof(dbpath)); - + if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) { - rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s", + snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s", sqlite3_errmsg(rb_bandb)); mlog(errbuf); return -1; } if(access(dbpath, W_OK)) { - rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno)); + snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno)); mlog(errbuf); - return -1; + return -1; } return 0; } @@ -120,7 +118,7 @@ static int rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames) { rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc); - (cb) (argc, (const char **)argv); + (cb) (argc, (const char **)(void *)argv); return 0; }