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