source: code/icb.h@ 59a7416

Last change on this file since 59a7416 was 1d2125a, checked in by Mike Belopuhov <mike@…>, 11 years ago

Add support for the moderator table that specifies (currently up
to 50) users that are allowed to become moderators.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2009 Mike Belopuhov
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include <sys/queue.h>
18
19#define ICB_MSGSIZE 256
20
21#define ICB_MAXGRPLEN 32
22#define ICB_MAXNICKLEN 32
23#define ICB_MAXPASSLEN 32
24#define ICB_MAXTOPICLEN 160
25#define ICB_MTABLEN 50 /* XXX */
26
27#define ICB_M_LOGIN 'a'
28#define ICB_M_OPEN 'b'
29#define ICB_M_PERSONAL 'c'
30#define ICB_M_STATUS 'd'
31enum {
32 STATUS_ARRIVE,
33 STATUS_BOOT,
34 STATUS_DEPART,
35 STATUS_HELP,
36 STATUS_NAME,
37 STATUS_NOBEEP,
38 STATUS_NOTIFY,
39 STATUS_SIGNON,
40 STATUS_SIGNOFF,
41 STATUS_STATUS,
42 STATUS_TOPIC,
43 STATUS_WARNING
44};
45#define ICB_M_ERROR 'e'
46#define ICB_M_IMPORTANT 'f'
47#define ICB_M_EXIT 'g'
48#define ICB_M_COMMAND 'h'
49#define ICB_M_CMDOUT 'i'
50enum {
51 CMDOUT_CO,
52 CMDOUT_EC,
53 CMDOUT_WG,
54 CMDOUT_WH,
55 CMDOUT_WL,
56};
57#define ICB_M_PROTO 'j'
58#define ICB_M_BEEP 'k'
59#define ICB_M_PING 'l'
60#define ICB_M_PONG 'm'
61#define ICB_M_NOOP 'n'
62
63#define ICB_M_SEP '\001'
64
65struct icb_group;
66
67struct icb_session {
68 char nick[ICB_MAXNICKLEN];
69 char client[ICB_MAXNICKLEN];
70 char host[MAXHOSTNAMELEN];
71 char buffer[ICB_MSGSIZE+1];
72 struct event ev;
73 LIST_ENTRY(icb_session) entry;
74 struct bufferevent *bev;
75 struct icb_group *group;
76 size_t length;
77 time_t login;
78 time_t last;
79 int port;
80 uint32_t flags;
81#define SETF(t, f) ((t) |= (f))
82#define CLRF(t, f) ((t) &= ~(f))
83#define ISSETF(t, f) ((t) & (f))
84#define ICB_SF_PROTOSENT 0x01
85#define ICB_SF_LOGGEDIN 0x02
86#define ICB_SF_NOGROUP 0x08
87#define ICB_SF_NOBEEP 0x10
88#define ICB_SF_NOBEEP2 0x20
89};
90
91struct icb_group {
92 char name[ICB_MAXGRPLEN];
93 char mpass[ICB_MAXPASSLEN];
94 char topic[ICB_MAXTOPICLEN];
95 LIST_ENTRY(icb_group) entry;
96 LIST_HEAD(, icb_session) sess;
97 struct icb_session *mod;
98};
99
100LIST_HEAD(icb_grlist, icb_group) groups;
101
102struct icbd_callbacks {
103 void (*drop)(struct icb_session *, char *);
104 void (*log)(struct icb_session *, int, const char *, ...);
105 void (*send)(struct icb_session *, char *, ssize_t);
106};
107
108#ifndef nitems
109#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
110#endif
111
112/* cmd.c */
113void *icb_cmd_lookup(char *);
114
115/* icb.c */
116struct icb_group *icb_addgroup(struct icb_session *, char *, char *);
117void icb_cmdout(struct icb_session *, int, char *);
118void icb_delgroup(struct icb_group *);
119void icb_error(struct icb_session *, const char *, ...);
120void icb_init(struct icbd_callbacks *);
121void icb_input(struct icb_session *);
122int icb_ismod(struct icb_group *, struct icb_session *);
123int icb_modpermit(struct icb_session *);
124int icb_pass(struct icb_group *, struct icb_session *, struct icb_session *);
125void icb_privmsg(struct icb_session *, char *, char *);
126void icb_remove(struct icb_session *, char *);
127void icb_sendfmt(struct icb_session *, const char *, ...);
128void icb_start(struct icb_session *);
129void icb_status(struct icb_session *, int, const char *, ...);
130void icb_status_group(struct icb_group *, struct icb_session *, int ,
131 const char *, ...);
132void icb_who(struct icb_session *, struct icb_group *);
133
134/* callbacks from icbd.c */
135void (*icb_drop)(struct icb_session *, char *);
136void (*icb_log)(struct icb_session *, int, const char *, ...);
137void (*icb_send)(struct icb_session *, char *, ssize_t);
Note: See TracBrowser for help on using the repository browser.