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