Moved silc_client_ch[u]mode[_char] to client library from silc/.
[silc.git] / lib / silccore / silccommand.h
1 /*
2
3   silccommand.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 Pekka Riikonen
8
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.
13   
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.
18
19 */
20
21 #ifndef SILCCOMMAND_H
22 #define SILCCOMMAND_H
23
24 /* Command function callback. The actual command function pointer. */
25 typedef void (*SilcCommandCb)(void *context);
26
27 /* Typedefinition for SILC commands. */
28 typedef unsigned char SilcCommand;
29
30 /* Forward declaration for Command Payload parsed from packet. The
31    actual structure is defined in source file and is private data. */
32 typedef struct SilcCommandPayloadStruct *SilcCommandPayload;
33
34 /* Command flags. These set how the commands behave on different
35    situations. These can be OR'ed together to set multiple flags. */
36 typedef enum {
37   SILC_CF_NONE           = 0,
38
39   /* Command may only be used once per (about) 2 seconds */
40   SILC_CF_LAG            = (1L << 1),
41
42   /* Command is available for registered connections (connections
43      whose ID has been created. */
44   SILC_CF_REG            = (1L << 2),
45
46   /* Command is available only for server operators */
47   SILC_CF_OPER           = (1L << 3),
48
49   /* Command is available only for SILC (router) operators. If this 
50      is set SILC_CF_OPER is not necessary to be set. */
51   SILC_CF_SILC_OPER      = (1L << 4),
52
53 } SilcCommandFlag;
54
55 /* All SILC commands. These are commands that have client and server
56    counterparts. These are pretty much the same as in IRC. */
57 #define SILC_COMMAND_NONE               0
58 #define SILC_COMMAND_WHOIS              1
59 #define SILC_COMMAND_WHOWAS             2
60 #define SILC_COMMAND_IDENTIFY           3
61 #define SILC_COMMAND_NICK               4
62 #define SILC_COMMAND_LIST               5
63 #define SILC_COMMAND_TOPIC              6
64 #define SILC_COMMAND_INVITE             7
65 #define SILC_COMMAND_QUIT               8
66 #define SILC_COMMAND_KILL               9
67 #define SILC_COMMAND_INFO               10
68 #define SILC_COMMAND_CONNECT            11
69 #define SILC_COMMAND_PING               12
70 #define SILC_COMMAND_OPER               13
71 #define SILC_COMMAND_JOIN               14
72 #define SILC_COMMAND_MOTD               15
73 #define SILC_COMMAND_UMODE              16
74 #define SILC_COMMAND_CMODE              17
75 #define SILC_COMMAND_CUMODE             18
76 #define SILC_COMMAND_KICK               19
77 #define SILC_COMMAND_RESTART            20
78 #define SILC_COMMAND_CLOSE              21
79 #define SILC_COMMAND_DIE                22
80 #define SILC_COMMAND_SILCOPER           23
81 #define SILC_COMMAND_LEAVE              24
82 #define SILC_COMMAND_NAMES              25
83
84 /* Reserved */
85 #define SILC_COMMAND_RESERVED           255
86
87 /* Command Status type */
88 typedef unsigned short SilcCommandStatus;
89
90 /* Command Status messages */
91 #define SILC_STATUS_OK                      0
92 #define SILC_STATUS_LIST_START              1
93 #define SILC_STATUS_LIST_ITEM               2
94 #define SILC_STATUS_LIST_END                3
95 #define SILC_STATUS_ERR_NO_SUCH_NICK        10
96 #define SILC_STATUS_ERR_NO_SUCH_CHANNEL     11
97 #define SILC_STATUS_ERR_NO_SUCH_SERVER      12
98 #define SILC_STATUS_ERR_TOO_MANY_TARGETS    13
99 #define SILC_STATUS_ERR_NO_RECIPIENT        14
100 #define SILC_STATUS_ERR_UNKNOWN_COMMAND     15
101 #define SILC_STATUS_ERR_WILDCARDS           16
102 #define SILC_STATUS_ERR_NO_CLIENT_ID        17
103 #define SILC_STATUS_ERR_NO_CHANNEL_ID       18
104 #define SILC_STATUS_ERR_NO_SERVER_ID        19
105 #define SILC_STATUS_ERR_BAD_CLIENT_ID       20
106 #define SILC_STATUS_ERR_BAD_CHANNEL_ID      21
107 #define SILC_STATUS_ERR_NO_SUCH_CLIENT_ID   22
108 #define SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID  23
109 #define SILC_STATUS_ERR_NICKNAME_IN_USE     24
110 #define SILC_STATUS_ERR_NOT_ON_CHANNEL      25
111 #define SILC_STATUS_ERR_USER_NOT_ON_CHANNEL 26
112 #define SILC_STATUS_ERR_USER_ON_CHANNEL     27
113 #define SILC_STATUS_ERR_NOT_REGISTERED      28
114 #define SILC_STATUS_ERR_NOT_ENOUGH_PARAMS   29
115 #define SILC_STATUS_ERR_TOO_MANY_PARAMS     30
116 #define SILC_STATUS_ERR_PERM_DENIED         31
117 #define SILC_STATUS_ERR_BANNED_FROM_SERVER  32
118 #define SILC_STATUS_ERR_BAD_PASSWORD        33
119 #define SILC_STATUS_ERR_CHANNEL_IS_FULL     34
120 #define SILC_STATUS_ERR_NOT_INVITED         35
121 #define SILC_STATUS_ERR_BANNED_FROM_CHANNEL 36
122 #define SILC_STATUS_ERR_UNKNOWN_MODE        37
123 #define SILC_STATUS_ERR_NOT_YOU             38
124 #define SILC_STATUS_ERR_NO_CHANNEL_PRIV     39
125 #define SILC_STATUS_ERR_NO_SERVER_PRIV      40
126 #define SILC_STATUS_ERR_NO_ROUTER_PRIV      41
127 #define SILC_STATUS_ERR_BAD_NICKNAME        42
128 #define SILC_STATUS_ERR_BAD_CHANNEL         43
129 #define SILC_STATUS_ERR_AUTH_FAILED         44
130
131 /* Prototypes */
132 SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer);
133 SilcBuffer silc_command_payload_encode(SilcCommand cmd,
134                                        unsigned int argc,
135                                        unsigned char **argv,
136                                        unsigned int *argv_lens,
137                                        unsigned int *argv_types,
138                                        unsigned short ident);
139 SilcBuffer silc_command_payload_encode_va(SilcCommand cmd, 
140                                           unsigned short ident, 
141                                           unsigned int argc, ...);
142 SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd, 
143                                            unsigned short ident, 
144                                            unsigned int argc, va_list ap);
145 SilcBuffer 
146 silc_command_reply_payload_encode_va(SilcCommand cmd, 
147                                      SilcCommandStatus status,
148                                      unsigned short ident,
149                                      unsigned int argc, ...);
150 void silc_command_free_payload(SilcCommandPayload payload);
151 SilcCommand silc_command_get(SilcCommandPayload payload);
152 SilcArgumentPayload silc_command_get_args(SilcCommandPayload payload);
153 unsigned short silc_command_get_ident(SilcCommandPayload payload);
154
155 #endif