+/**
+ * Add entries to channel ban and invite lists.
+ *
+ * @param what Can be 'I' for invite or 'b' for ban list.
+ * @param Prefix The originator of the command.
+ * @param Client The sender of the command.
+ * @param Channel The channel of which the list should be modified.
+ * @param Pattern The pattern to add to the list.
+ * @return CONNECTED or DISCONNECTED.
+ */
+static bool
+Add_Ban_Invite(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
+ const char *Pattern)
+{
+ const char *mask;
+ struct list_head *list;
+
+ assert(Client != NULL);
+ assert(Channel != NULL);
+ assert(Pattern != NULL);
+ assert(what == 'I' || what == 'b');
+
+ mask = Lists_MakeMask(Pattern);
+
+ if (what == 'I')
+ list = Channel_GetListInvites(Channel);
+ else
+ list = Channel_GetListBans(Channel);
+
+ if (Lists_CheckDupeMask(list, mask))
+ return CONNECTED;
+
+ if (what == 'I') {
+ if (!Channel_AddInvite(Channel, mask, false))
+ return CONNECTED;
+ } else {
+ if (!Channel_AddBan(Channel, mask))
+ return CONNECTED;
+ }
+ return Send_ListChange(true, what, Prefix, Client, Channel, mask);
+}
+
+
+/**
+ * Delete entries from channel ban and invite lists.
+ *
+ * @param what Can be 'I' for invite or 'b' for ban list.
+ * @param Prefix The originator of the command.
+ * @param Client The sender of the command.
+ * @param Channel The channel of which the list should be modified.
+ * @param Pattern The pattern to add to the list.
+ * @return CONNECTED or DISCONNECTED.
+ */
+static bool
+Del_Ban_Invite(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
+ const char *Pattern)
+{
+ const char *mask;
+ struct list_head *list;
+
+ assert(Client != NULL);
+ assert(Channel != NULL);
+ assert(Pattern != NULL);
+ assert(what == 'I' || what == 'b');
+
+ mask = Lists_MakeMask(Pattern);
+
+ if (what == 'I')
+ list = Channel_GetListInvites(Channel);
+ else
+ list = Channel_GetListBans(Channel);
+
+ if (!Lists_CheckDupeMask(list, mask))
+ return CONNECTED;
+ Lists_Del(list, mask);
+
+ return Send_ListChange(false, what, Prefix, Client, Channel, mask);
+}
+
+
+/**
+ * Send information about changed channel ban/invite lists to clients.
+ *
+ * @param IsAdd true if the list item has been added, false otherwise.
+ * @param ModeChar The mode to use (e. g. 'b' or 'I')
+ * @param Prefix The originator of the mode list change.
+ * @param Client The sender of the command.
+ * @param Channel The channel of which the list has been modified.
+ * @param Mask The mask which has been added or removed.
+ * @return CONNECTED or DISCONNECTED.
+ */
+static bool
+Send_ListChange(const bool IsAdd, const char ModeChar, CLIENT *Prefix,
+ CLIENT *Client, CHANNEL *Channel, const char *Mask)
+{
+ bool ok = true;
+
+ /* Send confirmation to the client */
+ if (Client_Type(Client) == CLIENT_USER)
+ ok = IRC_WriteStrClientPrefix(Client, Prefix, "MODE %s %c%c %s",
+ Channel_Name(Channel),
+ IsAdd ? '+' : '-',
+ ModeChar, Mask);
+
+ /* to other servers */
+ IRC_WriteStrServersPrefix(Client, Prefix, "MODE %s %c%c %s",
+ Channel_Name(Channel), IsAdd ? '+' : '-',
+ ModeChar, Mask);
+
+ /* and local users in channel */
+ IRC_WriteStrChannelPrefix(Client, Channel, Prefix, false,
+ "MODE %s %c%c %s", Channel_Name(Channel),
+ IsAdd ? '+' : '-', ModeChar, Mask );
+
+ return ok;
+} /* Send_ListChange */
+
+