#include <time.h>
#include "stdinc.h"
-#include "common.h"
#include "rsdb.h"
#define EmptyString(x) ((x == NULL) || (*(x) == '\0'))
-#define CheckEmpty(x) EmptyString(x) ? "" : x
#define BT_VERSION "0.4.1"
static void export_config(const char *conf, int id);
static void import_config(const char *conf, int id);
static void check_schema(void);
-static void print_help(int i_exit);
+static void print_help(int i_exit) __attribute__((noreturn));
static void wipe_schema(void);
static void drop_dupes(const char *user, const char *host, const char *t);
rb_strlcpy(etc, ETCPATH, sizeof(ETCPATH));
fprintf(stdout,
- "* charybdis bantool v.%s\n", BT_VERSION);
+ "* solanum bantool v.%s\n", BT_VERSION);
if(flag.pretend == false)
{
/* checking for our files to import or export */
for(i = 0; i < LAST_BANDB_TYPE; i++)
{
- snprintf(conf, sizeof(conf), "%s/%s.conf%s",
- etc, bandb_table[i], bandb_suffix[i]);
+ if (snprintf(conf, sizeof(conf), "%s/%s.conf%s",
+ etc, bandb_table[i], bandb_suffix[i]) >= sizeof(conf)) {
+ fprintf(stderr, "* Error: Config filename too long\n");
+ exit(EXIT_FAILURE);
+ }
if(flag.import && flag.pretend == false)
rsdb_transaction(RSDB_TRANS_START);
NULL
};
- for(i = 0; i < LAST_BANDB_TYPE; i++)
+ for(i = 0; i < LAST_BANDB_TYPE; i += 2 /* skip over _PERM */)
{
if(!table_exists(bandb_table[i]))
{
columns[j], type);
}
}
-
- i++; /* skip over .perm */
}
}
}
/**
- * completly wipes out an existing ban.db of all entries.
+ * completely wipes out an existing ban.db of all entries.
*/
static void
wipe_schema(void)
{
int i;
rsdb_transaction(RSDB_TRANS_START);
- for(i = 0; i < LAST_BANDB_TYPE; i++)
+ for(i = 0; i < LAST_BANDB_TYPE; i += 2 /* double increment to skip over _PERM */)
{
rsdb_exec(NULL, "DROP TABLE %s", bandb_table[i]);
- i++; /* double increment to skip over .perm */
}
rsdb_transaction(RSDB_TRANS_END);
void
print_help(int i_exit)
{
- fprintf(stderr, "bantool v.%s - the charybdis database tool.\n", BT_VERSION);
+ fprintf(stderr, "bantool v.%s - the solanum database tool.\n", BT_VERSION);
fprintf(stderr, "Copyright (C) 2008 Daniel J Reidy <dubkat@gmail.com>\n");
fprintf(stderr, "This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
fprintf(stderr, " -s : Reclaim empty slack space the database may be taking up.\n");
fprintf(stderr, " -u : Update the database tables to support any new features.\n");
fprintf(stderr,
- " This is automaticlly done if you are importing or exporting\n");
+ " This is automatically done if you are importing or exporting\n");
fprintf(stderr, " but should be run whenever you upgrade the ircd.\n");
fprintf(stderr,
" -p : pretend, checks for the configs, and parses them, then tells you some data...\n");
fprintf(stderr, " but does not touch your database.\n");
fprintf(stderr,
" -v : Be verbose... and it *is* very verbose! (intended for debugging)\n");
- fprintf(stderr, " -d : Enable checking for redunant entries.\n");
- fprintf(stderr, " -w : Completly wipe your database clean. May be used with -i \n");
+ fprintf(stderr, " -d : Enable checking for redundant entries.\n");
+ fprintf(stderr, " -w : Completely wipe your database clean. May be used with -i \n");
fprintf(stderr,
" path : An optional directory containing old ratbox configs for import, or export.\n");
fprintf(stderr, " If not specified, it looks in PREFIX/etc.\n");