2004-05-09 Michael Poole <mdpoole@troilus.org>
[ircu2.10.12-pk.git] / include / s_conf.h
index b969f4df3b37a3f6203b9b49a1eab9ba6bcf32ab..ff9a007a4a522db2b1570abd4cddef62fb19dbc7 100644 (file)
 #include <netinet/in.h>        /* struct in_addr */
 #define INCLUDED_netinet_in_h
 #endif
+#include "client.h"
 
 struct Client;
 struct SLink;
 struct TRecord;
-struct hostent;
+struct Message;
 
 
 /*
@@ -38,23 +39,12 @@ struct hostent;
 #define CONF_SERVER             0x0004
 #define CONF_LOCOP              0x0010
 #define CONF_OPERATOR           0x0020
-#define CONF_ME                 0x0040
-#define CONF_KILL               0x0080
-#define CONF_ADMIN              0x0100
-#define CONF_CLASS              0x0400
 #define CONF_LEAF               0x1000
-#define CONF_LISTEN_PORT        0x2000
 #define CONF_HUB                0x4000
 #define CONF_UWORLD             0x8000
-#define CONF_CRULEALL           0x00200000
-#define CONF_CRULEAUTO          0x00400000
-#define CONF_TLINES             0x00800000
-#define CONF_IPKILL             0x00010000
 
 #define CONF_OPS                (CONF_OPERATOR | CONF_LOCOP)
 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPS | CONF_SERVER)
-#define CONF_CRULE              (CONF_CRULEALL | CONF_CRULEAUTO)
-#define CONF_KLINE              (CONF_KILL | CONF_IPKILL)
 
 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
 
@@ -62,32 +52,70 @@ struct hostent;
  * Structures
  */
 
-struct ConfItem {
-  unsigned int       status;    /* If CONF_ILLEGAL, delete when no clients */
-  unsigned int       clients;   /* Number of *LOCAL* clients using this */
-  struct in_addr     ipnum;     /* ip number of host field */
-  char                      bits;      /* Number of bits for ipkills */
-  char*              host;
+struct ConfItem
+{
+  struct ConfItem *next;
+  unsigned int status;      /* If CONF_ILLEGAL, delete when no clients */
+  unsigned int clients;     /* Number of *LOCAL* clients using this */
+  struct ConnectionClass *conn_class;  /* Class of connection */
+  struct in_addr ipnum;       /* ip number of host field */
+  char *host;
+  char *passwd;
+  char *name;
+  time_t hold; /* Hold until this time (calendar time) */
+  int dns_pending; /* a dns request is pending */
+  unsigned short port;
+  unsigned char bits; /* Number of bits for ipkills. */
+  struct Privs privs; /* Priviledges for opers. */
+  /* Used to detect if a privilege has been touched. */
+  struct Privs privs_dirty;
+};
+
+struct ServerConf {
+  struct ServerConf* next;
+  char*              hostname;
   char*              passwd;
-  char*              name;
-  unsigned short int port;
-  time_t             hold;      /* Hold until this time (calendar time) */
-  int                dns_pending; /* a dns request is pending */
-  struct ConfClass*  confClass; /* Class of connection */
-  struct ConfItem*   next;
+  char*              alias;
+  struct in_addr     address;
+  int                port;
+  int                dns_pending;
+  int                connected;
+  time_t             hold;
+  struct ConnectionClass*  conn_class;
+};
+
+struct qline
+{
+  struct qline *next;
+  char *chname;
+  char *reason;
 };
 
+struct DenyConf {
+  struct DenyConf*    next;
+  char*               hostmask;
+  char*               message;
+  char*               usermask;
+  unsigned int        address;
+  unsigned int        flags;
+  char                bits;        /* Number of bits for ipkills */
+};
+
+#define DENY_FLAGS_FILE     0x0001 /* Comment is a filename */
+#define DENY_FLAGS_IP       0x0002 /* K-line by IP address */
+#define DENY_FLAGS_REALNAME 0x0004 /* K-line by real name */
+
 /*
  * A line: A:<line 1>:<line 2>:<line 3>
  */
 struct LocalConf {
-  char* server_alias;
-  char* vhost_address;
-  char* description;
-  char* numeric_id;
-  char* location1;
-  char* location2;
-  char* contact;
+  char*          name;
+  char*          description;
+  struct in_addr vhost_address;
+  unsigned int   numeric;
+  char*          location1;
+  char*          location2;
+  char*          contact;
 };
 
 struct MotdItem {
@@ -96,16 +124,32 @@ struct MotdItem {
 };
 
 struct MotdConf {
+  struct MotdConf* next;
   char* hostmask;
   char* path;
-  struct MotdConf* next;
 };
-  
+
+enum {
+  CRULE_AUTO = 1,
+  CRULE_ALL  = 2,
+  CRULE_MASK = 3
+};
+
+struct CRuleNode;
+
+struct CRuleConf {
+  struct CRuleConf* next;
+  char*             hostmask;
+  char*             rule;
+  int               type;
+  struct CRuleNode* node;
+};
+
 struct TRecord {
+  struct TRecord *next;
   char *hostmask;
   struct MotdItem *tmotd;
   struct tm tmotd_tm;
-  struct TRecord *next;
 };
 
 enum AuthorizationCheckResult {
@@ -117,6 +161,22 @@ enum AuthorizationCheckResult {
   ACR_BAD_SOCKET
 };
 
+struct nick_host {
+  struct nick_host *next;
+  int nicklen; /* offset of @ part of server string */
+  char nick[1]; /* start of nick@server string */
+};
+
+struct s_map {
+  struct s_map *next;
+  struct Message *msg;
+  char *name;
+  char *command;
+  char *prepend;
+  struct nick_host *services;
+};
+
+
 /*
  * GLOBALS
  */
@@ -126,39 +186,42 @@ extern struct tm        motd_tm;
 extern struct MotdItem* motd;
 extern struct MotdItem* rmotd;
 extern struct TRecord*  tdata;
+extern struct s_map*    GlobalServiceMapList;
+extern struct qline*    GlobalQuarantineList;
 
 /*
  * Proto types
  */
 
+extern int init_conf(void);
+
 extern const struct LocalConf* conf_get_local(void);
-extern const struct MotdConf* conf_get_motd_list(void);
-
-extern struct ConfItem* attach_confs_byhost(struct Client* cptr, 
-                                            const char* host, int statmask);
-extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host,
-                                         int statmask);
-extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name,
-                                         int statmask);
+extern const struct MotdConf*  conf_get_motd_list(void);
+extern const struct CRuleConf* conf_get_crule_list(void);
+extern const struct DenyConf*  conf_get_deny_list(void);
+
+extern const char* conf_eval_crule(const char* name, int mask);
+
+extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
+extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
+extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
 extern struct ConfItem* conf_find_server(const char* name);
-const char* conf_eval_crule(struct ConfItem* conf);
 
 extern void det_confs_butmask(struct Client *cptr, int mask);
-extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
-extern struct ConfItem* find_me(void);
-extern struct ConfItem* find_conf_exact(const char* name, 
-                                        const char* user,
+extern struct ConfItem* find_conf_exact(const char* name, const char* user,
                                         const char* host, int statmask);
 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
 extern int  conf_check_server(struct Client *cptr);
 extern struct ConfItem* find_conf_name(const char* name, int statmask);
 extern int rehash(struct Client *cptr, int sig);
-extern int conf_init(void);
 extern void read_tlines(void);
 extern int find_kill(struct Client *cptr);
 extern int find_restrict(struct Client *cptr);
-extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
 extern struct MotdItem* read_motd(const char* motdfile);
+extern const char *find_quarantine(const char* chname);
+extern void lookup_confhost(struct ConfItem *aconf);
+
+extern void yyerror(const char *msg);
 
 #endif /* INCLUDED_s_conf_h */