Moved silc_client_ch[u]mode[_char] to client library from silc/.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 1 Nov 2000 21:44:27 +0000 (21:44 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 1 Nov 2000 21:44:27 +0000 (21:44 +0000)
NAMES command now shows users modes on joining with nickname

CHANGES
apps/silc/clientutil.c
apps/silc/clientutil.h
lib/silcclient/client.c
lib/silcclient/client.h
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index 08341773ba5b5141b53b024689856e92f10726c4..bfec5a99a399d80324c42267e1b1c898eb663e70 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,13 @@
 Wed Nov  1 17:21:26 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
+       * NAMES command reply now shows users mode with the nickname when
+         joining to channel.
+
+       * Moved silc_client_ch[u]mode[_char] functions from 
+         silc/clientutil.[ch] to lib/silcclient/client.[ch].  Though, that
+         place sucks, they are utility functions and should be in some
+         other file.
+
        * Fixed some unsigned int's to unsigned short's.  Patch by cras.
 
        * Fixed contrib/getopt*.[ch] to not require config.h.  Patch by
index 321160d49055a73f705825eb99be4f0d331f2449..210f50b02c5d2307f6a8bb4bf12a211bb97e6c38 100644 (file)
@@ -729,80 +729,3 @@ int silc_client_load_keys(SilcClient client)
 
   return TRUE;
 }
-
-/* Parses mode mask and returns the mode as string. */
-
-char *silc_client_chmode(unsigned int mode)
-{
-  char string[20];
-
-  if (!mode)
-    return NULL;
-
-  memset(string, 0, sizeof(string));
-
-  if (mode & SILC_CHANNEL_MODE_PRIVATE)
-    strncat(string, "p", 1);
-
-  if (mode & SILC_CHANNEL_MODE_SECRET)
-    strncat(string, "s", 1);
-
-  if (mode & SILC_CHANNEL_MODE_PRIVKEY)
-    strncat(string, "k", 1);
-
-  if (mode & SILC_CHANNEL_MODE_INVITE)
-    strncat(string, "i", 1);
-
-  if (mode & SILC_CHANNEL_MODE_TOPIC)
-    strncat(string, "t", 1);
-
-  if (mode & SILC_CHANNEL_MODE_ULIMIT)
-    strncat(string, "l", 1);
-
-  if (mode & SILC_CHANNEL_MODE_PASSPHRASE)
-    strncat(string, "a", 1);
-
-  /* Rest of mode is ignored */
-
-  return strdup(string);
-}
-
-/* Parses channel user mode mask and returns te mode as string */
-
-char *silc_client_chumode(unsigned int mode)
-{
-  char string[4];
-
-  if (!mode)
-    return NULL;
-
-  memset(string, 0, sizeof(string));
-
-  if (mode & SILC_CHANNEL_UMODE_CHANFO)
-    strncat(string, "f", 1);
-
-  if (mode & SILC_CHANNEL_UMODE_CHANOP)
-    strncat(string, "o", 1);
-
-  return strdup(string);
-}
-
-/* Parses channel user mode and returns it as special mode character. */
-
-char *silc_client_chumode_char(unsigned int mode)
-{
-  char string[4];
-
-  if (!mode)
-    return NULL;
-
-  memset(string, 0, sizeof(string));
-
-  if (mode & SILC_CHANNEL_UMODE_CHANFO)
-    strncat(string, "*", 1);
-
-  if (mode & SILC_CHANNEL_UMODE_CHANOP)
-    strncat(string, "@", 1);
-
-  return strdup(string);
-}
index b682a1271a087df147c264f045936d6cfb46656f..38f0d9e857b7cfc88e28c0f6cd3c85f093c242cf 100644 (file)
@@ -43,8 +43,5 @@ int silc_client_create_key_pair(char *pkcs_name, int bits,
                                SilcPrivateKey *ret_prv_key);
 int silc_client_check_silc_dir();
 int silc_client_load_keys(SilcClient client);
-char *silc_client_chmode(unsigned int mode);
-char *silc_client_chumode(unsigned int mode);
-char *silc_client_chumode_char(unsigned int mode);
 
 #endif
index 4cb6fc7a5ec7abb7ab8060166a1215d039dd0c72..44659ada59e5366baddab1912a6270fa5ddd8ea6 100644 (file)
@@ -2079,3 +2079,80 @@ void silc_client_replace_from_channels(SilcClient client,
 
   silc_idcache_list_free(list);
 }
+
+/* Parses mode mask and returns the mode as string. */
+
+char *silc_client_chmode(unsigned int mode)
+{
+  char string[20];
+
+  if (!mode)
+    return NULL;
+
+  memset(string, 0, sizeof(string));
+
+  if (mode & SILC_CHANNEL_MODE_PRIVATE)
+    strncat(string, "p", 1);
+
+  if (mode & SILC_CHANNEL_MODE_SECRET)
+    strncat(string, "s", 1);
+
+  if (mode & SILC_CHANNEL_MODE_PRIVKEY)
+    strncat(string, "k", 1);
+
+  if (mode & SILC_CHANNEL_MODE_INVITE)
+    strncat(string, "i", 1);
+
+  if (mode & SILC_CHANNEL_MODE_TOPIC)
+    strncat(string, "t", 1);
+
+  if (mode & SILC_CHANNEL_MODE_ULIMIT)
+    strncat(string, "l", 1);
+
+  if (mode & SILC_CHANNEL_MODE_PASSPHRASE)
+    strncat(string, "a", 1);
+
+  /* Rest of mode is ignored */
+
+  return strdup(string);
+}
+
+/* Parses channel user mode mask and returns te mode as string */
+
+char *silc_client_chumode(unsigned int mode)
+{
+  char string[4];
+
+  if (!mode)
+    return NULL;
+
+  memset(string, 0, sizeof(string));
+
+  if (mode & SILC_CHANNEL_UMODE_CHANFO)
+    strncat(string, "f", 1);
+
+  if (mode & SILC_CHANNEL_UMODE_CHANOP)
+    strncat(string, "o", 1);
+
+  return strdup(string);
+}
+
+/* Parses channel user mode and returns it as special mode character. */
+
+char *silc_client_chumode_char(unsigned int mode)
+{
+  char string[4];
+
+  if (!mode)
+    return NULL;
+
+  memset(string, 0, sizeof(string));
+
+  if (mode & SILC_CHANNEL_UMODE_CHANFO)
+    strncat(string, "*", 1);
+
+  if (mode & SILC_CHANNEL_UMODE_CHANOP)
+    strncat(string, "@", 1);
+
+  return strdup(string);
+}
index 84cfa3244dea8770a53de4cd7fa66bdaf2bc6946..fdff610eee9e0ae4bcafa828d3540eeeafe0e81a 100644 (file)
@@ -288,4 +288,8 @@ void silc_client_replace_from_channels(SilcClient client,
                                       SilcClientConnection conn,
                                       SilcClientEntry old,
                                       SilcClientEntry new);
+char *silc_client_chmode(unsigned int mode);
+char *silc_client_chumode(unsigned int mode);
+char *silc_client_chumode_char(unsigned int mode);
+
 #endif
index 5ed0a3b1fe9935d3003ecd6ece3c66927e179ce0..8b2f0c35273793f87cb2f0e0451fe0931b9ce8b1 100644 (file)
@@ -1092,10 +1092,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(names)
        channel->clients[k].client->nickname = 
          silc_calloc(strlen(nickname) + 8, sizeof(*channel->clients[k].
                                                   client->nickname));
+       snprintf(t, sizeof(t), "[%d]", c++);
+       strncat(channel->clients[k].client->nickname, t, strlen(t));
        strncat(channel->clients[k].client->nickname, nickname, 
                strlen(nickname));
-       snprintf(t, sizeof(t), " [%d]", c++);
-       strncat(channel->clients[k].client->nickname, t, strlen(t));
       }
     }
 
@@ -1105,10 +1105,19 @@ SILC_CLIENT_CMD_REPLY_FUNC(names)
   name_list = NULL;
   len1 = 0;
   for (k = 0; k < channel->clients_count; k++) {
-    char *n = channel->clients[k].client->nickname;
+    char *m, *n = channel->clients[k].client->nickname;
     len2 = strlen(n);
     len1 += len2;
-    name_list = silc_realloc(name_list, sizeof(*name_list) * (len1 + 1));
+
+    name_list = silc_realloc(name_list, sizeof(*name_list) * (len1 + 3));
+
+    m = silc_client_chumode_char(channel->clients[k].mode);
+    if (m) {
+      memcpy(name_list + (len1 - len2), m, strlen(m));
+      len1 += strlen(m);
+      silc_free(m);
+    }
+
     memcpy(name_list + (len1 - len2), n, len2);
     name_list[len1] = 0;