6d3f7f124fe86468bef9c40c7602e65c8dc67fca
[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*              host;
70   char*              passwd;
71   char*              name;
72   unsigned short int port;
73   time_t             hold;      /* Hold until this time (calendar time) */
74   int                dns_pending; /* a dns request is pending */
75   struct ConfClass*  confClass; /* Class of connection */
76   struct ConfItem*   next;
77 };
78
79 struct MotdItem {
80   char line[82];
81   struct MotdItem *next;
82 };
83
84 struct TRecord {
85   char *hostmask;
86   struct MotdItem *tmotd;
87   struct tm tmotd_tm;
88   struct TRecord *next;
89 };
90
91 enum AuthorizationCheckResult {
92   ACR_OK,
93   ACR_NO_AUTHORIZATION,
94   ACR_TOO_MANY_IN_CLASS,
95   ACR_TOO_MANY_FROM_IP,
96   ACR_ALREADY_AUTHORIZED,
97   ACR_BAD_SOCKET
98 };
99
100 /*
101  * GLOBALS
102  */
103 extern struct ConfItem* GlobalConfList;
104 extern int              GlobalConfCount;
105 extern struct tm        motd_tm;
106 extern struct MotdItem* motd;
107 extern struct MotdItem* rmotd;
108 extern struct TRecord*  tdata;
109
110 /*
111  * Proto types
112  */
113 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, 
114                                             const char* host, int statmask);
115 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host,
116                                          int statmask);
117 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name,
118                                          int statmask);
119 extern struct ConfItem* conf_find_server(const char* name);
120 const char* conf_eval_crule(struct ConfItem* conf);
121
122 extern void det_confs_butmask(struct Client *cptr, int mask);
123 extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
124 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
125 extern struct ConfItem* find_admin(void);
126 extern struct ConfItem* find_me(void);
127 extern struct ConfItem* find_conf_exact(const char* name, 
128                                         const char* user,
129                                         const char* host, int statmask);
130 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
131 extern int  conf_check_server(struct Client *cptr);
132 extern struct ConfItem* find_conf_name(const char* name, int statmask);
133 extern int rehash(struct Client *cptr, int sig);
134 extern int conf_init(void);
135 extern void read_tlines(void);
136 extern int find_kill(struct Client *cptr);
137 extern int find_restrict(struct Client *cptr);
138 extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
139 extern struct MotdItem* read_motd(const char* motdfile);
140
141 #endif /* INCLUDED_s_conf_h */