Merged silc_1_0_branch to trunk.
[silc.git] / lib / silcclient / command.h
index 33479ec86062e51c6f3ec9237548ed2e4cc6c0a9..c6c597de1cb49f038bb03bc0ca96935819c0fb00 100644 (file)
@@ -1,6 +1,6 @@
 /*
 
-  command.h 
+  command.h
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
@@ -36,7 +36,7 @@ struct SilcClientCommandStruct {
   SilcCommandCb reply;            /* Command reply callback */
   char *name;                     /* Name of the command (optional) */
   SilcUInt8 max_args;             /* Maximum arguments (optional)  */
-  SilcUInt16 ident;                       /* Identifier for command (optional)  */
+  SilcUInt16 ident;               /* Identifier for command (optional)  */
   struct SilcClientCommandStruct *next;
 };
 
@@ -60,9 +60,10 @@ struct SilcClientCommandContextStruct {
    executed after command reply has been executed. */
 typedef struct SilcClientCommandPendingStruct {
   SilcCommand reply_cmd;
+  SilcUInt16 ident;
+  unsigned int reply_check : 8;
   SilcCommandCb callback;
   void *context;
-  SilcUInt16 ident;
   struct SilcClientCommandPendingStruct *next;
 } SilcClientCommandPending;
 
@@ -87,14 +88,20 @@ silc_client_command_unregister(client, SILC_COMMAND_##cmd,          \
 void silc_client_command_##func(void *context, void *context2)
 
 /* Executed pending command callback */
-#define SILC_CLIENT_PENDING_EXEC(ctx, cmd)                             \
-do {                                                                   \
-  if ((ctx)->callback)                                                 \
-    (*ctx->callback)(ctx->context, ctx);                               \
-  silc_client_command_pending_del((ctx)->sock->user_data, (cmd),       \
-                                 (ctx)->ident);                        \
+#define SILC_CLIENT_PENDING_EXEC(ctx, cmd)                               \
+do {                                                                     \
+  int _i;                                                                \
+  for (_i = 0; _i < ctx->callbacks_count; _i++)                                  \
+    if (ctx->callbacks[_i].callback)                                     \
+      (*ctx->callbacks[_i].callback)(ctx->callbacks[_i].context, ctx);   \
+  silc_client_command_pending_del(ctx->sock->user_data, cmd, ctx->ident); \
 } while(0)
 
+SilcClientCommandContext silc_client_command_alloc(void);
+void silc_client_command_free(SilcClientCommandContext ctx);
+SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx);
+SilcClientCommand silc_client_command_find(SilcClient client,
+                                          const char *name);
 bool silc_client_command_register(SilcClient client,
                                  SilcCommand command,
                                  const char *name,
@@ -112,11 +119,15 @@ void silc_client_commands_unregister(SilcClient client);
 void silc_client_command_pending_del(SilcClientConnection conn,
                                     SilcCommand reply_cmd,
                                     SilcUInt16 ident);
-int silc_client_command_pending_check(SilcClientConnection conn,
-                                     SilcClientCommandReplyContext ctx,
-                                     SilcCommand command, 
-                                     SilcUInt16 ident);
-
+SilcClientCommandPendingCallbacks
+silc_client_command_pending_check(SilcClientConnection conn,
+                                 SilcClientCommandReplyContext ctx,
+                                 SilcCommand command,
+                                 SilcUInt16 ident,
+                                 SilcUInt32 *callbacks_count);
+void silc_client_command_process(SilcClient client,
+                                SilcSocketConnection sock,
+                                SilcPacketContext *packet);
 SILC_CLIENT_CMD_FUNC(whois);
 SILC_CLIENT_CMD_FUNC(whowas);
 SILC_CLIENT_CMD_FUNC(identify);
@@ -137,6 +148,7 @@ SILC_CLIENT_CMD_FUNC(cumode);
 SILC_CLIENT_CMD_FUNC(kick);
 SILC_CLIENT_CMD_FUNC(ban);
 SILC_CLIENT_CMD_FUNC(detach);
+SILC_CLIENT_CMD_FUNC(watch);
 SILC_CLIENT_CMD_FUNC(silcoper);
 SILC_CLIENT_CMD_FUNC(leave);
 SILC_CLIENT_CMD_FUNC(users);