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_LEAF               0x1000
44 #define CONF_HUB                0x4000
45 #define CONF_UWORLD             0x8000
46 #define CONF_IPKILL             0x00010000
47
48 #define CONF_OPS                (CONF_OPERATOR | CONF_LOCOP)
49 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPS | CONF_SERVER)
50 #define CONF_KLINE              (CONF_KILL | CONF_IPKILL)
51
52 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
53
54 /*
55  * Structures
56  */
57
58 struct ConfItem {
59   struct ConfItem*   next;
60   unsigned int       status;    /* If CONF_ILLEGAL, delete when no clients */
61   unsigned int       clients;   /* Number of *LOCAL* clients using this */
62   struct in_addr     ipnum;     /* ip number of host field */
63   char               bits;      /* Number of bits for ipkills */
64   char*              host;
65   char*              passwd;
66   char*              name;
67   unsigned short int port;
68   time_t             hold;      /* Hold until this time (calendar time) */
69   int                dns_pending; /* a dns request is pending */
70   struct ConfClass*  confClass; /* Class of connection */
71 };
72
73 struct ServerConf {
74   struct ServerConf* next;
75   char*              hostname;
76   char*              passwd;
77   char*              alias;
78   struct in_addr     address;
79   int                port;
80   int                dns_pending;
81   int                connected;
82   time_t             hold;
83   struct ConfClass*  confClass;
84 };
85
86 /*
87  * A line: A:<line 1>:<line 2>:<line 3>
88  */
89 struct LocalConf {
90   char* server_alias;
91   char* vhost_address;
92   char* description;
93   char* numeric_id;
94   char* location1;
95   char* location2;
96   char* contact;
97 };
98
99 struct MotdItem {
100   char line[82];
101   struct MotdItem *next;
102 };
103
104 struct MotdConf {
105   struct MotdConf* next;
106   char* hostmask;
107   char* path;
108 };
109
110 enum {
111   CRULE_AUTO = 1,
112   CRULE_ALL  = 2,
113   CRULE_MASK = 3
114 };
115
116 struct CRuleNode;
117
118 struct CRuleConf {
119   struct CRuleConf* next;
120   char*             hostmask;
121   char*             rule;
122   int               type;
123   struct CRuleNode* node;
124 };
125
126 struct TRecord {
127   struct TRecord *next;
128   char *hostmask;
129   struct MotdItem *tmotd;
130   struct tm tmotd_tm;
131 };
132
133 enum AuthorizationCheckResult {
134   ACR_OK,
135   ACR_NO_AUTHORIZATION,
136   ACR_TOO_MANY_IN_CLASS,
137   ACR_TOO_MANY_FROM_IP,
138   ACR_ALREADY_AUTHORIZED,
139   ACR_BAD_SOCKET
140 };
141
142 /*
143  * GLOBALS
144  */
145 extern struct ConfItem* GlobalConfList;
146 extern int              GlobalConfCount;
147 extern struct tm        motd_tm;
148 extern struct MotdItem* motd;
149 extern struct MotdItem* rmotd;
150 extern struct TRecord*  tdata;
151
152 /*
153  * Proto types
154  */
155
156 extern const struct LocalConf* conf_get_local(void);
157 extern const struct MotdConf*  conf_get_motd_list(void);
158 extern const struct CRuleConf* conf_get_crule_list(void);
159
160 extern const char* conf_crule_eval(const char* host, int mask);
161
162 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
163 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
164 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
165 extern struct ConfItem* conf_find_server(const char* name);
166 const char* conf_eval_crule(const char* name, int mask);
167
168 extern void det_confs_butmask(struct Client *cptr, int mask);
169 extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
170 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
171 extern struct ConfItem* find_me(void);
172 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
173                                         const char* host, int statmask);
174 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
175 extern int  conf_check_server(struct Client *cptr);
176 extern struct ConfItem* find_conf_name(const char* name, int statmask);
177 extern int rehash(struct Client *cptr, int sig);
178 extern int init_conf(void);
179 extern void read_tlines(void);
180 extern int find_kill(struct Client *cptr);
181 extern int find_restrict(struct Client *cptr);
182 extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
183 extern struct MotdItem* read_motd(const char* motdfile);
184
185 #endif /* INCLUDED_s_conf_h */