updates.
[silc.git] / apps / irssi / src / core / chat-protocols.h
1 #ifndef __CHAT_PROTOCOLS_H
2 #define __CHAT_PROTOCOLS_H
3
4 struct _CHAT_PROTOCOL_REC {
5         int id;
6
7         unsigned int not_initialized:1;
8         unsigned int case_insensitive:1;
9
10         char *name;
11         char *fullname;
12         char *chatnet;
13
14         CHATNET_REC *(*create_chatnet) (void);
15         SERVER_SETUP_REC *(*create_server_setup) (void);
16         CHANNEL_SETUP_REC *(*create_channel_setup) (void);
17         SERVER_CONNECT_REC *(*create_server_connect) (void);
18         void (*destroy_server_connect) (SERVER_CONNECT_REC *);
19
20         SERVER_REC *(*server_connect) (SERVER_CONNECT_REC *);
21         CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *, int);
22         QUERY_REC *(*query_create) (const char *, const char *, int);
23 };
24
25 extern GSList *chat_protocols;
26
27 #define PROTO_CHECK_CAST(object, cast, type_field, id) \
28         ((cast *) chat_protocol_check_cast(object, \
29                                 offsetof(cast, type_field), id))
30 void *chat_protocol_check_cast(void *object, int type_pos, const char *id);
31
32 #define CHAT_PROTOCOL(object) \
33         ((object) == NULL ? chat_protocol_get_default() : \
34         chat_protocol_find_id((object)->chat_type))
35
36 /* Register new chat protocol. */
37 CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec);
38
39 /* Unregister chat protocol. */
40 void chat_protocol_unregister(const char *name);
41
42 /* Find functions */
43 int chat_protocol_lookup(const char *name);
44 CHAT_PROTOCOL_REC *chat_protocol_find(const char *name);
45 CHAT_PROTOCOL_REC *chat_protocol_find_id(int id);
46 CHAT_PROTOCOL_REC *chat_protocol_find_net(GHashTable *optlist);
47
48 /* Default chat protocol to use */
49 void chat_protocol_set_default(CHAT_PROTOCOL_REC *rec);
50 CHAT_PROTOCOL_REC *chat_protocol_get_default(void);
51
52 /* Return "unknown chat protocol" record. Used when protocol name is
53    specified but it isn't registered yet. */
54 CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name);
55
56 void chat_protocols_init(void);
57 void chat_protocols_deinit(void);
58
59 #endif