updates.
[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/SilcNotifyAPI
22  *
23  * DESCRIPTION
24  *
25  * Implementation of the Notify Payload. Notify Payload is used usually
26  * 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 uint16 SilcNotifyType;
55  *
56  * DESCRIPTION
57  *
58  *    The notify type definition and all of the notify types.
59  *
60  * SOURCE
61  */
62 typedef uint16 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 /***/
83
84 /* Prototypes */
85
86 /****f* silccore/SilcNotifyAPI/silc_notify_payload_parse
87  *
88  * SYNOPSIS
89  *
90  *    SilcNotifyPayload silc_notify_payload_parse(SilcBuffer buffer);
91  *
92  * DESCRIPTION
93  *
94  *    Parse notify payload buffer and return data into payload structure.
95  *    The `buffer' is the raw payload data.
96  *
97  ***/
98 SilcNotifyPayload silc_notify_payload_parse(SilcBuffer buffer);
99
100 /****f* silccore/SilcNotifyAPI/silc_notify_payload_encode
101  *
102  * SYNOPSIS
103  *
104  *    SilcBuffer silc_notify_payload_encode(SilcNotifyType type, uint32 argc, 
105  *                                          va_list ap);
106  *
107  * DESCRIPTION
108  *
109  *    Encode notify payload with variable argument list. If `argc' is > 0
110  *    argument payloads will be associated to the notify payload. Variable
111  *    arguments must be {usigned char *, uint32 (len)}.
112  *
113  ***/
114 SilcBuffer silc_notify_payload_encode(SilcNotifyType type, uint32 argc, 
115                                       va_list ap);
116
117 /****f* silccore/SilcNotifyAPI/silc_notify_payload_encode_args
118  *
119  * SYNOPSIS
120  *
121  *    SilcBuffer silc_notify_payload_encode_args(SilcNotifyType type, 
122  *                                               uint32 argc,
123  *                                               SilcBuffer args);
124  *
125  * DESCRIPTION
126  *
127  *    Same as silc_notify_payload_encode but takes arguments from the `args'
128  *    encoded Argument Payload buffer.
129  *
130  ***/
131 SilcBuffer silc_notify_payload_encode_args(SilcNotifyType type, 
132                                            uint32 argc,
133                                            SilcBuffer args);
134
135 /****f* silccore/SilcNotifyAPI/silc_notify_payload_free
136  *
137  * SYNOPSIS
138  *
139  *    void silc_notify_payload_free(SilcNotifyPayload payload);
140  *
141  * DESCRIPTION
142  *
143  *    Frees the Notify Payload and all data in it.
144  *
145  ***/
146 void silc_notify_payload_free(SilcNotifyPayload payload);
147
148 /****f* silccore/SilcNotifyAPI/silc_notify_get_type
149  *
150  * SYNOPSIS
151  *
152  *    SilcNotifyType silc_notify_get_type(SilcNotifyPayload payload);
153  *
154  * DESCRIPTION
155  *
156  *    Return the notify type from the payload.
157  *
158  ***/
159 SilcNotifyType silc_notify_get_type(SilcNotifyPayload payload);
160
161 /****f* silccore/SilcNotifyAPI/silc_notify_get_arg_num
162  *
163  * SYNOPSIS
164  *
165  *    uint32 silc_notify_get_arg_num(SilcNotifyPayload payload);
166  *
167  * DESCRIPTION
168  *
169  *    Return the number of the arguments associated with the Notify Payload.
170  *
171  ***/
172 uint32 silc_notify_get_arg_num(SilcNotifyPayload payload);
173
174 /****f* silccore/SilcNotifyAPI/silc_notify_get_args
175  *
176  * SYNOPSIS
177  *
178  *    SilcArgumentPayload silc_notify_get_args(SilcNotifyPayload payload);
179  *
180  * DESCRIPTION
181  *
182  *    Return the Argument Payload containing the arguments from the
183  *    Notify Payload. The caller must not free it.
184  *
185  ***/
186 SilcArgumentPayload silc_notify_get_args(SilcNotifyPayload payload);
187
188 #endif