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* location1;
89   char* location2;
90   char* contact;
91 };
92
93 struct MotdItem {
94   char line[82];
95   struct MotdItem *next;
96 };
97
98 struct MotdConf {
99   char* hostmask;
100   char* path;
101   struct MotdConf* next;
102 };
103   
104 struct TRecord {
105   char *hostmask;
106   struct MotdItem *tmotd;
107   struct tm tmotd_tm;
108   struct TRecord *next;
109 };
110
111 enum AuthorizationCheckResult {
112   ACR_OK,
113   ACR_NO_AUTHORIZATION,
114   ACR_TOO_MANY_IN_CLASS,
115   ACR_TOO_MANY_FROM_IP,
116   ACR_ALREADY_AUTHORIZED,
117   ACR_BAD_SOCKET
118 };
119
120 /*
121  * GLOBALS
122  */
123 extern struct ConfItem* GlobalConfList;
124 extern int              GlobalConfCount;
125 extern struct tm        motd_tm;
126 extern struct MotdItem* motd;
127 extern struct MotdItem* rmotd;
128 extern struct TRecord*  tdata;
129
130 /*
131  * Proto types
132  */
133
134 extern const struct LocalConf* conf_get_local(void);
135 extern const struct MotdConf* conf_get_motd_list(void);
136
137 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, 
138                                             const char* host, int statmask);
139 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host,
140                                          int statmask);
141 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name,
142                                          int statmask);
143 extern struct ConfItem* conf_find_server(const char* name);
144 const char* conf_eval_crule(struct ConfItem* conf);
145
146 extern void det_confs_butmask(struct Client *cptr, int mask);
147 extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
148 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
149 extern struct ConfItem* find_me(void);
150 extern struct ConfItem* find_conf_exact(const char* name, 
151                                         const char* user,
152                                         const char* host, int statmask);
153 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
154 extern int  conf_check_server(struct Client *cptr);
155 extern struct ConfItem* find_conf_name(const char* name, int statmask);
156 extern int rehash(struct Client *cptr, int sig);
157 extern int conf_init(void);
158 extern void read_tlines(void);
159 extern int find_kill(struct Client *cptr);
160 extern int find_restrict(struct Client *cptr);
161 extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
162 extern struct MotdItem* read_motd(const char* motdfile);
163
164 #endif /* INCLUDED_s_conf_h */