updates.
[silc.git] / lib / silcclient / command.c
index 7c94838374a6167cca177d69a3af66e4dac7974e..c0c058d00aa865054db8f0cd17ff918ed946c2ea 100644 (file)
@@ -18,7 +18,8 @@
 */
 /* $Id$ */
 
-#include "clientlibincludes.h"
+#include "silcincludes.h"
+#include "silcclient.h"
 #include "client_internal.h"
 
 #define SILC_NOT_CONNECTED(x, c) \
@@ -40,8 +41,8 @@
    encoded into correct form and in correct order. */
 
 void silc_client_command_send(SilcClient client, SilcClientConnection conn,
-                             SilcCommand command, uint16 ident,
-                             uint32 argc, ...)
+                             SilcCommand command, SilcUInt16 ident,
+                             SilcUInt32 argc, ...)
 {
   SilcBuffer packet;
   va_list ap;
@@ -92,7 +93,7 @@ void silc_client_command_call(SilcClientCommand command,
 
 void silc_client_command_pending(SilcClientConnection conn,
                                 SilcCommand reply_cmd,
-                                uint16 ident,
+                                SilcUInt16 ident,
                                 SilcCommandCb callback,
                                 void *context)
 {
@@ -110,7 +111,7 @@ void silc_client_command_pending(SilcClientConnection conn,
 
 void silc_client_command_pending_del(SilcClientConnection conn,
                                     SilcCommand reply_cmd,
-                                    uint16 ident)
+                                    SilcUInt16 ident)
 {
   SilcClientCommandPending *r;
 
@@ -129,7 +130,7 @@ void silc_client_command_pending_del(SilcClientConnection conn,
 int silc_client_command_pending_check(SilcClientConnection conn,
                                      SilcClientCommandReplyContext ctx,
                                      SilcCommand command, 
-                                     uint16 ident)
+                                     SilcUInt16 ident)
 {
   SilcClientCommandPending *r;
 
@@ -321,9 +322,8 @@ SILC_CLIENT_CMD_FUNC(nick_change)
   SilcClientConnection conn = cmd->conn;
   SilcClientCommandReplyContext reply = 
     (SilcClientCommandReplyContext)context2;
-  SilcCommandStatus status;
+  SilcCommandStatus status = silc_command_get_status(reply->payload);
 
-  SILC_GET16_MSB(status, silc_argument_get_arg_type(reply->args, 1, NULL));
   if (status == SILC_STATUS_OK) {
     /* Set the nickname */
     silc_idcache_del_by_context(conn->client_cache, conn->local_entry);
@@ -545,7 +545,7 @@ SILC_CLIENT_CMD_FUNC(invite)
   SilcClientEntry client_entry = NULL;
   SilcChannelEntry channel;
   SilcBuffer buffer, clidp, chidp;
-  uint32 type = 0;
+  SilcUInt32 type = 0;
   char *nickname = NULL, *name;
   char *invite = NULL;
 
@@ -748,9 +748,8 @@ SILC_CLIENT_CMD_FUNC(kill_remove)
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientCommandReplyContext reply = 
     (SilcClientCommandReplyContext)context2;
-  SilcCommandStatus status;
+  SilcCommandStatus status = silc_command_get_status(reply->payload);
 
-  SILC_GET16_MSB(status, silc_argument_get_arg_type(reply->args, 1, NULL));
   if (status == SILC_STATUS_OK) {
     /* Remove with timeout */
     silc_schedule_task_add(cmd->client->schedule, cmd->conn->sock->sock,
@@ -986,7 +985,7 @@ SILC_CLIENT_CMD_FUNC(join)
       if (!strcasecmp(cmd->argv[i + 1], "-pubkey")) {
        auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
                                                  cmd->client->private_key,
-                                                 conn->hash,
+                                                 cmd->client->rng, conn->hash,
                                                  conn->local_id,
                                                  SILC_ID_CLIENT);
       } else {
@@ -1075,7 +1074,7 @@ SILC_CLIENT_CMD_FUNC(umode)
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer, idp;
   unsigned char *cp, modebuf[4];
-  uint32 mode, add, len;
+  SilcUInt32 mode, add, len;
   int i;
 
   if (!cmd->conn) {
@@ -1170,7 +1169,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
   SilcChannelEntry channel;
   SilcBuffer buffer, chidp, auth = NULL;
   unsigned char *name, *cp, modebuf[4], tmp[4], *arg = NULL;
-  uint32 mode, add, type, len, arg_len = 0;
+  SilcUInt32 mode, add, type, len, arg_len = 0;
   int i;
 
   if (!cmd->conn) {
@@ -1335,6 +1334,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
        if (!strcasecmp(cmd->argv[3], "-pubkey")) {
          auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
                                                    cmd->client->private_key,
+                                                   cmd->client->rng, 
                                                    conn->hash,
                                                    conn->local_id,
                                                    SILC_ID_CLIENT);
@@ -1400,7 +1400,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
   SilcClientEntry client_entry;
   SilcBuffer buffer, clidp, chidp, auth = NULL;
   unsigned char *name, *cp, modebuf[4];
-  uint32 mode = 0, add, len;
+  SilcUInt32 mode = 0, add, len;
   char *nickname = NULL;
   int i;
 
@@ -1493,6 +1493,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
          if (!strcasecmp(cmd->argv[4], "-pubkey")) {
            auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
                                                      cmd->client->private_key,
+                                                     cmd->client->rng,
                                                      conn->hash,
                                                      conn->local_id,
                                                      SILC_ID_CLIENT);
@@ -1649,7 +1650,7 @@ SILC_CLIENT_CMD_FUNC(kick)
 }
 
 static void silc_client_command_oper_send(unsigned char *data,
-                                         uint32 data_len, void *context)
+                                         SilcUInt32 data_len, void *context)
 {
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientConnection conn = cmd->conn;
@@ -1659,7 +1660,7 @@ static void silc_client_command_oper_send(unsigned char *data,
     /* Encode the public key authentication payload */
     auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
                                              cmd->client->private_key,
-                                             conn->hash,
+                                             cmd->client->rng, conn->hash,
                                              conn->local_id,
                                              SILC_ID_CLIENT);
   } else {
@@ -1717,7 +1718,7 @@ SILC_CLIENT_CMD_FUNC(oper)
 }
 
 static void silc_client_command_silcoper_send(unsigned char *data,
-                                             uint32 data_len, void *context)
+                                             SilcUInt32 data_len, void *context)
 {
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientConnection conn = cmd->conn;
@@ -1727,7 +1728,7 @@ static void silc_client_command_silcoper_send(unsigned char *data,
     /* Encode the public key authentication payload */
     auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
                                              cmd->client->private_key,
-                                             conn->hash,
+                                             cmd->client->rng, conn->hash,
                                              conn->local_id,
                                              SILC_ID_CLIENT);
   } else {
@@ -1792,7 +1793,7 @@ SILC_CLIENT_CMD_FUNC(connect)
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer;
   unsigned char port[4];
-  uint32 tmp;
+  SilcUInt32 tmp;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1919,7 +1920,7 @@ SILC_CLIENT_CMD_FUNC(close)
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer;
   unsigned char port[4];
-  uint32 tmp;
+  SilcUInt32 tmp;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -2164,9 +2165,7 @@ SILC_CLIENT_CMD_FUNC(getkey)
       } else {
        SilcClientCommandReplyContext reply = 
          (SilcClientCommandReplyContext)context2;
-       SilcCommandStatus status;
-       unsigned char *tmp = silc_argument_get_arg_type(reply->args, 1, NULL);
-       SILC_GET16_MSB(status, tmp);
+       SilcCommandStatus status = silc_command_get_status(reply->payload);
        
        /* If nickname was not found, then resolve the server. */
        if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
@@ -2239,8 +2238,8 @@ bool silc_client_command_register(SilcClient client,
                                  const char *name,
                                  SilcCommandCb command_function,
                                  SilcCommandCb command_reply_function,
-                                 uint8 max_args,
-                                 uint16 ident)
+                                 SilcUInt8 max_args,
+                                 SilcUInt16 ident)
 {
   SilcClientCommand cmd;
 
@@ -2265,7 +2264,7 @@ bool silc_client_command_unregister(SilcClient client,
                                    SilcCommand command,
                                    SilcCommandCb command_function,
                                    SilcCommandCb command_reply_function,
-                                   uint16 ident)
+                                   SilcUInt16 ident)
 {
   SilcClientCommand cmd;
 
@@ -2303,7 +2302,7 @@ void silc_client_commands_register(SilcClient client)
   SILC_CLIENT_CMD(info, INFO, "INFO", 2);
   SILC_CLIENT_CMD(connect, CONNECT, "CONNECT", 3);
   SILC_CLIENT_CMD(ping, PING, "PING", 2);
-  SILC_CLIENT_CMD(oper, OPER, "OPER", 2);
+  SILC_CLIENT_CMD(oper, OPER, "OPER", 3);
   SILC_CLIENT_CMD(join, JOIN, "JOIN", 9);
   SILC_CLIENT_CMD(motd, MOTD, "MOTD", 2);
   SILC_CLIENT_CMD(umode, UMODE, "UMODE", 2);