Author: Bleep <helveytw@home.com>
[ircu2.10.12-pk.git] / include / s_conf.h
1 /*
2  * s_conf.h
3  *
4  * $Id$ 
5  */
6 #ifndef INCLUDED_s_conf_h
7 #define INCLUDED_s_conf_h
8 #ifndef INCLUDED_time_h
9 #include <time.h>              /* struct tm */
10 #define INCLUDED_time_h
11 #endif
12 #ifndef INCLUDED_sys_types_h
13 #include <sys/types.h>
14 #define INCLUDED_sys_types_h
15 #endif
16 #ifndef INCLUDED_netinet_in_h
17 #include <netinet/in.h>        /* struct in_addr */
18 #define INCLUDED_netinet_in_h
19 #endif
20
21 struct Client;
22 struct SLink;
23 struct TRecord;
24 struct hostent;
25
26
27 /*
28  * General defines
29  */
30
31 /*-----------------------------------------------------------------------------
32  * Macros
33  */
34
35 #define CONF_ILLEGAL            0x80000000
36 #define CONF_MATCH              0x40000000
37 #define CONF_CLIENT             0x0002
38 #define CONF_SERVER             0x0004
39 #define CONF_LOCOP              0x0010
40 #define CONF_OPERATOR           0x0020
41 #define CONF_ME                 0x0040
42 #define CONF_KILL               0x0080
43 #define CONF_ADMIN              0x0100
44 #define CONF_CLASS              0x0400
45 #define CONF_LEAF               0x1000
46 #define CONF_LISTEN_PORT        0x2000
47 #define CONF_HUB                0x4000
48 #define CONF_UWORLD             0x8000
49 #define CONF_CRULEALL           0x00200000
50 #define CONF_CRULEAUTO          0x00400000
51 #define CONF_TLINES             0x00800000
52 #define CONF_IPKILL             0x00010000
53
54 #define CONF_OPS                (CONF_OPERATOR | CONF_LOCOP)
55 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPS | CONF_SERVER)
56 #define CONF_CRULE              (CONF_CRULEALL | CONF_CRULEAUTO)
57 #define CONF_KLINE              (CONF_KILL | CONF_IPKILL)
58
59 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
60
61 /*
62  * Structures
63  */
64
65 struct ConfItem {
66   unsigned int       status;    /* If CONF_ILLEGAL, delete when no clients */
67   unsigned int       clients;   /* Number of *LOCAL* clients using this */
68   struct in_addr     ipnum;     /* ip number of host field */
69   char               bits;      /* Number of bits for ipkills */
70   char*              host;
71   char*              passwd;
72   char*              name;
73   unsigned short int port;
74   time_t             hold;      /* Hold until this time (calendar time) */
75   int                dns_pending; /* a dns request is pending */
76   struct ConfClass*  confClass; /* Class of connection */
77   struct ConfItem*   next;
78 };
79
80 /*
81  * A line: A:<line 1>:<line 2>:<line 3>
82  */
83 struct LocalConf {
84   char* server_alias;
85   char* vhost_address;
86   char* description;
87   char* numeric_id;
88   char* admin_line1;
89   char* admin_line2;
90   char* admin_line3;
91 };
92
93 struct MotdItem {
94   char line[82];
95   struct MotdItem *next;
96 };
97
98 struct TRecord {
99   char *hostmask;
100   struct MotdItem *tmotd;
101   struct tm tmotd_tm;
102   struct TRecord *next;
103 };
104
105 enum AuthorizationCheckResult {
106   ACR_OK,
107   ACR_NO_AUTHORIZATION,
108   ACR_TOO_MANY_IN_CLASS,
109   ACR_TOO_MANY_FROM_IP,
110   ACR_ALREADY_AUTHORIZED,
111   ACR_BAD_SOCKET
112 };
113
114 /*
115  * GLOBALS
116  */
117 extern struct ConfItem* GlobalConfList;
118 extern int              GlobalConfCount;
119 extern struct tm        motd_tm;
120 extern struct MotdItem* motd;
121 extern struct MotdItem* rmotd;
122 extern struct TRecord*  tdata;
123
124 /*
125  * Proto types
126  */
127 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, 
128                                             const char* host, int statmask);
129 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host,
130                                          int statmask);
131 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name,
132                                          int statmask);
133 extern struct ConfItem* conf_find_server(const char* name);
134 const char* conf_eval_crule(struct ConfItem* conf);
135
136 extern void det_confs_butmask(struct Client *cptr, int mask);
137 extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
138 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
139 extern struct ConfItem* find_admin(void);
140 extern struct ConfItem* find_me(void);
141 extern struct ConfItem* find_conf_exact(const char* name, 
142                                         const char* user,
143                                         const char* host, int statmask);
144 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
145 extern int  conf_check_server(struct Client *cptr);
146 extern struct ConfItem* find_conf_name(const char* name, int statmask);
147 extern int rehash(struct Client *cptr, int sig);
148 extern int conf_init(void);
149 extern void read_tlines(void);
150 extern int find_kill(struct Client *cptr);
151 extern int find_restrict(struct Client *cptr);
152 extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
153 extern struct MotdItem* read_motd(const char* motdfile);
154
155 #endif /* INCLUDED_s_conf_h */