Fixed silc_client_get_clients_local to parse nick@server string
[silc.git] / lib / silcclient / client_entry.c
index a6dc88d578946a133a49320a97725dc94166ed9a..705e1cd1a74d088581be2f03b6d0ecfe8672eaff 100644 (file)
@@ -72,19 +72,22 @@ SilcDList silc_client_get_clients_local_ext(SilcClient client,
   SilcList list;
   SilcDList clients;
   SilcClientEntry entry;
-  char *nicknamec, *parsed = NULL, *format = NULL;
+  char nick[128 + 1], *nicknamec, *parsed = NULL, *format = NULL;
 
   if (!client || !conn || !nickname)
     return NULL;
 
+  /* Get nickname from nickname@server string */
+  silc_parse_userfqdn(nickname, nick, sizeof(nick), NULL, 0);
+
   /* Parse nickname in case it is formatted */
-  if (!silc_client_nickname_parse(client, conn, (char *)nickname, &parsed))
+  if (!silc_client_nickname_parse(client, conn, (char *)nick, &parsed))
     return NULL;
 
   if (!get_all && parsed)
-    format = (char *)nickname;
+    format = (char *)nick;
   if (!parsed) {
-    parsed = silc_memdup(nickname, strlen(nickname));
+    parsed = silc_memdup(nick, strlen(nick));
     if (!parsed)
       return NULL;
   }
@@ -340,7 +343,7 @@ static SilcUInt16 silc_client_get_clients_i(SilcClient client,
 
   /* Parse server name from the nickname if set */
   if (silc_parse_userfqdn(nickname, nick, sizeof(nick),
-                         serv, sizeof(serv) == 2))
+                         serv, sizeof(serv)) == 2)
     server = (const char *)serv;
   nickname = (const char *)nick;
 
@@ -1125,7 +1128,8 @@ SilcClientEntry silc_client_nickname_format(SilcClient client,
   }
 
   /* Is the requested client formatted already */
-  if (!silc_utf8_strcasecmp(client_entry->nickname, 
+  if (client_entry->nickname_normalized &&
+      !silc_utf8_strcasecmp(client_entry->nickname,
                            client_entry->nickname_normalized))
     formatted = TRUE;
 
@@ -1142,7 +1146,7 @@ SilcClientEntry silc_client_nickname_format(SilcClient client,
       unformatted = entry;
       break;
     }
-  }  
+  }
 
   /* If there are no other unformatted clients and the requested client is
      unformatted, just return it. */
@@ -1151,7 +1155,7 @@ SilcClientEntry silc_client_nickname_format(SilcClient client,
     return client_entry;
   }
 
-  /* If priority formatting then the requested client will get the 
+  /* If priority formatting then the requested client will get the
      unformatted nickname, and the unformatted client will get a new
      formatted nickname. */
   if (priority) {
@@ -1161,7 +1165,7 @@ SilcClientEntry silc_client_nickname_format(SilcClient client,
                                      &cp))
         return NULL;
 
-      silc_snprintf(client_entry->nickname, sizeof(client_entry->nickname), 
+      silc_snprintf(client_entry->nickname, sizeof(client_entry->nickname),
                    cp);
       silc_free(cp);
     }