+ if (the_args[0])
+ strlcat(the_modes, the_args, sizeof(the_modes));
+
+ if (!IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
+ Client_ID(Origin), Channel_Name(Channel),
+ the_modes))
+ return DISCONNECTED;
+#ifndef STRICT_RFC
+ if (!IRC_WriteStrClient(Origin, RPL_CREATIONTIME_MSG,
+ Client_ID(Origin), Channel_Name(Channel),
+ Channel_CreationTime(Channel)))
+ return DISCONNECTED;
+#endif
+ return CONNECTED;
+}
+
+
+/**
+ * Handle channel mode and channel-user mode changes
+ */
+static bool
+Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
+{
+ char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2],
+ argadd[CLIENT_PASS_LEN], *mode_ptr, *o_mode_ptr;
+ bool connected, set, skiponce, retval, use_servermode,
+ is_halfop, is_op, is_admin, is_owner, is_machine, is_oper;
+ int mode_arg, arg_arg, mode_arg_count = 0;
+ CLIENT *client;
+ long l;
+ size_t len;
+
+ is_halfop = is_op = is_admin = is_owner = is_machine = is_oper = false;
+
+ if (Channel_IsModeless(Channel))
+ return IRC_WriteStrClient(Client, ERR_NOCHANMODES_MSG,
+ Client_ID(Client), Channel_Name(Channel));
+
+ /* Mode request: let's answer it :-) */
+ if (Req->argc <= 1)
+ return Channel_Mode_Answer_Request(Origin, Channel);
+
+ /* Check if origin is oper and opers can use mode */
+ use_servermode = Conf_OperServerMode;
+ if(Client_OperByMe(Client) && Conf_OperCanMode) {
+ is_oper = true;
+ }
+
+ /* Check if client is a server/service */
+ if(Client_Type(Client) == CLIENT_SERVER ||
+ Client_Type(Client) == CLIENT_SERVICE) {
+ is_machine = true;
+ }
+
+ /* Check if client is member of channel or an oper or an server/service */
+ if(!Channel_IsMemberOf(Channel, Client) && !is_oper && !is_machine)
+ return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG,
+ Client_ID(Origin),
+ Channel_Name(Channel));
+
+ mode_arg = 1;
+ mode_ptr = Req->argv[mode_arg];
+ if (Req->argc > mode_arg + 1)
+ arg_arg = mode_arg + 1;