5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
24 #include "command_reply.h"
27 Structure holding one command and pointer to its function.
31 Callback function called when this command is executed.
35 The actual command. These are defined in silccore/silccommand.h
39 Logical name of the command. This is the visible command name
40 that user uses when calling command. Eg. NICK.
44 Flags for the command. These set how command behaves on different
45 situations. Server sets these flags as well, but to be sure
46 that our client never sends wrong commands we preserve the
47 flags on client side as well.
49 XXX: We preserve these so that we define them but currently we
50 don't check the flags at all.
57 SilcCommandFlag flags;
58 unsigned int max_args;
61 /* All client commands */
62 extern SilcClientCommand silc_command_list[];
64 /* Context sent as argument to all commands */
67 SilcClientConnection conn;
68 SilcClientCommand *command;
71 unsigned int *argv_lens;
72 unsigned int *argv_types;
73 int pending; /* Command is being re-processed when TRUE */
74 } *SilcClientCommandContext;
76 /* Structure holding pending commands. If command is pending it will be
77 executed after command reply has been executed. */
78 typedef struct SilcClientCommandPendingStruct {
79 SilcCommand reply_cmd;
80 SilcCommandCb callback;
83 struct SilcClientCommandPendingStruct *next;
84 } SilcClientCommandPending;
86 /* List of pending commands */
87 extern SilcClientCommandPending *silc_command_pending;
91 /* Macro used for command declaration in command list structure */
92 #define SILC_CLIENT_CMD(func, cmd, name, flags, args) \
93 { silc_client_command_##func, SILC_COMMAND_##cmd, name, flags, args }
95 /* Macro used to declare command functions */
96 #define SILC_CLIENT_CMD_FUNC(func) \
97 void silc_client_command_##func(void *context)
99 /* Executed pending command callback */
100 #define SILC_CLIENT_COMMAND_EXEC_PENDING(ctx, cmd) \
102 if ((ctx)->callback) { \
103 (*ctx->callback)(ctx->context); \
104 silc_client_command_pending_del((ctx)->sock->user_data, (cmd), \
110 void silc_client_command_free(SilcClientCommandContext cmd);
111 void silc_client_send_command(SilcClient client, SilcClientConnection conn,
112 SilcCommand command, unsigned int argc, ...);
113 SilcClientCommand *silc_client_command_find(const char *name);
114 void silc_client_command_pending(SilcClientConnection conn,
115 SilcCommand reply_cmd,
116 unsigned short ident,
117 SilcCommandCb callback,
119 void silc_client_command_pending_del(SilcClientConnection conn,
120 SilcCommand reply_cmd,
121 unsigned short ident);
122 int silc_client_command_pending_check(SilcClientConnection conn,
123 SilcClientCommandReplyContext ctx,
125 unsigned short ident);
126 SILC_CLIENT_CMD_FUNC(whois);
127 SILC_CLIENT_CMD_FUNC(whowas);
128 SILC_CLIENT_CMD_FUNC(identify);
129 SILC_CLIENT_CMD_FUNC(nick);
130 SILC_CLIENT_CMD_FUNC(list);
131 SILC_CLIENT_CMD_FUNC(topic);
132 SILC_CLIENT_CMD_FUNC(invite);
133 SILC_CLIENT_CMD_FUNC(quit);
134 SILC_CLIENT_CMD_FUNC(kill);
135 SILC_CLIENT_CMD_FUNC(info);
136 SILC_CLIENT_CMD_FUNC(connect);
137 SILC_CLIENT_CMD_FUNC(ping);
138 SILC_CLIENT_CMD_FUNC(oper);
139 SILC_CLIENT_CMD_FUNC(join);
140 SILC_CLIENT_CMD_FUNC(motd);
141 SILC_CLIENT_CMD_FUNC(umode);
142 SILC_CLIENT_CMD_FUNC(cmode);
143 SILC_CLIENT_CMD_FUNC(cumode);
144 SILC_CLIENT_CMD_FUNC(kick);
145 SILC_CLIENT_CMD_FUNC(restart);
146 SILC_CLIENT_CMD_FUNC(close);
147 SILC_CLIENT_CMD_FUNC(die);
148 SILC_CLIENT_CMD_FUNC(silcoper);
149 SILC_CLIENT_CMD_FUNC(leave);
150 SILC_CLIENT_CMD_FUNC(users);