void SetChannelTopic(struct chanNode *channel, struct userNode *service, struct userNode *user, const char *topic, int announce) { unsigned int n; struct modeNode *mn; char old_topic[TOPICLEN+1]; safestrncpy(old_topic, channel->topic, sizeof(old_topic)); safestrncpy(channel->topic, topic, sizeof(channel->topic)); channel->topic_time = now; if (user) { safestrncpy(channel->topic_nick, user->nick, sizeof(channel->topic_nick)); /* Update the setter's idle time */ if ((mn = GetUserMode(channel, user))) mn->idle_since = now; } if (announce) { /* We don't really care if a local user messes with the topic, * so don't call the tf_list functions. */ irc_topic(service, user, channel, topic); } else { for (n=0; n<tf_used; n++) /* A topic change handler can return non-zero to indicate * that it has reverted the topic change, and that further * hooks should not be called. */ if (tf_list[n](user, channel, old_topic, tf_list_extra[n])) break; } }
void test_irc_topic() { char msg[READ_BUF]; irc_topic("#circus", "The topic"); read_mock(msg); mu_assert(s_eq(msg, "TOPIC #circus :The topic\r\n"), "test_irc_topic: msg should be 'TOPIC #circus :The topic\\r\\n'"); }