diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2020-10-16 20:19:52 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2020-10-16 21:17:57 +0200 |
commit | 76f4e6faa6d4ea5da25ec4158b2db3df6aa97d8d (patch) | |
tree | 0458338d0af360def197012faa43dec87221ad3e | |
parent | 2c48bc99590efce278a436e3ce8d78cd04356686 (diff) | |
download | xK-76f4e6faa6d4ea5da25ec4158b2db3df6aa97d8d.tar.gz xK-76f4e6faa6d4ea5da25ec4158b2db3df6aa97d8d.tar.xz xK-76f4e6faa6d4ea5da25ec4158b2db3df6aa97d8d.zip |
degesch: cleanup
Channels now need a reference to the server,
so don't pass it to functions.
-rw-r--r-- | degesch.c | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -4621,9 +4621,9 @@ irc_try_readd_user (struct server *s, } static void -irc_try_readd_channel (struct server *s, - struct channel *channel, struct buffer *buffer) +irc_try_readd_channel (struct channel *channel, struct buffer *buffer) { + struct server *s = channel->s; if (str_map_find (&s->irc_channels, channel->name)) { // Remove all users from channel and destroy any channel buffer @@ -4680,7 +4680,7 @@ irc_rehash_and_fix_conflicts (struct server *s) iter = str_map_iter_make (&old_channels); while ((channel = str_map_iter_next (&iter))) - irc_try_readd_channel (s, channel, + irc_try_readd_channel (channel, str_map_find (&old_buffer_map, channel->name)); // Hopefully we've either moved or destroyed all the old content @@ -6315,10 +6315,9 @@ mode_processor_apply_channel (struct mode_processor *self) /// Returns whether the change has only affected channel user modes static bool -irc_handle_mode_channel - (struct server *s, struct channel *channel, char **params) +irc_handle_mode_channel (struct channel *channel, char **params) { - struct mode_processor p = { .s = s, .channel = channel }; + struct mode_processor p = { .s = channel->s, .channel = channel }; mode_processor_run (&p, params, mode_processor_apply_channel); return p.changes == p.usermode_changes; } @@ -6720,7 +6719,7 @@ irc_handle_mode (struct server *s, const struct irc_message *msg) int flags = 0; if (channel - && irc_handle_mode_channel (s, channel, msg->params.vector + 1)) + && irc_handle_mode_channel (channel, msg->params.vector + 1)) // This is 90% automode spam, let's not let it steal attention, // maybe this behaviour should be configurable though flags = BUFFER_LINE_UNIMPORTANT; @@ -7375,7 +7374,7 @@ channel_user_sort_entry_cmp (const void *entry_a, const void *entry_b) } static char * -make_channel_users_list (struct server *s, struct channel *channel) +make_channel_users_list (struct channel *channel) { size_t n_users = 0; LIST_FOR_EACH (struct channel_user, iter, channel->users) @@ -7385,7 +7384,7 @@ make_channel_users_list (struct server *s, struct channel *channel) size_t i = 0; LIST_FOR_EACH (struct channel_user, iter, channel->users) { - entries[i].s = s; + entries[i].s = channel->s; entries[i].channel_user = iter; i++; } @@ -7399,7 +7398,7 @@ make_channel_users_list (struct server *s, struct channel *channel) { struct channel_user *channel_user = entries[i].channel_user; if (channel_user->user->away) str_append_c (&list, '\x1d'); - irc_get_channel_user_prefix (s, channel_user, &list); + irc_get_channel_user_prefix (channel->s, channel_user, &list); str_append (&list, channel_user->user->nickname); if (channel_user->user->away) str_append_c (&list, '\x1d'); str_append_c (&list, ' '); @@ -7410,10 +7409,10 @@ make_channel_users_list (struct server *s, struct channel *channel) } static void -irc_sync_channel_user (struct server *s, struct channel *channel, - const char *nickname, const char *prefixes) +irc_sync_channel_user (struct channel *channel, const char *nickname, + const char *prefixes) { - struct user *user = irc_get_or_make_user (s, nickname); + struct user *user = irc_get_or_make_user (channel->s, nickname); struct channel_user *channel_user = irc_channel_get_user (channel, user); if (!channel_user) @@ -7431,34 +7430,35 @@ irc_sync_channel_user (struct server *s, struct channel *channel, } static void -irc_process_names_finish (struct server *s, struct channel *channel) +irc_process_names_finish (struct channel *channel) { + struct server *s = channel->s; struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel->name); if (buffer) { - log_server_status (s, buffer, "Users on #S: #&m", - channel->name, make_channel_users_list (s, channel)); + log_server_status (channel->s, buffer, "Users on #S: #&m", + channel->name, make_channel_users_list (channel)); } } static void -irc_process_names (struct server *s, struct channel *channel) +irc_process_names (struct channel *channel) { struct str_map present = str_map_make (NULL); - present.key_xfrm = s->irc_strxfrm; + present.key_xfrm = channel->s->irc_strxfrm; struct strv *updates = &channel->names_buf; for (size_t i = 0; i < updates->len; i++) { const char *item = updates->vector[i]; - size_t n_prefixes = strspn (item, s->irc_chanuser_prefixes); + size_t n_prefixes = strspn (item, channel->s->irc_chanuser_prefixes); const char *nickname = item + n_prefixes; // Store the nickname in a hashset str_map_set (&present, nickname, (void *) 1); char *prefixes = xstrndup (item, n_prefixes); - irc_sync_channel_user (s, channel, nickname, prefixes); + irc_sync_channel_user (channel, nickname, prefixes); free (prefixes); } @@ -7471,7 +7471,7 @@ irc_process_names (struct server *s, struct channel *channel) strv_reset (&channel->names_buf); if (!channel->show_names_after_who) - irc_process_names_finish (s, channel); + irc_process_names_finish (channel); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -7489,10 +7489,10 @@ irc_handle_rpl_endofnames (struct server *s, const struct irc_message *msg) struct str_map_iter iter = str_map_iter_make (&s->irc_channels); struct channel *channel; while ((channel = str_map_iter_next (&iter))) - irc_process_names (s, channel); + irc_process_names (channel); } else if (channel) - irc_process_names (s, channel); + irc_process_names (channel); } static bool @@ -7531,7 +7531,7 @@ irc_handle_rpl_endofwho (struct server *s, const struct irc_message *msg) if (!channel || !channel->show_names_after_who) return false; - irc_process_names_finish (s, channel); + irc_process_names_finish (channel); channel->show_names_after_who = false; return true; } @@ -7573,7 +7573,7 @@ irc_handle_rpl_channelmodeis (struct server *s, const struct irc_message *msg) str_reset (&channel->no_param_modes); str_map_clear (&channel->param_modes); - irc_handle_mode_channel (s, channel, msg->params.vector + 1); + irc_handle_mode_channel (channel, msg->params.vector + 1); } // XXX: do we want to log a message? |