diff options
| author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
|---|---|---|
| committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
| commit | 6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 (patch) | |
| tree | 91b0841faf23087ebe0c74dd4269d181a383f1e7 /src/chanserv.c | |
| parent | 069409cd99cf78ab8bf87a1fe69a833576414fd3 (diff) | |
Insane commit of doom: s/ \t/g
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1681 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/chanserv.c')
| -rw-r--r-- | src/chanserv.c | 3536 |
1 files changed, 1768 insertions, 1768 deletions
diff --git a/src/chanserv.c b/src/chanserv.c index 5e92ce3dc..e95a2a238 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -23,97 +23,97 @@ ChannelInfo *chanlists[256]; static int def_levels[][2] = { - { CA_AUTOOP, 5 }, - { CA_AUTOVOICE, 3 }, - { CA_AUTODEOP, -1 }, - { CA_NOJOIN, -2 }, - { CA_INVITE, 5 }, - { CA_AKICK, 10 }, - { CA_SET, ACCESS_INVALID }, - { CA_CLEAR, ACCESS_INVALID }, - { CA_UNBAN, 5 }, - { CA_OPDEOP, 5 }, - { CA_ACCESS_LIST, 1 }, - { CA_ACCESS_CHANGE, 10 }, - { CA_MEMO, 10 }, - { CA_ASSIGN, ACCESS_INVALID }, - { CA_BADWORDS, 10 }, - { CA_NOKICK, 1 }, - { CA_FANTASIA, 3 }, - { CA_SAY, 5 }, - { CA_GREET, 5 }, - { CA_VOICEME, 3 }, - { CA_VOICE, 5 }, - { CA_GETKEY, 5 }, - { CA_AUTOHALFOP, 4 }, - { CA_AUTOPROTECT, 10 }, - { CA_OPDEOPME, 5 }, - { CA_HALFOPME, 4 }, - { CA_HALFOP, 5 }, - { CA_PROTECTME, 10 }, - { CA_PROTECT, ACCESS_INVALID }, - { CA_KICKME, 5 }, - { CA_KICK, 5 }, - { CA_SIGNKICK, ACCESS_INVALID }, - { CA_BANME, 5 }, - { CA_BAN, 5 }, - { CA_TOPIC, ACCESS_INVALID }, - { CA_INFO, ACCESS_INVALID }, - { -1 } + { CA_AUTOOP, 5 }, + { CA_AUTOVOICE, 3 }, + { CA_AUTODEOP, -1 }, + { CA_NOJOIN, -2 }, + { CA_INVITE, 5 }, + { CA_AKICK, 10 }, + { CA_SET, ACCESS_INVALID }, + { CA_CLEAR, ACCESS_INVALID }, + { CA_UNBAN, 5 }, + { CA_OPDEOP, 5 }, + { CA_ACCESS_LIST, 1 }, + { CA_ACCESS_CHANGE, 10 }, + { CA_MEMO, 10 }, + { CA_ASSIGN, ACCESS_INVALID }, + { CA_BADWORDS, 10 }, + { CA_NOKICK, 1 }, + { CA_FANTASIA, 3 }, + { CA_SAY, 5 }, + { CA_GREET, 5 }, + { CA_VOICEME, 3 }, + { CA_VOICE, 5 }, + { CA_GETKEY, 5 }, + { CA_AUTOHALFOP, 4 }, + { CA_AUTOPROTECT, 10 }, + { CA_OPDEOPME, 5 }, + { CA_HALFOPME, 4 }, + { CA_HALFOP, 5 }, + { CA_PROTECTME, 10 }, + { CA_PROTECT, ACCESS_INVALID }, + { CA_KICKME, 5 }, + { CA_KICK, 5 }, + { CA_SIGNKICK, ACCESS_INVALID }, + { CA_BANME, 5 }, + { CA_BAN, 5 }, + { CA_TOPIC, ACCESS_INVALID }, + { CA_INFO, ACCESS_INVALID }, + { -1 } }; LevelInfo levelinfo[] = { - { CA_AUTODEOP, "AUTODEOP", CHAN_LEVEL_AUTODEOP }, - { CA_AUTOHALFOP, "AUTOHALFOP", CHAN_LEVEL_AUTOHALFOP }, - { CA_AUTOOP, "AUTOOP", CHAN_LEVEL_AUTOOP }, + { CA_AUTODEOP, "AUTODEOP", CHAN_LEVEL_AUTODEOP }, + { CA_AUTOHALFOP, "AUTOHALFOP", CHAN_LEVEL_AUTOHALFOP }, + { CA_AUTOOP, "AUTOOP", CHAN_LEVEL_AUTOOP }, { CA_AUTOPROTECT, "", CHAN_LEVEL_AUTOPROTECT }, - { CA_AUTOVOICE, "AUTOVOICE", CHAN_LEVEL_AUTOVOICE }, - { CA_NOJOIN, "NOJOIN", CHAN_LEVEL_NOJOIN }, - { CA_SIGNKICK, "SIGNKICK", CHAN_LEVEL_SIGNKICK }, - { CA_ACCESS_LIST, "ACC-LIST", CHAN_LEVEL_ACCESS_LIST }, + { CA_AUTOVOICE, "AUTOVOICE", CHAN_LEVEL_AUTOVOICE }, + { CA_NOJOIN, "NOJOIN", CHAN_LEVEL_NOJOIN }, + { CA_SIGNKICK, "SIGNKICK", CHAN_LEVEL_SIGNKICK }, + { CA_ACCESS_LIST, "ACC-LIST", CHAN_LEVEL_ACCESS_LIST }, { CA_ACCESS_CHANGE, "ACC-CHANGE", CHAN_LEVEL_ACCESS_CHANGE }, - { CA_AKICK, "AKICK", CHAN_LEVEL_AKICK }, - { CA_SET, "SET", CHAN_LEVEL_SET }, - { CA_BAN, "BAN", CHAN_LEVEL_BAN }, - { CA_BANME, "BANME", CHAN_LEVEL_BANME }, - { CA_CLEAR, "CLEAR", CHAN_LEVEL_CLEAR }, - { CA_GETKEY, "GETKEY", CHAN_LEVEL_GETKEY }, - { CA_HALFOP, "HALFOP", CHAN_LEVEL_HALFOP }, - { CA_HALFOPME, "HALFOPME", CHAN_LEVEL_HALFOPME }, - { CA_INFO, "INFO", CHAN_LEVEL_INFO }, - { CA_KICK, "KICK", CHAN_LEVEL_KICK }, - { CA_KICKME, "KICKME", CHAN_LEVEL_KICKME }, - { CA_INVITE, "INVITE", CHAN_LEVEL_INVITE }, - { CA_OPDEOP, "OPDEOP", CHAN_LEVEL_OPDEOP }, - { CA_OPDEOPME, "OPDEOPME", CHAN_LEVEL_OPDEOPME }, - { CA_PROTECT, "", CHAN_LEVEL_PROTECT }, - { CA_PROTECTME, "", CHAN_LEVEL_PROTECTME }, - { CA_TOPIC, "TOPIC", CHAN_LEVEL_TOPIC }, - { CA_UNBAN, "UNBAN", CHAN_LEVEL_UNBAN }, - { CA_VOICE, "VOICE", CHAN_LEVEL_VOICE }, - { CA_VOICEME, "VOICEME", CHAN_LEVEL_VOICEME }, - { CA_MEMO, "MEMO", CHAN_LEVEL_MEMO }, - { CA_ASSIGN, "ASSIGN", CHAN_LEVEL_ASSIGN }, - { CA_BADWORDS, "BADWORDS", CHAN_LEVEL_BADWORDS }, - { CA_FANTASIA, "FANTASIA", CHAN_LEVEL_FANTASIA }, - { CA_GREET, "GREET", CHAN_LEVEL_GREET }, - { CA_NOKICK, "NOKICK", CHAN_LEVEL_NOKICK }, - { CA_SAY, "SAY", CHAN_LEVEL_SAY }, - { -1 } + { CA_AKICK, "AKICK", CHAN_LEVEL_AKICK }, + { CA_SET, "SET", CHAN_LEVEL_SET }, + { CA_BAN, "BAN", CHAN_LEVEL_BAN }, + { CA_BANME, "BANME", CHAN_LEVEL_BANME }, + { CA_CLEAR, "CLEAR", CHAN_LEVEL_CLEAR }, + { CA_GETKEY, "GETKEY", CHAN_LEVEL_GETKEY }, + { CA_HALFOP, "HALFOP", CHAN_LEVEL_HALFOP }, + { CA_HALFOPME, "HALFOPME", CHAN_LEVEL_HALFOPME }, + { CA_INFO, "INFO", CHAN_LEVEL_INFO }, + { CA_KICK, "KICK", CHAN_LEVEL_KICK }, + { CA_KICKME, "KICKME", CHAN_LEVEL_KICKME }, + { CA_INVITE, "INVITE", CHAN_LEVEL_INVITE }, + { CA_OPDEOP, "OPDEOP", CHAN_LEVEL_OPDEOP }, + { CA_OPDEOPME, "OPDEOPME", CHAN_LEVEL_OPDEOPME }, + { CA_PROTECT, "", CHAN_LEVEL_PROTECT }, + { CA_PROTECTME, "", CHAN_LEVEL_PROTECTME }, + { CA_TOPIC, "TOPIC", CHAN_LEVEL_TOPIC }, + { CA_UNBAN, "UNBAN", CHAN_LEVEL_UNBAN }, + { CA_VOICE, "VOICE", CHAN_LEVEL_VOICE }, + { CA_VOICEME, "VOICEME", CHAN_LEVEL_VOICEME }, + { CA_MEMO, "MEMO", CHAN_LEVEL_MEMO }, + { CA_ASSIGN, "ASSIGN", CHAN_LEVEL_ASSIGN }, + { CA_BADWORDS, "BADWORDS", CHAN_LEVEL_BADWORDS }, + { CA_FANTASIA, "FANTASIA", CHAN_LEVEL_FANTASIA }, + { CA_GREET, "GREET", CHAN_LEVEL_GREET }, + { CA_NOKICK, "NOKICK", CHAN_LEVEL_NOKICK }, + { CA_SAY, "SAY", CHAN_LEVEL_SAY }, + { -1 } }; int levelinfo_maxwidth = 0; CSModeUtil csmodeutils[] = { - { "DEOP", "deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, - { "OP", "op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, - { "DEVOICE", "devoice", "-v", 0, CA_VOICE, CA_VOICEME }, - { "VOICE", "voice", "+v", 0, CA_VOICE, CA_VOICEME }, - { "DEHALFOP", "dehalfop", "-h", 0, CA_HALFOP, CA_HALFOPME }, - { "HALFOP", "halfop", "+h", 0, CA_HALFOP, CA_HALFOPME }, - { "DEPROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, - { "PROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, - { NULL } + { "DEOP", "deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, + { "OP", "op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, + { "DEVOICE", "devoice", "-v", 0, CA_VOICE, CA_VOICEME }, + { "VOICE", "voice", "+v", 0, CA_VOICE, CA_VOICEME }, + { "DEHALFOP", "dehalfop", "-h", 0, CA_HALFOP, CA_HALFOPME }, + { "HALFOP", "halfop", "+h", 0, CA_HALFOP, CA_HALFOPME }, + { "DEPROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, + { "PROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, + { NULL } }; /*************************************************************************/ @@ -130,56 +130,56 @@ void moduleAddChanServCmds(void) { char *get_mlock_modes(ChannelInfo * ci, int complete) { - static char res[BUFSIZE]; + static char res[BUFSIZE]; - char *end = res; + char *end = res; - if (ci->mlock_on || ci->mlock_off) { - unsigned int n = 0; - CBModeInfo *cbmi = cbmodeinfos; + if (ci->mlock_on || ci->mlock_off) { + unsigned int n = 0; + CBModeInfo *cbmi = cbmodeinfos; - if (ci->mlock_on) { - *end++ = '+'; - n++; + if (ci->mlock_on) { + *end++ = '+'; + n++; - do { - if (ci->mlock_on & cbmi->flag) - *end++ = cbmi->mode; - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + do { + if (ci->mlock_on & cbmi->flag) + *end++ = cbmi->mode; + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - cbmi = cbmodeinfos; - } + cbmi = cbmodeinfos; + } - if (ci->mlock_off) { - *end++ = '-'; - n++; + if (ci->mlock_off) { + *end++ = '-'; + n++; - do { - if (ci->mlock_off & cbmi->flag) - *end++ = cbmi->mode; - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + do { + if (ci->mlock_off & cbmi->flag) + *end++ = cbmi->mode; + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - cbmi = cbmodeinfos; - } + cbmi = cbmodeinfos; + } - if (ci->mlock_on && complete) { - do { - if (cbmi->csgetvalue && (ci->mlock_on & cbmi->flag)) { - char *value = cbmi->csgetvalue(ci); + if (ci->mlock_on && complete) { + do { + if (cbmi->csgetvalue && (ci->mlock_on & cbmi->flag)) { + char *value = cbmi->csgetvalue(ci); - if (value) { - *end++ = ' '; - while (*value) - *end++ = *value++; - } - } - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - } - } + if (value) { + *end++ = ' '; + while (*value) + *end++ = *value++; + } + } + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + } + } - *end = 0; + *end = 0; - return res; + return res; } /*************************************************************************/ @@ -188,66 +188,66 @@ char *get_mlock_modes(ChannelInfo * ci, int complete) void get_chanserv_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - int i, j; - ChannelInfo *ci; - - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - count++; - mem += sizeof(*ci); - if (ci->desc) - mem += strlen(ci->desc) + 1; - if (ci->url) - mem += strlen(ci->url) + 1; - if (ci->email) - mem += strlen(ci->email) + 1; - mem += ci->accesscount * sizeof(ChanAccess); - mem += ci->akickcount * sizeof(AutoKick); - for (j = 0; j < ci->akickcount; j++) { - if (!(ci->akick[j].flags & AK_ISNICK) - && ci->akick[j].u.mask) - mem += strlen(ci->akick[j].u.mask) + 1; - if (ci->akick[j].reason) - mem += strlen(ci->akick[j].reason) + 1; - if (ci->akick[j].creator) - mem += strlen(ci->akick[j].creator) + 1; - } - if (ci->mlock_key) - mem += strlen(ci->mlock_key) + 1; - if (ircd->fmode) { - if (ci->mlock_flood) - mem += strlen(ci->mlock_flood) + 1; - } - if (ircd->Lmode) { - if (ci->mlock_redirect) - mem += strlen(ci->mlock_redirect) + 1; - } - if (ci->last_topic) - mem += strlen(ci->last_topic) + 1; - if (ci->entry_message) - mem += strlen(ci->entry_message) + 1; - if (ci->forbidby) - mem += strlen(ci->forbidby) + 1; - if (ci->forbidreason) - mem += strlen(ci->forbidreason) + 1; - if (ci->levels) - mem += sizeof(*ci->levels) * CA_SIZE; - mem += ci->memos.memocount * sizeof(Memo); - for (j = 0; j < ci->memos.memocount; j++) { - if (ci->memos.memos[j].text) - mem += strlen(ci->memos.memos[j].text) + 1; - } - if (ci->ttb) - mem += sizeof(*ci->ttb) * TTB_SIZE; - mem += ci->bwcount * sizeof(BadWord); - for (j = 0; j < ci->bwcount; j++) - if (ci->badwords[j].word) - mem += strlen(ci->badwords[j].word) + 1; - } - } - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + int i, j; + ChannelInfo *ci; + + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = ci->next) { + count++; + mem += sizeof(*ci); + if (ci->desc) + mem += strlen(ci->desc) + 1; + if (ci->url) + mem += strlen(ci->url) + 1; + if (ci->email) + mem += strlen(ci->email) + 1; + mem += ci->accesscount * sizeof(ChanAccess); + mem += ci->akickcount * sizeof(AutoKick); + for (j = 0; j < ci->akickcount; j++) { + if (!(ci->akick[j].flags & AK_ISNICK) + && ci->akick[j].u.mask) + mem += strlen(ci->akick[j].u.mask) + 1; + if (ci->akick[j].reason) + mem += strlen(ci->akick[j].reason) + 1; + if (ci->akick[j].creator) + mem += strlen(ci->akick[j].creator) + 1; + } + if (ci->mlock_key) + mem += strlen(ci->mlock_key) + 1; + if (ircd->fmode) { + if (ci->mlock_flood) + mem += strlen(ci->mlock_flood) + 1; + } + if (ircd->Lmode) { + if (ci->mlock_redirect) + mem += strlen(ci->mlock_redirect) + 1; + } + if (ci->last_topic) + mem += strlen(ci->last_topic) + 1; + if (ci->entry_message) + mem += strlen(ci->entry_message) + 1; + if (ci->forbidby) + mem += strlen(ci->forbidby) + 1; + if (ci->forbidreason) + mem += strlen(ci->forbidreason) + 1; + if (ci->levels) + mem += sizeof(*ci->levels) * CA_SIZE; + mem += ci->memos.memocount * sizeof(Memo); + for (j = 0; j < ci->memos.memocount; j++) { + if (ci->memos.memos[j].text) + mem += strlen(ci->memos.memos[j].text) + 1; + } + if (ci->ttb) + mem += sizeof(*ci->ttb) * TTB_SIZE; + mem += ci->bwcount * sizeof(BadWord); + for (j = 0; j < ci->bwcount; j++) + if (ci->badwords[j].word) + mem += strlen(ci->badwords[j].word) + 1; + } + } + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -257,7 +257,7 @@ void get_chanserv_stats(long *nrec, long *memuse) void cs_init(void) { - moduleAddChanServCmds(); + moduleAddChanServCmds(); } /*************************************************************************/ @@ -266,20 +266,20 @@ void cs_init(void) void chanserv(User * u, char *buf) { - char *cmd, *s; - - cmd = strtok(buf, " "); - - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - *s = 0; - } - ircdproto->SendCTCP(findbot(s_ChanServ), u->nick, "PING %s", s); - } else { - mod_run_cmd(s_ChanServ, u, CHANSERV, cmd); - } + char *cmd, *s; + + cmd = strtok(buf, " "); + + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + *s = 0; + } + ircdproto->SendCTCP(findbot(s_ChanServ), u->nick, "PING %s", s); + } else { + mod_run_cmd(s_ChanServ, u, CHANSERV, cmd); + } } /*************************************************************************/ @@ -288,319 +288,319 @@ void chanserv(User * u, char *buf) #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", ChanDBName); \ + fatal("Read error on %s", ChanDBName); \ failed = 1; \ break; \ - } \ + } \ } while (0) void load_cs_dbase(void) { - dbFILE *f; - int ver, i, j, c; - ChannelInfo *ci, **last, *prev; - int failed = 0; + dbFILE *f; + int ver, i, j, c; + ChannelInfo *ci, **last, *prev; + int failed = 0; - if (!(f = open_db(s_ChanServ, ChanDBName, "r", CHAN_VERSION))) - return; + if (!(f = open_db(s_ChanServ, ChanDBName, "r", CHAN_VERSION))) + return; - ver = get_file_version(f); + ver = get_file_version(f); if (ver != 16) fatal("Invalid database version! (I only understand %d)", CHAN_VERSION); - for (i = 0; i < 256 && !failed; i++) { - uint16 tmp16; - uint32 tmp32; - unsigned int read; - int n_levels; - char *s; - NickAlias *na; - - last = &chanlists[i]; - prev = NULL; - while ((c = getc_db(f)) != 0) { - if (c != 1) - fatal("Invalid format in %s", ChanDBName); - ci = (ChannelInfo *)scalloc(sizeof(ChannelInfo), 1); - *last = ci; - last = &ci->next; - ci->prev = prev; - prev = ci; - SAFE(read = read_buffer(ci->name, f)); - SAFE(read_string(&s, f)); - if (s) { - ci->founder = findcore(s); - free(s); - } else - ci->founder = NULL; - if (ver >= 7) { - SAFE(read_string(&s, f)); - if (s) { - if (ver >= 13) - ci->successor = findcore(s); - else { - na = findnick(s); - if (na) - ci->successor = na->nc; - else - ci->successor = NULL; - } - free(s); - } else - ci->successor = NULL; - } else { - ci->successor = NULL; - } - SAFE(read = read_buffer(ci->founderpass, f)); - SAFE(read_string(&ci->desc, f)); - if (!ci->desc) - ci->desc = sstrdup(""); - SAFE(read_string(&ci->url, f)); - SAFE(read_string(&ci->email, f)); - SAFE(read_int32(&tmp32, f)); - ci->time_registered = tmp32; - SAFE(read_int32(&tmp32, f)); - ci->last_used = tmp32; - SAFE(read_string(&ci->last_topic, f)); - SAFE(read = read_buffer(ci->last_topic_setter, f)); - SAFE(read_int32(&tmp32, f)); - ci->last_topic_time = tmp32; - SAFE(read_int32(&ci->flags, f)); - - /* Leaveops cleanup */ - if (ver <= 13 && (ci->flags & 0x00000020)) - ci->flags &= ~0x00000020; - /* Temporary flags cleanup */ - ci->flags &= ~CI_INHABIT; - - SAFE(read_string(&ci->forbidby, f)); - SAFE(read_string(&ci->forbidreason, f)); - SAFE(read_int16(&tmp16, f)); - ci->bantype = tmp16; - SAFE(read_int16(&tmp16, f)); - n_levels = tmp16; - ci->levels = (int16 *)scalloc(2 * CA_SIZE, 1); - reset_levels(ci); - for (j = 0; j < n_levels; j++) { - SAFE(read_int16(&tmp16, f)); - if (j < CA_SIZE) - ci->levels[j] = (int16) tmp16; - } - - SAFE(read_int16(&ci->accesscount, f)); - if (ci->accesscount) { - ci->access = (ChanAccess *)scalloc(ci->accesscount, sizeof(ChanAccess)); - for (j = 0; j < ci->accesscount; j++) { - SAFE(read_int16(&ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - SAFE(read_int16(&tmp16, f)); - ci->access[j].level = (int16) tmp16; - SAFE(read_string(&s, f)); - if (s) { - ci->access[j].nc = findcore(s); - free(s); - } - if (ci->access[j].nc == NULL) - ci->access[j].in_use = 0; - SAFE(read_int32(&tmp32, f)); - ci->access[j].last_seen = tmp32; - } - } - } else { - ci->access = NULL; - } - - SAFE(read_int16(&ci->akickcount, f)); - if (ci->akickcount) { - ci->akick = (AutoKick *)scalloc(ci->akickcount, sizeof(AutoKick)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(read_int16(&ci->akick[j].flags, f)); - if (ci->akick[j].flags & AK_USED) { - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & AK_ISNICK) { - ci->akick[j].u.nc = findcore(s); - if (!ci->akick[j].u.nc) - ci->akick[j].flags &= ~AK_USED; - free(s); - } else { - ci->akick[j].u.mask = s; - } - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & AK_USED) - ci->akick[j].reason = s; - else if (s) - free(s); - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & AK_USED) { - ci->akick[j].creator = s; - } else if (s) { - free(s); - } - SAFE(read_int32(&tmp32, f)); - if (ci->akick[j].flags & AK_USED) - ci->akick[j].addtime = tmp32; - } - } - } else { - ci->akick = NULL; - } - - SAFE(read_int32(&ci->mlock_on, f)); - SAFE(read_int32(&ci->mlock_off, f)); - SAFE(read_int32(&ci->mlock_limit, f)); - SAFE(read_string(&ci->mlock_key, f)); - if (ircd->fmode) { - SAFE(read_string(&ci->mlock_flood, f)); - } else { - SAFE(read_string(&s, f)); - if (s) - free(s); - } - if (ircd->Lmode) { - SAFE(read_string(&ci->mlock_redirect, f)); - } else { - SAFE(read_string(&s, f)); - if (s) - free(s); - } - - SAFE(read_int16(&tmp16, f)); - ci->memos.memocount = (int16) tmp16; - SAFE(read_int16(&tmp16, f)); - ci->memos.memomax = (int16) tmp16; - if (ci->memos.memocount) { - Memo *memos; - memos = (Memo *)scalloc(sizeof(Memo) * ci->memos.memocount, 1); - ci->memos.memos = memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - SAFE(read_int32(&memos->number, f)); - SAFE(read_int16(&memos->flags, f)); - SAFE(read_int32(&tmp32, f)); - memos->time = tmp32; - SAFE(read = read_buffer(memos->sender, f)); - SAFE(read_string(&memos->text, f)); - memos->moduleData = NULL; - } - } - - SAFE(read_string(&ci->entry_message, f)); - - ci->c = NULL; - - /* BotServ options */ - int n_ttb; - - SAFE(read_string(&s, f)); - if (s) { - ci->bi = findbot(s); - free(s); - } else - ci->bi = NULL; - - SAFE(read_int32(&tmp32, f)); - ci->botflags = tmp32; - SAFE(read_int16(&tmp16, f)); - n_ttb = tmp16; - ci->ttb = (int16 *)scalloc(2 * TTB_SIZE, 1); - for (j = 0; j < n_ttb; j++) { - SAFE(read_int16(&tmp16, f)); - if (j < TTB_SIZE) - ci->ttb[j] = (int16) tmp16; - } - for (j = n_ttb; j < TTB_SIZE; j++) - ci->ttb[j] = 0; - SAFE(read_int16(&tmp16, f)); - ci->capsmin = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->capspercent = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->floodlines = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->floodsecs = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->repeattimes = tmp16; - - SAFE(read_int16(&ci->bwcount, f)); - if (ci->bwcount) { - ci->badwords = (BadWord *)scalloc(ci->bwcount, sizeof(BadWord)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(read_int16(&ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_int16(&ci->badwords[j].type, f)); - } - } - } else { - ci->badwords = NULL; - } - } /* while (getc_db(f) != 0) */ - - *last = NULL; - - } /* for (i) */ - - close_db(f); - - /* Check for non-forbidden channels with no founder. - Makes also other essential tasks. */ - for (i = 0; i < 256; i++) { - ChannelInfo *next; - for (ci = chanlists[i]; ci; ci = next) { - next = ci->next; - if (!(ci->flags & CI_VERBOTEN) && !ci->founder) { - alog("%s: database load: Deleting founderless channel %s", - s_ChanServ, ci->name); - delchan(ci); - continue; - } - if (ver < 13) { - ChanAccess *access, *access2; - AutoKick *akick, *akick2; - int k; - - if (ci->flags & CI_VERBOTEN) - continue; - /* Need to regenerate the channel count for the founder */ - ci->founder->channelcount++; - /* Check for eventual double entries in access/akick lists. */ - for (j = 0, access = ci->access; j < ci->accesscount; - j++, access++) { - if (!access->in_use) - continue; - for (k = 0, access2 = ci->access; k < j; - k++, access2++) { - if (access2->in_use && access2->nc == access->nc) { - alog("%s: deleting %s channel access entry of %s because it is already in the list (this is OK).", s_ChanServ, access->nc->display, ci->name); - memset(access, 0, sizeof(ChanAccess)); - break; - } - } - } - for (j = 0, akick = ci->akick; j < ci->akickcount; - j++, akick++) { - if (!(akick->flags & AK_USED) - || !(akick->flags & AK_ISNICK)) - continue; - for (k = 0, akick2 = ci->akick; k < j; k++, akick2++) { - if ((akick2->flags & AK_USED) - && (akick2->flags & AK_ISNICK) - && akick2->u.nc == akick->u.nc) { - alog("%s: deleting %s channel akick entry of %s because it is already in the list (this is OK).", s_ChanServ, akick->u.nc->display, ci->name); - if (akick->reason) - free(akick->reason); - if (akick->creator) - free(akick->creator); - memset(akick, 0, sizeof(AutoKick)); - break; - } - } - } - } - } - } + for (i = 0; i < 256 && !failed; i++) { + uint16 tmp16; + uint32 tmp32; + unsigned int read; + int n_levels; + char *s; + NickAlias *na; + + last = &chanlists[i]; + prev = NULL; + while ((c = getc_db(f)) != 0) { + if (c != 1) + fatal("Invalid format in %s", ChanDBName); + ci = (ChannelInfo *)scalloc(sizeof(ChannelInfo), 1); + *last = ci; + last = &ci->next; + ci->prev = prev; + prev = ci; + SAFE(read = read_buffer(ci->name, f)); + SAFE(read_string(&s, f)); + if (s) { + ci->founder = findcore(s); + free(s); + } else + ci->founder = NULL; + if (ver >= 7) { + SAFE(read_string(&s, f)); + if (s) { + if (ver >= 13) + ci->successor = findcore(s); + else { + na = findnick(s); + if (na) + ci->successor = na->nc; + else + ci->successor = NULL; + } + free(s); + } else + ci->successor = NULL; + } else { + ci->successor = NULL; + } + SAFE(read = read_buffer(ci->founderpass, f)); + SAFE(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = sstrdup(""); + SAFE(read_string(&ci->url, f)); + SAFE(read_string(&ci->email, f)); + SAFE(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + SAFE(read_int32(&tmp32, f)); + ci->last_used = tmp32; + SAFE(read_string(&ci->last_topic, f)); + SAFE(read = read_buffer(ci->last_topic_setter, f)); + SAFE(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + SAFE(read_int32(&ci->flags, f)); + + /* Leaveops cleanup */ + if (ver <= 13 && (ci->flags & 0x00000020)) + ci->flags &= ~0x00000020; + /* Temporary flags cleanup */ + ci->flags &= ~CI_INHABIT; + + SAFE(read_string(&ci->forbidby, f)); + SAFE(read_string(&ci->forbidreason, f)); + SAFE(read_int16(&tmp16, f)); + ci->bantype = tmp16; + SAFE(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = (int16 *)scalloc(2 * CA_SIZE, 1); + reset_levels(ci); + for (j = 0; j < n_levels; j++) { + SAFE(read_int16(&tmp16, f)); + if (j < CA_SIZE) + ci->levels[j] = (int16) tmp16; + } + + SAFE(read_int16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = (ChanAccess *)scalloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(read_int16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(read_int16(&tmp16, f)); + ci->access[j].level = (int16) tmp16; + SAFE(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + SAFE(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + + SAFE(read_int16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = (AutoKick *)scalloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_int16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & AK_USED) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & AK_ISNICK) { + ci->akick[j].u.nc = findcore(s); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~AK_USED; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & AK_USED) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & AK_USED) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & AK_USED) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + + SAFE(read_int32(&ci->mlock_on, f)); + SAFE(read_int32(&ci->mlock_off, f)); + SAFE(read_int32(&ci->mlock_limit, f)); + SAFE(read_string(&ci->mlock_key, f)); + if (ircd->fmode) { + SAFE(read_string(&ci->mlock_flood, f)); + } else { + SAFE(read_string(&s, f)); + if (s) + free(s); + } + if (ircd->Lmode) { + SAFE(read_string(&ci->mlock_redirect, f)); + } else { + SAFE(read_string(&s, f)); + if (s) + free(s); + } + + SAFE(read_int16(&tmp16, f)); + ci->memos.memocount = (int16) tmp16; + SAFE(read_int16(&tmp16, f)); + ci->memos.memomax = (int16) tmp16; + if (ci->memos.memocount) { + Memo *memos; + memos = (Memo *)scalloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(read_int32(&memos->number, f)); + SAFE(read_int16(&memos->flags, f)); + SAFE(read_int32(&tmp32, f)); + memos->time = tmp32; + SAFE(read = read_buffer(memos->sender, f)); + SAFE(read_string(&memos->text, f)); + memos->moduleData = NULL; + } + } + + SAFE(read_string(&ci->entry_message, f)); + + ci->c = NULL; + + /* BotServ options */ + int n_ttb; + + SAFE(read_string(&s, f)); + if (s) { + ci->bi = findbot(s); + free(s); + } else + ci->bi = NULL; + + SAFE(read_int32(&tmp32, f)); + ci->botflags = tmp32; + SAFE(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = (int16 *)scalloc(2 * TTB_SIZE, 1); + for (j = 0; j < n_ttb; j++) { + SAFE(read_int16(&tmp16, f)); + if (j < TTB_SIZE) + ci->ttb[j] = (int16) tmp16; + } + for (j = n_ttb; j < TTB_SIZE; j++) + ci->ttb[j] = 0; + SAFE(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + SAFE(read_int16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = (BadWord *)scalloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_int16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_int16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + } /* while (getc_db(f) != 0) */ + + *last = NULL; + + } |
