summaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-14 20:57:20 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-14 20:57:20 +0000
commit6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 (patch)
tree91b0841faf23087ebe0c74dd4269d181a383f1e7 /src/channels.c
parent069409cd99cf78ab8bf87a1fe69a833576414fd3 (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/channels.c')
-rw-r--r--src/channels.c3564
1 files changed, 1782 insertions, 1782 deletions
diff --git a/src/channels.c b/src/channels.c
index 5fdd6b73b..2cce6266c 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -24,36 +24,36 @@ Channel *chanlist[1024];
void chan_deluser(User * user, Channel * c)
{
- struct c_userlist *u;
-
- if (c->ci)
- update_cs_lastseen(user, c->ci);
-
- for (u = c->users; u && u->user != user; u = u->next);
- if (!u)
- return;
-
- if (u->ud) {
- if (u->ud->lastline)
- free(u->ud->lastline);
- free(u->ud);
- }
-
- if (u->next)
- u->next->prev = u->prev;
- if (u->prev)
- u->prev->next = u->next;
- else
- c->users = u->next;
- free(u);
- c->usercount--;
-
- if (s_BotServ && c->ci && c->ci->bi && c->usercount == BSMinUsers - 1) {
- ircdproto->SendPart(c->ci->bi, c->name, NULL);
- }
-
- if (!c->users)
- chan_delete(c);
+ struct c_userlist *u;
+
+ if (c->ci)
+ update_cs_lastseen(user, c->ci);
+
+ for (u = c->users; u && u->user != user; u = u->next);
+ if (!u)
+ return;
+
+ if (u->ud) {
+ if (u->ud->lastline)
+ free(u->ud->lastline);
+ free(u->ud);
+ }
+
+ if (u->next)
+ u->next->prev = u->prev;
+ if (u->prev)
+ u->prev->next = u->next;
+ else
+ c->users = u->next;
+ free(u);
+ c->usercount--;
+
+ if (s_BotServ && c->ci && c->ci->bi && c->usercount == BSMinUsers - 1) {
+ ircdproto->SendPart(c->ci->bi, c->name, NULL);
+ }
+
+ if (!c->users)
+ chan_delete(c);
}
/*************************************************************************/
@@ -64,39 +64,39 @@ void chan_deluser(User * user, Channel * c)
char *chan_get_modes(Channel * chan, int complete, int plus)
{
- static char res[BUFSIZE];
- char *end = res;
-
- if (chan->mode) {
- unsigned int n = 0;
- CBModeInfo *cbmi = cbmodeinfos;
-
- do {
- if (chan->mode & cbmi->flag)
- *end++ = cbmi->mode;
- } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
-
- if (complete) {
- cbmi = cbmodeinfos;
-
- do {
- if (cbmi->getvalue && (chan->mode & cbmi->flag) &&
- (plus || !(cbmi->flags & CBM_MINUS_NO_ARG))) {
- char *value = cbmi->getvalue(chan);
-
- if (value) {
- *end++ = ' ';
- while (*value)
- *end++ = *value++;
- }
- }
- } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
- }
- }
-
- *end = 0;
-
- return res;
+ static char res[BUFSIZE];
+ char *end = res;
+
+ if (chan->mode) {
+ unsigned int n = 0;
+ CBModeInfo *cbmi = cbmodeinfos;
+
+ do {
+ if (chan->mode & cbmi->flag)
+ *end++ = cbmi->mode;
+ } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
+
+ if (complete) {
+ cbmi = cbmodeinfos;
+
+ do {
+ if (cbmi->getvalue && (chan->mode & cbmi->flag) &&
+ (plus || !(cbmi->flags & CBM_MINUS_NO_ARG))) {
+ char *value = cbmi->getvalue(chan);
+
+ if (value) {
+ *end++ = ' ';
+ while (*value)
+ *end++ = *value++;
+ }
+ }
+ } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
+ }
+ }
+
+ *end = 0;
+
+ return res;
}
/*************************************************************************/
@@ -105,13 +105,13 @@ char *chan_get_modes(Channel * chan, int complete, int plus)
int chan_get_user_status(Channel * chan, User * user)
{
- struct u_chanlist *uc;
+ struct u_chanlist *uc;
- for (uc = user->chans; uc; uc = uc->next)
- if (uc->chan == chan)
- return uc->status;
+ for (uc = user->chans; uc; uc = uc->next)
+ if (uc->chan == chan)
+ return uc->status;
- return 0;
+ return 0;
}
/*************************************************************************/
@@ -120,17 +120,17 @@ int chan_get_user_status(Channel * chan, User * user)
int chan_has_user_status(Channel * chan, User * user, int16 status)
{
- struct u_chanlist *uc;
-
- for (uc = user->chans; uc; uc = uc->next) {
- if (uc->chan == chan) {
- if (debug) {
- alog("debug: chan_has_user_status wanted %d the user is %d", status, uc->status);
- }
- return (uc->status & status);
- }
- }
- return 0;
+ struct u_chanlist *uc;
+
+ for (uc = user->chans; uc; uc = uc->next) {
+ if (uc->chan == chan) {
+ if (debug) {
+ alog("debug: chan_has_user_status wanted %d the user is %d", status, uc->status);
+ }
+ return (uc->status & status);
+ }
+ }
+ return 0;
}
/*************************************************************************/
@@ -139,186 +139,186 @@ int chan_has_user_status(Channel * chan, User * user, int16 status)
void chan_remove_user_status(Channel * chan, User * user, int16 status)
{
- struct u_chanlist *uc;
-
- if (debug >= 2)
- alog("debug: removing user status (%d) from %s for %s", status,
- user->nick, chan->name);
-
- for (uc = user->chans; uc; uc = uc->next) {
- if (uc->chan == chan) {
- uc->status &= ~status;
- break;
- }
- }
+ struct u_chanlist *uc;
+
+ if (debug >= 2)
+ alog("debug: removing user status (%d) from %s for %s", status,
+ user->nick, chan->name);
+
+ for (uc = user->chans; uc; uc = uc->next) {
+ if (uc->chan == chan) {
+ uc->status &= ~status;
+ break;
+ }
+ }
}
/*************************************************************************/
void chan_set_modes(const char *source, Channel * chan, int ac, const char **av,
- int check)
+ int check)
{
- int add = 1;
- const char *modes = av[0];
+ int add = 1;
+ const char *modes = av[0];
char mode;
- CBMode *cbm;
- CMMode *cmm;
- CUMode *cum;
- unsigned char botmode = 0;
- BotInfo *bi;
- User *u, *user;
- int i, real_ac = ac;
- const char **real_av = av;
-
- if (debug)
- alog("debug: Changing modes for %s to %s", chan->name,
- merge_args(ac, av));
-
- u = finduser(source);
- if (u && (chan_get_user_status(chan, u) & CUS_DEOPPED)) {
- char *s;
-
- if (debug)
- alog("debug: Removing instead of setting due to DEOPPED flag");
-
- /* Swap adding and removing of the modes */
- for (s = (char *)av[0]; *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX
- if (*s == '+')
- *s = '-';
- else if (*s == '-')
- *s = '+';
- }
-
- /* Set the resulting mode buffer */
- ircdproto->SendMode(whosends(chan->ci), chan->name, merge_args(ac, av));
-
- return;
- }
-
- ac--;
-
- while ((mode = *modes++)) {
-
- switch (mode) {
- case '+':
- add = 1;
- continue;
- case '-':
- add = 0;
- continue;
- }
-
- if (((int) mode) < 0) {
- if (debug)
- alog("Debug: Malformed mode detected on %s.", chan->name);
- continue;
- }
-
- if ((cum = &cumodes[(int) mode])->status != 0) {
- if (ac == 0) {
- alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
- continue;
- }
- ac--;
- av++;
-
- if ((cum->flags & CUF_PROTECT_BOTSERV) && !add) {
- if ((bi = findbot(*av))) {
- if (!botmode || botmode != mode) {
- ircdproto->SendMode(bi, chan->name, "+%c %s",
- mode, bi->nick);
- botmode = mode;
- continue;
- } else {
- botmode = mode;
- continue;
- }
- }
- } else {
- if ((bi = findbot(*av))) {
- continue;
- }
- }
-
- if (!(user = finduser(*av))
- && !(UseTS6 && ircd->ts6 && (user = find_byuid(*av)))) {
- if (debug) {
- alog("debug: MODE %s %c%c for nonexistent user %s",
- chan->name, (add ? '+' : '-'), mode, *av);
- }
- continue;
- }
-
- if (debug)
- alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'),
- mode, chan->name, user->nick);
-
- if (add) {
- chan_set_user_status(chan, user, cum->status);
- /* If this does +o, remove any DEOPPED flag */
- if (cum->status & CUS_OP)
- chan_remove_user_status(chan, user, CUS_DEOPPED);
- } else {
- chan_remove_user_status(chan, user, cum->status);
- }
-
- } else if ((cbm = &cbmodes[(int) mode])->flag != 0) {
- if (check >= 0) {
- if (add)
- chan->mode |= cbm->flag;
- else
- chan->mode &= ~cbm->flag;
- }
-
- if (cbm->setvalue) {
- if (add || !(cbm->flags & CBM_MINUS_NO_ARG)) {
- if (ac == 0) {
- alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
- continue;
- }
- ac--;
- av++;
- }
- cbm->setvalue(chan, add ? *av : NULL);
- }
-
- if (check < 0) {
- if (add)
- chan->mode |= cbm->flag;
- else
- chan->mode &= ~cbm->flag;
- }
- } else if ((cmm = &cmmodes[(int) mode])->addmask) {
- if (ac == 0) {
- alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
- continue;
- }
-
- ac--;
- av++;
- if (add)
- cmm->addmask(chan, *av);
- else
- cmm->delmask(chan, *av);
- }
- }
-
- if (check > 0) {
- check_modes(chan);
-
- if (check < 2) {
- /* Walk through all users we've set modes for and see if they are
- * valid. Invalid modes (like +o with SECUREOPS on) will be removed
- */
- real_ac--;
- real_av++;
- for (i = 0; i < real_ac; i++) {
- if ((user = finduser(*real_av)) && is_on_chan(chan, user))
- chan_set_correct_modes(user, chan, 0);
- real_av++;
- }
- }
- }
+ CBMode *cbm;
+ CMMode *cmm;
+ CUMode *cum;
+ unsigned char botmode = 0;
+ BotInfo *bi;
+ User *u, *user;
+ int i, real_ac = ac;
+ const char **real_av = av;
+
+ if (debug)
+ alog("debug: Changing modes for %s to %s", chan->name,
+ merge_args(ac, av));
+
+ u = finduser(source);
+ if (u && (chan_get_user_status(chan, u) & CUS_DEOPPED)) {
+ char *s;
+
+ if (debug)
+ alog("debug: Removing instead of setting due to DEOPPED flag");
+
+ /* Swap adding and removing of the modes */
+ for (s = (char *)av[0]; *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX
+ if (*s == '+')
+ *s = '-';
+ else if (*s == '-')
+ *s = '+';
+ }
+
+ /* Set the resulting mode buffer */
+ ircdproto->SendMode(whosends(chan->ci), chan->name, merge_args(ac, av));
+
+ return;
+ }
+
+ ac--;
+
+ while ((mode = *modes++)) {
+
+ switch (mode) {
+ case '+':
+ add = 1;
+ continue;
+ case '-':
+ add = 0;
+ continue;
+ }
+
+ if (((int) mode) < 0) {
+ if (debug)
+ alog("Debug: Malformed mode detected on %s.", chan->name);
+ continue;
+ }
+
+ if ((cum = &cumodes[(int) mode])->status != 0) {
+ if (ac == 0) {
+ alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
+ continue;
+ }
+ ac--;
+ av++;
+
+ if ((cum->flags & CUF_PROTECT_BOTSERV) && !add) {
+ if ((bi = findbot(*av))) {
+ if (!botmode || botmode != mode) {
+ ircdproto->SendMode(bi, chan->name, "+%c %s",
+ mode, bi->nick);
+ botmode = mode;
+ continue;
+ } else {
+ botmode = mode;
+ continue;
+ }
+ }
+ } else {
+ if ((bi = findbot(*av))) {
+ continue;
+ }
+ }
+
+ if (!(user = finduser(*av))
+ && !(UseTS6 && ircd->ts6 && (user = find_byuid(*av)))) {
+ if (debug) {
+ alog("debug: MODE %s %c%c for nonexistent user %s",
+ chan->name, (add ? '+' : '-'), mode, *av);
+ }
+ continue;
+ }
+
+ if (debug)
+ alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'),
+ mode, chan->name, user->nick);
+
+ if (add) {
+ chan_set_user_status(chan, user, cum->status);
+ /* If this does +o, remove any DEOPPED flag */
+ if (cum->status & CUS_OP)
+ chan_remove_user_status(chan, user, CUS_DEOPPED);
+ } else {
+ chan_remove_user_status(chan, user, cum->status);
+ }
+
+ } else if ((cbm = &cbmodes[(int) mode])->flag != 0) {
+ if (check >= 0) {
+ if (add)
+ chan->mode |= cbm->flag;
+ else
+ chan->mode &= ~cbm->flag;
+ }
+
+ if (cbm->setvalue) {
+ if (add || !(cbm->flags & CBM_MINUS_NO_ARG)) {
+ if (ac == 0) {
+ alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
+ continue;
+ }
+ ac--;
+ av++;
+ }
+ cbm->setvalue(chan, add ? *av : NULL);
+ }
+
+ if (check < 0) {
+ if (add)
+ chan->mode |= cbm->flag;
+ else
+ chan->mode &= ~cbm->flag;
+ }
+ } else if ((cmm = &cmmodes[(int) mode])->addmask) {
+ if (ac == 0) {
+ alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
+ continue;
+ }
+
+ ac--;
+ av++;
+ if (add)
+ cmm->addmask(chan, *av);
+ else
+ cmm->delmask(chan, *av);
+ }
+ }
+
+ if (check > 0) {
+ check_modes(chan);
+
+ if (check < 2) {
+ /* Walk through all users we've set modes for and see if they are
+ * valid. Invalid modes (like +o with SECUREOPS on) will be removed
+ */
+ real_ac--;
+ real_av++;
+ for (i = 0; i < real_ac; i++) {
+ if ((user = finduser(*real_av)) && is_on_chan(chan, user))
+ chan_set_correct_modes(user, chan, 0);
+ real_av++;
+ }
+ }
+ }
}
/*************************************************************************/
@@ -327,28 +327,28 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av,
void chan_set_user_status(Channel * chan, User * user, int16 status)
{
- struct u_chanlist *uc;
-
- if (debug >= 2)
- alog("debug: setting user status (%d) on %s for %s", status,
- user->nick, chan->name);
-
- if (HelpChannel && ircd->supporthelper && (status & CUS_OP)
- && (stricmp(chan->name, HelpChannel) == 0)
- && (!chan->ci || check_access(user, chan->ci, CA_AUTOOP))) {
- if (debug) {
- alog("debug: %s being given +h for having %d status in %s",
- user->nick, status, chan->name);
- }
- common_svsmode(user, "+h", NULL);
- }
-
- for (uc = user->chans; uc; uc = uc->next) {
- if (uc->chan == chan) {
- uc->status |= status;
- break;
- }
- }
+ struct u_chanlist *uc;
+
+ if (debug >= 2)
+ alog("debug: setting user status (%d) on %s for %s", status,
+ user->nick, chan->name);
+
+ if (HelpChannel && ircd->supporthelper && (status & CUS_OP)
+ && (stricmp(chan->name, HelpChannel) == 0)
+ && (!chan->ci || check_access(user, chan->ci, CA_AUTOOP))) {
+ if (debug) {
+ alog("debug: %s being given +h for having %d status in %s",
+ user->nick, status, chan->name);
+ }
+ common_svsmode(user, "+h", NULL);
+ }
+
+ for (uc = user->chans; uc; uc = uc->next) {
+ if (uc->chan == chan) {
+ uc->status |= status;
+ break;
+ }
+ }
}
/*************************************************************************/
@@ -359,29 +359,29 @@ void chan_set_user_status(Channel * chan, User * user, int16 status)
Channel *findchan(const char *chan)
{
- Channel *c;
-
- if (!chan || !*chan) {
- if (debug) {
- alog("debug: findchan() called with NULL values");
- }
- return NULL;
- }
-
- if (debug >= 3)
- alog("debug: findchan(%p)", chan);
- c = chanlist[HASH(chan)];
- while (c) {
- if (stricmp(c->name, chan) == 0) {
- if (debug >= 3)
- alog("debug: findchan(%s) -> %p", chan, (void *) c);
- return c;
- }
- c = c->next;
- }
- if (debug >= 3)
- alog("debug: findchan(%s) -> %p", chan, (void *) c);
- return NULL;
+ Channel *c;
+
+ if (!chan || !*chan) {
+ if (debug) {
+ alog("debug: findchan() called with NULL values");
+ }
+ return NULL;
+ }
+
+ if (debug >= 3)
+ alog("debug: findchan(%p)", chan);
+ c = chanlist[HASH(chan)];
+ while (c) {
+ if (stricmp(c->name, chan) == 0) {
+ if (debug >= 3)
+ alog("debug: findchan(%s) -> %p", chan, (void *) c);
+ return c;
+ }
+ c = c->next;
+ }
+ if (debug >= 3)
+ alog("debug: findchan(%s) -> %p", chan, (void *) c);
+ return NULL;
}
/*************************************************************************/
@@ -395,27 +395,27 @@ static int next_index;
Channel *firstchan(void)
{
- next_index = 0;
- while (next_index < 1024 && current == NULL)
- current = chanlist[next_index++];
- if (debug >= 3)
- alog("debug: firstchan() returning %s",
- current ? current->name : "NULL (end of list)");
- return current;
+ next_index = 0;
+ while (next_index < 1024 && current == NULL)
+ current = chanlist[next_index++];
+ if (debug >= 3)
+ alog("debug: firstchan() returning %s",
+ current ? current->name : "NULL (end of list)");
+ return current;
}
Channel *nextchan(void)
{
- if (current)
- current = current->next;
- if (!current && next_index < 1024) {
- while (next_index < 1024 && current == NULL)
- current = chanlist[next_index++];
- }
- if (debug >= 3)
- alog("debug: nextchan() returning %s",
- current ? current->name : "NULL (end of list)");
- return current;
+ if (current)
+ current = current->next;
+ if (!current && next_index < 1024) {
+ while (next_index < 1024 && current == NULL)
+ current = chanlist[next_index++];
+ }
+ if (debug >= 3)
+ alog("debug: nextchan() returning %s",
+ current ? current->name : "NULL (end of list)");
+ return current;
}
/*************************************************************************/
@@ -424,52 +424,52 @@ Channel *nextchan(void)
void get_channel_stats(long *nrec, long *memuse)
{
- long count = 0, mem = 0;
- Channel *chan;
- struct c_userlist *cu;
- BanData *bd;
- int i;
-
- for (i = 0; i < 1024; i++) {
- for (chan = chanlist[i]; chan; chan = chan->next) {
- count++;
- mem += sizeof(*chan);
- if (chan->topic)
- mem += strlen(chan->topic) + 1;
- if (chan->key)
- mem += strlen(chan->key) + 1;
- if (ircd->fmode) {
- if (chan->flood)
- mem += strlen(chan->flood) + 1;
- }
- if (ircd->Lmode) {
- if (chan->redirect)
- mem += strlen(chan->redirect) + 1;
- }
- mem += get_memuse(chan->bans);
- if (ircd->except) {
- mem += get_memuse(chan->excepts);
- }
- if (ircd->invitemode) {
- mem += get_memuse(chan->invites);
- }
- for (cu = chan->users; cu; cu = cu->next) {
- mem += sizeof(*cu);
- if (cu->ud) {
- mem += sizeof(*cu->ud);
- if (cu->ud->lastline)
- mem += strlen(cu->ud->lastline) + 1;
- }
- }
- for (bd = chan->bd; bd; bd = bd->next) {
- if (bd->mask)
- mem += strlen(bd->mask) + 1;
- mem += sizeof(*bd);
- }
- }
- }
- *nrec = count;
- *memuse = mem;
+ long count = 0, mem = 0;
+ Channel *chan;
+ struct c_userlist *cu;
+ BanData *bd;
+ int i;
+
+ for (i = 0; i < 1024; i++) {
+ for (chan = chanlist[i]; chan; chan = chan->next) {
+ count++;
+ mem += sizeof(*chan);
+ if (chan->topic)
+ mem += strlen(chan->topic) + 1;
+ if (chan->key)
+ mem += strlen(chan->key) + 1;
+ if (ircd->fmode) {
+ if (chan->flood)
+ mem += strlen(chan->flood) + 1;
+ }
+ if (ircd->Lmode) {
+ if (chan->redirect)
+ mem += strlen(chan->redirect) + 1;
+ }
+ mem += get_memuse(chan->bans);
+ if (ircd->except) {
+ mem += get_memuse(chan->excepts);
+ }
+ if (ircd->invitemode) {
+ mem += get_memuse(chan->invites);
+ }
+ for (cu = chan->users; cu; cu = cu->next) {
+ mem += sizeof(*cu);
+ if (cu->ud) {
+ mem += sizeof(*cu->ud);
+ if (cu->ud->lastline)
+ mem += strlen(cu->ud->lastline) + 1;
+ }
+ }
+ for (bd = chan->bd; bd; bd = bd->next) {
+ if (bd->mask)
+ mem += strlen(bd->mask) + 1;
+ mem += sizeof(*bd);
+ }
+ }
+ }
+ *nrec = count;
+ *memuse = mem;
}
/*************************************************************************/
@@ -478,13 +478,13 @@ void get_channel_stats(long *nrec, long *memuse)
int is_on_chan(Channel * c, User * u)
{
- struct u_chanlist *uc;
+ struct u_chanlist *uc;
- for (uc = u->chans; uc; uc = uc->next)
- if (uc->chan == c)
- return 1;
+ for (uc = u->chans; uc; uc = uc->next)
+ if (uc->chan == c)
+ return 1;
- return 0;
+ return 0;
}
/*************************************************************************/
@@ -494,17 +494,17 @@ int is_on_chan(Channel * c, User * u)
User *nc_on_chan(Channel * c, NickCore * nc)
{
- struct c_userlist *u;
+ struct c_userlist *u;
- if (!c || !nc)
- return NULL;
+ if (!c || !nc)
+ return NULL;
- for (u = c->users; u; u = u->next) {
- if (u->user->na && u->user->na->nc == nc
- && nick_recognized(u->user))
- return u->user;
- }
- return NULL;
+ for (u = c->users; u; u = u->next) {
+ if (u->user->na && u->user->na->nc == nc
+ && nick_recognized(u->user))
+ return u->user;
+ }
+ return NULL;
}
/*************************************************************************/
@@ -517,76 +517,76 @@ User *nc_on_chan(Channel * c, NickCore * nc)
void do_join(const char *source, int ac, const char **av)
{
- User *user;
- Channel *chan;
- char *s, *t;
- struct u_chanlist *c, *nextc;
- char *channame;
- time_t ts = time(NULL);
-
- if (UseTS6 && ircd->ts6) {
- user = find_byuid(source);
- if (!user)
- user = finduser(source);
- } else {
- user = finduser(source);
- }
- if (!user) {
- if (debug) {
- alog("debug: JOIN from nonexistent user %s: %s", source,
- merge_args(ac, av));
- }
- return;
- }
-
- t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX
- while (*(s = t)) {
- t = s + strcspn(s, ",");
- if (*t)
- *t++ = 0;
-
- if (*s == '0') {
- c = user->chans;
- while (c) {
- nextc = c->next;
- channame = sstrdup(c->chan->name);
- send_event(EVENT_PART_CHANNEL, 3, EVENT_START, user->nick,
- channame);
- chan_deluser(user, c->chan);
- send_event(EVENT_PART_CHANNEL, 3, EVENT_STOP, user->nick,
- channame);
- free(channame);
- free(c);
- c = nextc;
- }
- user->chans = NULL;
- continue;
- }
-
- /* how about not triggering the JOIN event on an actual /part :) -certus */
- send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, source, s);
-
- /* Make sure check_kick comes before chan_adduser, so banned users
- * don't get to see things like channel keys. */
- /* If channel already exists, check_kick() will use correct TS.
- * Otherwise, we lose. */
- if (check_kick(user, s, ts))
- continue;
-
- if (ac == 2) {
- if (debug) {
- alog("debug: recieved a new TS for JOIN: %ld",
- (long int) ts);
- }
- ts = strtoul(av[1], NULL, 10);
- }
-
- chan = findchan(s);
- chan = join_user_update(user, chan, s, ts);
- chan_set_correct_modes(user, chan, 1);
-
- send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, source, s);
- }
+ User *user;
+ Channel *chan;
+ char *s, *t;
+ struct u_chanlist *c, *nextc;
+ char *channame;
+ time_t ts = time(NULL);
+
+ if (UseTS6 && ircd->ts6) {
+ user = find_byuid(source);
+ if (!user)
+ user = finduser(source);
+ } else {
+ user = finduser(source);
+ }
+ if (!user) {
+ if (debug) {
+ alog("debug: JOIN from nonexistent user %s: %s", source,
+ merge_args(ac, av));
+ }
+ return;
+ }
+
+ t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX
+ while (*(s = t)) {
+ t = s + strcspn(s, ",");
+ if (*t)
+ *t++ = 0;
+
+ if (*s == '0') {
+ c = user->chans;
+ while (c) {
+ nextc = c->next;
+ channame = sstrdup(c->chan->name);
+ send_event(EVENT_PART_CHANNEL, 3, EVENT_START, user->nick,
+ channame);
+ chan_deluser(user, c->chan);
+ send_event(EVENT_PART_CHANNEL, 3, EVENT_STOP, user->nick,
+ channame);
+ free(channame);
+ free(c);
+ c = nextc;
+ }
+ user->chans = NULL;
+ continue;
+ }
+
+ /* how about not triggering the JOIN event on an actual /part :) -certus */
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, source, s);
+
+ /* Make sure check_kick comes before chan_adduser, so banned users
+ * don't get to see things like channel keys. */
+ /* If channel already exists, check_kick() will use correct TS.
+ * Otherwise, we lose. */
+ if (check_kick(user, s, ts))
+ continue;
+
+ if (ac == 2) {
+ if (debug) {
+ alog("debug: recieved a new TS for JOIN: %ld",
+ (long int) ts);
+ }
+ ts = strtoul(av[1], NULL, 10);
+ }
+
+ chan = findchan(s);
+ chan = join_user_update(user, chan, s, ts);
+ chan_set_correct_modes(user, chan, 1);
+
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, source, s);
+ }
}
/*************************************************************************/
@@ -599,59 +599,59 @@ void do_join(const char *source, int ac, const char **av)
void do_kick(const char *source, int ac, const char **av)
{
- BotInfo *bi;
- ChannelInfo *ci;
- User *user;
- char *s, *t;
- struct u_chanlist *c;
-
- t = (char *)av[1]; // XXX unsafe cast, this needs reviewing -- w00t
- while (*(s = t)) {
- t = s + strcspn(s, ",");
- if (*t)
- *t++ = 0;
-
- /* If it is the bot that is being kicked, we make it rejoin the
- * channel and stop immediately.
- * --lara
- */
- if (s_BotServ && (bi = findbot(s)) && (ci = cs_findchan(av[0]))) {
- bot_join(ci);
- continue;
- }
-
- if (UseTS6 && ircd->ts6) {
- user = find_byuid(s);
- if (!user) {
- user = finduser(s);
- }
- } else {
- user = finduser(s);
- }
- if (!user) {
- if (debug) {
- alog("debug: KICK for nonexistent user %s on %s: %s", s,
- av[0], merge_args(ac - 2, av + 2));
- }
- continue;
- }
- if (debug) {
- alog("debug: kicking %s from %s", user->nick, av[0]);
- }
- for (c = user->chans; c && stricmp(av[0], c->chan->name) != 0;
- c = c->next);
- if (c) {
- send_event(EVENT_CHAN_KICK, 2, user->nick, av[0]);
- chan_deluser(user, c->chan);
- if (c->next)
- c->next->prev = c->prev;
- if (c->prev)
- c->prev->next = c->next;
- else
- user->chans = c->next;
- free(c);
- }
- }
+ BotInfo *bi;
+ ChannelInfo *ci;
+ User *user;
+ char *s, *t;
+ struct u_chanlist *c;
+
+ t = (char *)av[1]; // XXX unsafe cast, this needs reviewing -- w00t
+ while (*(s = t)) {
+ t = s + strcspn(s, ",");
+ if (*t)
+ *t++ = 0;
+
+ /* If it is the bot that is being kicked, we make it rejoin the
+ * channel and stop immediately.
+ * --lara
+ */
+ if (s_BotServ && (bi = findbot(s)) && (ci = cs_findchan(av[0]))) {
+ bot_join(ci);
+ continue;
+ }
+
+ if (UseTS6 && ircd->ts6) {
+ user = find_byuid(s);
+ if (!user) {
+ user = finduser(s);
+ }
+ } else {
+ user = finduser(s);
+ }
+ if (!user) {
+ if (debug) {
+ alog("debug: KICK for nonexistent user %s on %s: %s", s,
+ av[0], merge_args(ac - 2, av + 2));
+ }
+ continue;
+ }
+ if (debug) {
+ alog("debug: kicking %s from %s", user->nick, av[0]);
+ }
+ for (c = user->chans; c && stricmp(av[0], c->chan->name) != 0;
+ c = c->next);
+ if (c) {
+ send_event(EVENT_CHAN_KICK, 2, user->nick, av[0]);
+ chan_deluser(user, c->chan);
+ if (c->next)
+ c->next->prev = c->prev;
+ if (c->prev)
+ c->prev->next = c->next;
+ else
+ user->chans = c->next;
+ free(c);
+ }
+ }
}
/*************************************************************************/
@@ -663,57 +663,57 @@ void do_kick(const char *source, int ac, const char **av)
void do_part(const char *source, int ac, const char **av)
{
- User *user;
- char *s, *t;
- struct u_chanlist *c;
- char *channame;
-
- if (UseTS6 && ircd->ts6) {
- user = find_byuid(source);
- if (!user)
- user = finduser(source);
- } else {
- user = finduser(source);
- }
- if (!user) {
- if (debug) {
- alog("debug: PART from nonexistent user %s: %s", source,
- merge_args(ac, av));
- }
- return;
- }
- t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX
- while (*(s = t)) {
- t = s + strcspn(s, ",");
- if (*t)
- *t++ = 0;
- if (debug)
- alog("debug: %s leaves %s", source, s);
- for (c = user->chans; c && stricmp(s, c->chan->name) != 0;
- c = c->next);
- if (c) {
- if (!c->chan) {
- alog("user: BUG parting %s: channel entry found but c->chan NULL", s);
- return;
- }
- channame = sstrdup(c->chan->name);
- send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_START,
- user->nick, channame, (ac >= 2 ? av[1] : ""));
-
- chan_deluser(user, c->chan);
- if (c->next)
- c->next->prev = c->prev;
- if (c->prev)
- c->prev->next = c->next;
- else
- user->chans = c->next;
- free(c);
-