Handle command reply correctly for LIST.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 14 Apr 2005 17:57:52 +0000 (17:57 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 14 Apr 2005 17:57:52 +0000 (17:57 +0000)
CHANGES
apps/silcd/command_reply.c
lib/doc/command_reply_args.html
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index 0ed4ca68f0c47b62a906dba128991dc035a18895..0d8dddb2d38d0772ff270bc6c69e65beb772bc94 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+Thu Apr 14 20:25:08 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
+
+       * Handle empty LIST command reply correcttly in server.  Affected
+         file silcd/command_reply.c.
+
+       * Handle empty LIST command reply correctly in client library.
+         The application will now receive one LIST command reply with
+         all arguments set to NULL if there are no channels.  Updated
+         Client Library documentation accordingly.  Affected file
+         lib/silcclient/command_reply.c.
+
 Tue Apr 12 00:02:09 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
 
        * Added channel name string stringprep profile to the protocol
index d1200015ffd637f280af7732366d297d388cd00d..b4862c61221ed3d38de4bd46891c810400405ceb 100644 (file)
@@ -1502,6 +1502,8 @@ SILC_SERVER_CMD_REPLY_FUNC(list)
   COMMAND_CHECK_STATUS;
 
   tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
+  if (!tmp)
+    goto out;
   channel_id = silc_id_payload_parse_id(tmp, len, NULL);
   if (!channel_id)
     goto out;
index 5d2843f4198ab30b2fa86fe853946f32d14c74bd..a38209e9df6b57aa618222c32ed85b97a7acfb17 100644 (file)
@@ -153,7 +153,11 @@ const SilcClientID *old_client_id
 <td><small>
 Returns the list of channel in the SILC network. Each call of command reply
 returns one channel. This means that the command reply is called multiple
-times to return list of channels.  The 'channel_topic' may be NULL.
+times to return list of channels.  The 'channel', 'channel_name' and
+'channel_topic' may be NULL.  However, the 'channel' and 'channel_name'
+are NULL only if there are no channels in the network.  In this case
+this reply is called once with all arguments set to NULL.  Application
+must be able to handle this situation correctly.
 </td>
 <td width="50%"><small>SilcChannelEntry channel, char *channel_name,
 char *channel_topic, SilcUInt32 user_count
index abc51d1d04d131d1b978f82ffbb4d279df29f8c8..3c041113b70157cc139bea90bbf6ef96dd56e9ca 100644 (file)
@@ -634,7 +634,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(list)
 
   tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
   if (!tmp) {
-    COMMAND_REPLY_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+    /* There were no channels in the network. */
+    COMMAND_REPLY((SILC_ARGS, NULL, NULL, 0));
     goto out;
   }