]> Pileus Git - ~andy/lamechat/blob - chat.h
Support pre-formatted text.
[~andy/lamechat] / chat.h
1 /*
2  * Copyright (C) 2017 Andy Spencer <andy753421@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /* Message Types */
19 typedef unsigned long long stamp_t;
20
21 typedef struct server_t  server_t;
22 typedef struct channel_t channel_t;
23 typedef struct user_t    user_t;
24
25 typedef enum {
26         IRC,
27         XMPP,
28 } protocol_t;
29
30 typedef struct server_t {
31         protocol_t  protocol;
32         char       *name;
33         server_t   *next;
34 } server_t;
35
36 typedef struct channel_t {
37         server_t   *server;
38         char       *name;
39         char       *topic;
40         FILE       *log;
41         int         seen;
42         channel_t  *next;
43 } channel_t;
44
45 typedef struct user_t {
46         server_t   *server;
47         char       *name;
48         user_t     *alias;
49         user_t     *next;
50 } user_t;
51
52 typedef struct {
53         stamp_t     when;
54         channel_t  *channel;
55         user_t     *from;
56         char       *text;
57 } message_t;
58
59 /* Global Data */
60 extern server_t  *servers;
61 extern channel_t *channels;
62 extern user_t    *users;
63 extern message_t *messages;
64 extern int        history;
65
66 /* Chat functions */
67 void chat_init(void);
68 void chat_config(const char *group, const char *name,
69                  const char *key, const char *value);
70 void chat_recv(channel_t *channel, user_t *from, const char *text);
71 void chat_send(channel_t *channel, const char *text);
72 void chat_exit(void);
73
74 void add_server(server_t *server);
75 void add_channel(channel_t *channel);
76 void add_user(user_t *user);
77
78 /* IRC functions */
79 extern void irc_config(server_t *server, channel_t *channel,
80                        const char *group, const char *name,
81                        const char *key, const char *value);
82 extern void irc_send(channel_t *channel, const char *text);
83 extern void irc_exit(void);
84 extern void irc_init(void);
85
86 /* XMPP functions */
87 extern void xmpp_init(void);
88 extern void xmpp_config(server_t *server, channel_t *channel,
89                         const char *group, const char *name,
90                         const char *key, const char *value);
91 extern void xmpp_send(channel_t *channel, const char *text);
92 extern void xmpp_exit(void);