+static void
+silc_client_command_reply_whois_print(SilcClientCommandReplyContext cmd,
+ SilcCommandStatus status)
+{
+ char buf[256];
+ int argc, len;
+ unsigned char *id_data;
+ char *nickname = NULL, *username = NULL;
+ char *realname = NULL;
+ SilcClientID *client_id;
+ SilcIDCacheEntry id_cache = NULL;
+ SilcClientEntry client_entry = NULL;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+
+ memset(buf, 0, sizeof(buf));
+
+ argc = silc_argument_get_arg_num(cmd->args);
+
+ id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
+ if (!id_data) {
+ COMMAND_REPLY_ERROR;
+ return;
+ }
+
+ client_id = silc_id_payload_parse_id(id_data, len);
+
+ nickname = silc_argument_get_arg_type(cmd->args, 3, &len);
+ if (nickname) {
+ strncat(buf, nickname, len);
+ strncat(buf, " is ", 4);
+ }
+
+ username = silc_argument_get_arg_type(cmd->args, 4, &len);
+ if (username) {
+ strncat(buf, username, len);
+ }
+
+ realname = silc_argument_get_arg_type(cmd->args, 5, &len);
+ if (realname) {
+ strncat(buf, " (", 2);
+ strncat(buf, realname, len);
+ strncat(buf, ")", 1);
+ }
+
+ /* Check if we have this client cached already. */
+ if (!silc_idcache_find_by_id_one(conn->client_cache, (void *)client_id,
+ SILC_ID_CLIENT, &id_cache)) {
+ client_entry = silc_calloc(1, sizeof(*client_entry));
+ client_entry->id = client_id;
+ silc_parse_nickname(nickname, &client_entry->nickname,
+ &client_entry->server, &client_entry->num);
+ client_entry->username = strdup(username);
+
+ /* Add client to cache */
+ silc_idcache_add(conn->client_cache, client_entry->nickname,
+ SILC_ID_CLIENT, client_id, (void *)client_entry, TRUE);
+ } else {
+ client_entry = (SilcClientEntry)id_cache->context;
+ silc_free(client_id);
+ }
+
+ if (!cmd->callback)
+ cmd->client->ops->say(cmd->client, conn, "%s", buf);
+
+ /* Notify application */
+ COMMAND_REPLY((ARGS, client_entry, nickname,
+ username, realname, NULL, NULL));
+}
+