+ err:
+ silc_server_command_reply_free(cmd);
+}
+
+SILC_SERVER_CMD_REPLY_FUNC(list)
+{
+ SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcServer server = cmd->server;
+ SilcStatus status, error;
+ SilcID id;
+ SilcChannelEntry channel;
+ SilcIDCacheEntry cache;
+ unsigned char *tmp, *name, *namec = NULL, *topic;
+ SilcUInt32 usercount = 0;
+ SilcBool global_list = FALSE;
+
+ COMMAND_CHECK_STATUS;
+
+ if (!silc_argument_get_decoded(cmd->args, 2, SILC_ARGUMENT_ID, &id, NULL))
+ goto out;
+
+ name = silc_argument_get_arg_type(cmd->args, 3, NULL);
+ topic = silc_argument_get_arg_type(cmd->args, 4, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 5, NULL);
+ if (tmp)
+ SILC_GET32_MSB(usercount, tmp);
+
+ namec = silc_channel_name_check(name, strlen(name), SILC_STRING_UTF8,
+ 256, NULL);
+ if (!namec)
+ goto out;
+
+ /* Add the channel entry if we do not have it already */
+ channel = silc_idlist_find_channel_by_name(server->local_list,
+ namec, &cache);
+ if (!channel) {
+ channel = silc_idlist_find_channel_by_name(server->global_list,
+ namec, &cache);
+ global_list = TRUE;
+ }
+ if (!channel) {
+ /* If router did not find such channel in its lists then this must
+ be bogus channel or some router in the net is buggy. */
+ if (server->server_type != SILC_SERVER)
+ goto out;
+
+ channel = silc_idlist_add_channel(server->global_list, strdup(name),
+ SILC_CHANNEL_MODE_NONE,
+ silc_id_dup(SILC_ID_GET_ID(id),
+ SILC_ID_CHANNEL),
+ server->router, NULL, NULL, NULL);
+ if (!channel)
+ goto out;
+ }
+
+ channel->user_count = usercount;
+
+ if (topic) {
+ silc_free(channel->topic);
+ channel->topic = strdup(topic);
+ }
+
+ /* Pending callbacks are not executed if this was an list entry */
+ if (status != SILC_STATUS_OK &&
+ status != SILC_STATUS_LIST_END) {
+ silc_server_command_reply_free(cmd);
+ return;
+ }
+
+ out:
+ SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_LIST);
+ err:
+ silc_free(namec);
+ silc_server_command_reply_free(cmd);
+}
+
+SILC_SERVER_CMD_REPLY_FUNC(watch)
+{
+ SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcStatus status, error;
+
+ COMMAND_CHECK_STATUS;
+
+ out:
+ SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_WATCH);
+ err:
+ silc_server_command_reply_free(cmd);
+}
+
+SILC_SERVER_CMD_REPLY_FUNC(ping)
+{
+ SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcStatus status, error;
+
+ COMMAND_CHECK_STATUS;
+
+ out:
+ SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_PING);
+ err: