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