+ /* Notify application */
+ COMMAND_REPLY((ARGS));
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CONNECT);
+ silc_client_command_reply_free(cmd);
+}
+
+SILC_CLIENT_CMD_REPLY_FUNC(ban)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status;
+ SilcChannelEntry channel;
+ SilcChannelID *channel_id;
+ unsigned char *tmp;
+ SilcUInt32 len;
+
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
+ SILC_GET16_MSB(status, tmp);
+ if (status != SILC_STATUS_OK) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Take Channel ID */
+ tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
+ if (!tmp)
+ goto out;
+
+ channel_id = silc_id_payload_parse_id(tmp, len);
+ if (!channel_id)
+ goto out;
+
+ /* Get the channel entry */
+ channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
+ if (!channel) {
+ silc_free(channel_id);
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Get the ban list */
+ tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
+
+ /* Notify application */
+ COMMAND_REPLY((ARGS, channel, tmp));
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_BAN);
+ silc_client_command_reply_free(cmd);
+}
+
+SILC_CLIENT_CMD_REPLY_FUNC(close)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status;
+ unsigned char *tmp;
+
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
+ SILC_GET16_MSB(status, tmp);
+ if (status != SILC_STATUS_OK) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Notify application */
+ COMMAND_REPLY((ARGS));
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CLOSE);
+ silc_client_command_reply_free(cmd);
+}
+
+SILC_CLIENT_CMD_REPLY_FUNC(shutdown)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status;
+ unsigned char *tmp;
+
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
+ SILC_GET16_MSB(status, tmp);
+ if (status != SILC_STATUS_OK) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Notify application */
+ COMMAND_REPLY((ARGS));
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SHUTDOWN);
+ silc_client_command_reply_free(cmd);
+}
+
+/* Reply to LEAVE command. */
+
+SILC_CLIENT_CMD_REPLY_FUNC(leave)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status;
+ unsigned char *tmp;
+
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
+ SILC_GET16_MSB(status, tmp);
+ if (status != SILC_STATUS_OK) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Notify application */
+ COMMAND_REPLY((ARGS));
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LEAVE);
+ silc_client_command_reply_free(cmd);
+}
+
+/* Channel resolving callback for USERS command reply. */
+
+static void silc_client_command_reply_users_cb(SilcClient client,
+ SilcClientConnection conn,
+ SilcChannelEntry *channels,
+ SilcUInt32 channels_count,
+ void *context)
+{
+ if (!channels_count) {
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
+
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
+ silc_client_command_reply_free(cmd);
+ return;
+ }
+
+ silc_client_command_reply_users(context, NULL);
+}
+
+/* Reply to USERS command. Received list of client ID's and theirs modes
+ on the channel we requested. */
+
+SILC_CLIENT_CMD_REPLY_FUNC(users)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status;
+ SilcChannelEntry channel;
+ SilcClientEntry client_entry;
+ SilcChannelUser chu;
+ SilcChannelID *channel_id = NULL;
+ SilcBuffer client_id_list = NULL;
+ SilcBuffer client_mode_list = NULL;
+ unsigned char *tmp;
+ SilcUInt32 tmp_len, list_count;
+ int i;
+ unsigned char **res_argv = NULL;
+ SilcUInt32 *res_argv_lens = NULL, *res_argv_types = NULL, res_argc = 0;
+
+ SILC_LOG_DEBUG(("Start"));
+
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
+ SILC_GET16_MSB(status, tmp);
+ if (status != SILC_STATUS_OK) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Get channel ID */
+ tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+ if (!tmp) {
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+ channel_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!channel_id) {
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+