0c7fb6a89489df2d1bc702cbb1dbcc0059b26a4a
[silc.git] / lib / silccore / silcnotify.h
1 /*
2  
3   silcnotify.h
4  
5   Author: Pekka Riikonen <priikone@silcnet.org>
6  
7   Copyright (C) 1997 - 2001 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 /****h* silccore/SILC Notify Interface
22  *
23  * DESCRIPTION
24  *
25  * Implementation of the Notify Payload. Notify Payload is used usually
26  * by servers to send different kind of important notify messages to other
27  * servers and to clients.
28  *
29  ***/
30
31 #ifndef SILCNOTIFY_H
32 #define SILCNOTIFY_H
33
34 /****s* silccore/SilcNotifyAPI/SilcNotifyPayload
35  *
36  * NAME
37  * 
38  *    typedef struct SilcNotifyPayloadStruct *SilcNotifyPayload;
39  *
40  * DESCRIPTION
41  *
42  *    This context is the actual Notify Payload and is allocated
43  *    by silc_notify_payload_parse and given as argument usually to
44  *    all silc_notify_payload_* functions.  It is freed by the
45  *    silc_notify_payload_free function.
46  *
47  ***/
48 typedef struct SilcNotifyPayloadStruct *SilcNotifyPayload;
49
50 /****d* silccore/SilcNotifyAPI/SilcNotifyType
51  *
52  * NAME
53  * 
54  *    typedef SilcUInt16 SilcNotifyType;
55  *
56  * DESCRIPTION
57  *
58  *    The notify type definition and all of the notify types.
59  *
60  * SOURCE
61  */
62 typedef SilcUInt16 SilcNotifyType;
63
64 /* SILC notify types. Server may send these notify types to client to
65    notify of some action. */
66 #define SILC_NOTIFY_TYPE_NONE            0  /* no specific type */
67 #define SILC_NOTIFY_TYPE_INVITE          1  /* invites/invite list change */
68 #define SILC_NOTIFY_TYPE_JOIN            2  /* "has joined channel" */
69 #define SILC_NOTIFY_TYPE_LEAVE           3  /* "has left channel" */
70 #define SILC_NOTIFY_TYPE_SIGNOFF         4  /* "signoff" */
71 #define SILC_NOTIFY_TYPE_TOPIC_SET       5  /* "topic has been changed" */
72 #define SILC_NOTIFY_TYPE_NICK_CHANGE     6  /* "has changed nickname" */
73 #define SILC_NOTIFY_TYPE_CMODE_CHANGE    7  /* "has changed channel mode" */
74 #define SILC_NOTIFY_TYPE_CUMODE_CHANGE   8  /* "has change mode" */
75 #define SILC_NOTIFY_TYPE_MOTD            9  /* message of the day */
76 #define SILC_NOTIFY_TYPE_CHANNEL_CHANGE  10 /* Channel's ID has changed */
77 #define SILC_NOTIFY_TYPE_SERVER_SIGNOFF  11 /* Server quitting SILC */
78 #define SILC_NOTIFY_TYPE_KICKED          12 /* Kicked from channel */
79 #define SILC_NOTIFY_TYPE_KILLED          13 /* Killed from the network */
80 #define SILC_NOTIFY_TYPE_UMODE_CHANGE    14 /* user mode was changed */
81 #define SILC_NOTIFY_TYPE_BAN             15 /* ban list change */
82 #define SILC_NOTIFY_TYPE_ERROR           16 /* error notify */
83 #define SILC_NOTIFY_TYPE_WATCH           17 /* watch notify */
84 /***/
85
86 /* Prototypes */
87
88 /****f* silccore/SilcNotifyAPI/silc_notify_payload_parse
89  *
90  * SYNOPSIS
91  *
92  *    SilcNotifyPayload
93  *    silc_notify_payload_parse(const unsigned char *payload,
94  *                              SilcUInt32 payload_len);
95  *
96  * DESCRIPTION
97  *
98  *    Parse notify payload buffer and return data into payload structure.
99  *    The `buffer' is the raw payload data.
100  *
101  ***/
102 SilcNotifyPayload silc_notify_payload_parse(const unsigned char *payload,
103                                             SilcUInt32 payload_len);
104
105 /****f* silccore/SilcNotifyAPI/silc_notify_payload_encode
106  *
107  * SYNOPSIS
108  *
109  *    SilcBuffer silc_notify_payload_encode(SilcNotifyType type,
110  *                                          SilcUInt32 argc,
111  *                                          va_list ap);
112  *
113  * DESCRIPTION
114  *
115  *    Encode notify payload with variable argument list. If `argc' is > 0
116  *    argument payloads will be associated to the notify payload. Variable
117  *    arguments must be {unsigned char *, SilcUInt32 (len)}.
118  *
119  ***/
120 SilcBuffer silc_notify_payload_encode(SilcNotifyType type, SilcUInt32 argc, 
121                                       va_list ap);
122
123 /****f* silccore/SilcNotifyAPI/silc_notify_payload_encode_args
124  *
125  * SYNOPSIS
126  *
127  *    SilcBuffer silc_notify_payload_encode_args(SilcNotifyType type,
128  *                                               SilcUInt32 argc,
129  *                                               SilcBuffer args);
130  *
131  * DESCRIPTION
132  *
133  *    Same as silc_notify_payload_encode but takes arguments from the `args'
134  *    encoded Argument Payload buffer.
135  *
136  ***/
137 SilcBuffer silc_notify_payload_encode_args(SilcNotifyType type, 
138                                            SilcUInt32 argc,
139                                            SilcBuffer args);
140
141 /****f* silccore/SilcNotifyAPI/silc_notify_payload_free
142  *
143  * SYNOPSIS
144  *
145  *    void silc_notify_payload_free(SilcNotifyPayload payload);
146  *
147  * DESCRIPTION
148  *
149  *    Frees the Notify Payload and all data in it.
150  *
151  ***/
152 void silc_notify_payload_free(SilcNotifyPayload payload);
153
154 /****f* silccore/SilcNotifyAPI/silc_notify_get_type
155  *
156  * SYNOPSIS
157  *
158  *    SilcNotifyType silc_notify_get_type(SilcNotifyPayload payload);
159  *
160  * DESCRIPTION
161  *
162  *    Return the notify type from the payload.
163  *
164  ***/
165 SilcNotifyType silc_notify_get_type(SilcNotifyPayload payload);
166
167 /****f* silccore/SilcNotifyAPI/silc_notify_get_arg_num
168  *
169  * SYNOPSIS
170  *
171  *    SilcUInt32 silc_notify_get_arg_num(SilcNotifyPayload payload);
172  *
173  * DESCRIPTION
174  *
175  *    Return the number of the arguments associated with the Notify Payload.
176  *
177  ***/
178 SilcUInt32 silc_notify_get_arg_num(SilcNotifyPayload payload);
179
180 /****f* silccore/SilcNotifyAPI/silc_notify_get_args
181  *
182  * SYNOPSIS
183  *
184  *    SilcArgumentPayload silc_notify_get_args(SilcNotifyPayload payload);
185  *
186  * DESCRIPTION
187  *
188  *    Return the Argument Payload containing the arguments from the
189  *    Notify Payload. The caller must not free it.
190  *
191  ***/
192 SilcArgumentPayload silc_notify_get_args(SilcNotifyPayload payload);
193
194 #endif