updates.
[silc.git] / lib / silcclient / command.c
index 0afa717bb2974a95b1796c2586bbac6c6de3eb19..7e450da9627a07599c0e62a663d8f8bb56c913a1 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
 
-  Copyright (C) 1997 - 2000 Pekka Riikonen
+  Copyright (C) 1997 - 2001 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
 /* $Id$ */
 
 #include "clientlibincludes.h"
+#include "client_internal.h"
 
 /* Client command list. */
 SilcClientCommand silc_command_list[] =
@@ -41,7 +42,7 @@ SilcClientCommand silc_command_list[] =
   SILC_CLIENT_CMD(ping, PING, "PING", SILC_CF_LAG | SILC_CF_REG, 2),
   SILC_CLIENT_CMD(oper, OPER, "OPER",
                  SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER, 2),
-  SILC_CLIENT_CMD(join, JOIN, "JOIN", SILC_CF_LAG | SILC_CF_REG, 4),
+  SILC_CLIENT_CMD(join, JOIN, "JOIN", SILC_CF_LAG | SILC_CF_REG, 5),
   SILC_CLIENT_CMD(motd, MOTD, "MOTD", SILC_CF_LAG | SILC_CF_REG, 2),
   SILC_CLIENT_CMD(umode, UMODE, "UMODE", SILC_CF_LAG | SILC_CF_REG, 2),
   SILC_CLIENT_CMD(cmode, CMODE, "CMODE", SILC_CF_LAG | SILC_CF_REG, 4),
@@ -75,7 +76,7 @@ SilcClientCommand silc_command_list[] =
   cmd, FALSE, cmd->command->cmd)
 
 /* Generic function to send any command. The arguments must be sent already
-   encoded into correct form in correct order. */
+   encoded into correct form and in correct order. */
 
 void silc_client_send_command(SilcClient client, SilcClientConnection conn,
                              SilcCommand command, unsigned short ident,
@@ -201,8 +202,7 @@ void silc_client_command_free(SilcClientCommandContext ctx)
 /* Duplicate Command Context by adding reference counter. The context won't
    be free'd untill it hits zero. */
 
-SilcClientCommandContext 
-silc_client_command_dup(SilcClientCommandContext ctx)
+SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx)
 {
   ctx->users++;
   SILC_LOG_DEBUG(("Command context %p refcnt %d->%d", ctx, ctx->users - 1,
@@ -217,6 +217,16 @@ static void silc_client_command_destructor(void *context)
   silc_client_command_free((SilcClientCommandContext)context);
 }
 
+/* silc_client_get_client completion callback */
+void silc_client_command_completion(SilcClient client,
+                                   SilcClientConnection conn,
+                                   SilcClientEntry clients,
+                                   unsigned int clients_count,
+                                   void *context)
+{
+
+}
+
 /* Command WHOIS. This command is used to query information about 
    specific user. */
 
@@ -490,7 +500,7 @@ SILC_CLIENT_CMD_FUNC(invite)
   }
 
   /* Find channel entry */
-  channel_entry = silc_idlist_get_channel(client, conn, cmd->argv[2]);
+  channel_entry = silc_client_get_channel(client, conn, cmd->argv[2]);
   if (!channel_entry) {
     cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
     COMMAND_ERROR;
@@ -531,7 +541,7 @@ SILC_TASK_CALLBACK(silc_client_command_quit_cb)
 
   /* Close connection */
   q->client->ops->disconnect(q->client, q->conn);
-  silc_client_close_connection(q->client, q->conn->sock);
+  silc_client_close_connection(q->client, q->conn->sock->user_data);
 
   silc_free(q);
 }
@@ -834,7 +844,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
   } else {
     name = cmd->argv[1];
 
-    channel = silc_idlist_get_channel(cmd->client, conn, name);
+    channel = silc_client_get_channel(cmd->client, conn, name);
     if (!channel) {
       cmd->client->ops->say(cmd->client, conn, "You are on that channel");
       COMMAND_ERROR;
@@ -1023,7 +1033,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
   } else {
     name = cmd->argv[1];
 
-    channel = silc_idlist_get_channel(cmd->client, conn, name);
+    channel = silc_client_get_channel(cmd->client, conn, name);
     if (!channel) {
       cmd->client->ops->say(cmd->client, conn, "You are on that channel");
       COMMAND_ERROR;
@@ -1233,6 +1243,7 @@ SILC_CLIENT_CMD_FUNC(connect)
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer;
   unsigned char port[4];
+  unsigned int tmp;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1247,8 +1258,10 @@ SILC_CLIENT_CMD_FUNC(connect)
     goto out;
   }
 
-  if (cmd->argc == 3)
-    SILC_PUT32_MSB(atoi(cmd->argv[2]), port);
+  if (cmd->argc == 3) {
+    tmp = atoi(cmd->argv[2]);
+    SILC_PUT32_MSB(tmp, port);
+  }
 
   if (cmd->argc == 3)
     buffer = silc_command_payload_encode_va(SILC_COMMAND_CONNECT, 0, 2, 
@@ -1282,6 +1295,7 @@ SILC_CLIENT_CMD_FUNC(close)
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer;
   unsigned char port[4];
+  unsigned int tmp;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1296,8 +1310,10 @@ SILC_CLIENT_CMD_FUNC(close)
     goto out;
   }
 
-  if (cmd->argc == 3)
-    SILC_PUT32_MSB(atoi(cmd->argv[2]), port);
+  if (cmd->argc == 3) {
+    tmp = atoi(cmd->argv[2]);
+    SILC_PUT32_MSB(tmp, port);
+  }
 
   if (cmd->argc == 3)
     buffer = silc_command_payload_encode_va(SILC_COMMAND_CLOSE, 0, 2,