aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-05 01:17:20 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-05 01:17:32 +0200
commit4bac248c503ba79354442f3e6c611526e58efe53 (patch)
tree154c55276a641fde17fd0f753efd5d014ee7c294
parent7f57bed5638b4e9e7f3a4fdfabfe3eb72135f7dc (diff)
downloadxK-4bac248c503ba79354442f3e6c611526e58efe53.tar.gz
xK-4bac248c503ba79354442f3e6c611526e58efe53.tar.xz
xK-4bac248c503ba79354442f3e6c611526e58efe53.zip
degesch: refactoring
-rw-r--r--degesch.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/degesch.c b/degesch.c
index 3533658..dc36ef9 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2809,12 +2809,21 @@ irc_make_channel (struct server *s, char *name)
return channel;
}
-static void
-irc_remove_user_from_channel (struct user *user, struct channel *channel)
+static struct channel_user *
+irc_channel_get_user (struct channel *channel, struct user *user)
{
LIST_FOR_EACH (struct channel_user, iter, channel->users)
if (iter->user == user)
- irc_channel_unlink_user (channel, iter);
+ return iter;
+ return NULL;
+}
+
+static void
+irc_remove_user_from_channel (struct user *user, struct channel *channel)
+{
+ struct channel_user *channel_user = irc_channel_get_user (channel, user);
+ if (channel_user)
+ irc_channel_unlink_user (channel, channel_user);
}
static void
@@ -3966,16 +3975,10 @@ mode_processor_do_user (struct mode_processor *self)
{
const char *nickname;
struct user *user;
+ struct channel_user *channel_user;
if (!(nickname = mode_processor_next_param (self))
- || !(user = str_map_find (&self->s->irc_users, nickname)))
- return;
-
- // TODO: factor out, also use in unlink_user or whatever
- struct channel_user *channel_user = NULL;
- LIST_FOR_EACH (struct channel_user, iter, self->channel->users)
- if (iter->user == user)
- channel_user = iter;
- if (!channel_user)
+ || !(user = str_map_find (&self->s->irc_users, nickname))
+ || !(channel_user = irc_channel_get_user (self->channel, user)))
return;
const char *all_prefixes = self->s->irc_chanuser_prefixes;