*
* Copyright (C) 2003-2006 Lee Hardy <leeh@leeh.co.uk>
* 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:
* 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"
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);
}
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;
}
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;
}