*
* $Id$
*/
-#include "s_conf.h"
+#include "config.h"
+#include "s_conf.h"
#include "IPcheck.h"
#include "class.h"
#include "client.h"
#include "s_debug.h"
#include "s_misc.h"
#include "send.h"
-#include "sprintf_irc.h"
#include "struct.h"
#include "support.h"
#include "sys.h"
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
struct ConfItem* GlobalConfList = 0;
int GlobalConfCount = 0;
-static struct LocalConf localConf;
-static struct CRuleConf* cruleConfList;
-static struct ServerConf* serverConfList;
-static struct DenyConf* denyConfList;
+void yyparse(void);
+int conf_fd, lineno;
+
+struct LocalConf localConf;
+struct CRuleConf* cruleConfList;
+/* struct ServerConf* serverConfList; */
+struct DenyConf* denyConfList;
/*
* output the reason for being k lined from a file - Mmmm
* Do (start) DNS lookups of all hostnames in the conf line and convert
* an IP addresses in a.b.c.d number for to IP#s.
*/
-static void lookup_confhost(struct ConfItem *aconf)
+void lookup_confhost(struct ConfItem *aconf)
{
struct DNSReply* reply;
*
* - looks for a match on all given fields.
*/
+#if 0
static struct ConfItem *find_conf_entry(struct ConfItem *aconf,
unsigned int mask)
{
return bconf;
}
-
/*
* If conf line is a class definition, create a class entry
* for it and make the conf_line illegal and delete it.
cruleConfList = p;
}
}
+#endif
void conf_erase_crule_list(void)
{
return cruleConfList;
}
+#if 0
void conf_add_server(const char* const* fields, int count)
{
struct ServerConf* server;
server->next = serverConfList;
serverConfList = server;
- // if (INADDR_NONE == server->address.s_addr)
- // lookup_confhost(server);
+ /* if (INADDR_NONE == server->address.s_addr) */
+ /* lookup_confhost(server); */
}
void conf_add_deny(const char* const* fields, int count, int ip_kill)
else {
conf->bits = bits2;
}
- sprintf_irc(ipname, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]);
+ ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1],
+ ad[2], ad[3]);
/*
* This ensures endian correctness
*/
- conf->s_addr = inet_addr(ipname);
+ conf->address = inet_addr(ipname);
Debug((DEBUG_DEBUG, "IPkill: %s = %08x/%i (%08x)", ipname,
- conf->s_addr, conf->bits, NETMASK(conf->bits)));
+ conf->address, conf->bits, NETMASK(conf->bits)));
conf->flags |= DENY_FLAGS_IP;
}
conf->next = denyConfList;
denyConfList = conf;
}
+#endif
+
void conf_erase_deny_list(void)
{
int read_configuration_file(void)
{
- enum { MAX_FIELDS = 15 };
-
- char* src;
- char* dest;
- int quoted;
- FBFILE *file;
- char line[512];
- int ccount = 0;
- struct ConfItem *aconf = 0;
-
- int field_count = 0;
- const char* field_vector[MAX_FIELDS + 1];
-
- Debug((DEBUG_DEBUG, "read_configuration_file: ircd.conf = %s", configfile));
- if (0 == (file = fbopen(configfile, "r"))) {
- return 0;
- }
-
feature_unmark(); /* unmark all features for resetting later */
-
+ /* Now just open an fd. The buffering isn't really needed... */
+ if ((conf_fd = open(configfile, O_RDONLY)) < 0)
+ return 0;
+ lineno = 1;
+ yyparse();
+ close(conf_fd);
+#if 0
while (fbgets(line, sizeof(line) - 1, file)) {
if ('#' == *line || IsSpace(*line))
continue;
if (aconf)
free_conf(aconf);
fbclose(file);
- nextping = nextconnect = CurrentTime;
+/* nextping = nextconnect = CurrentTime; */
+#endif
feature_mark(); /* reset unmarked features */
return 1;
}
+void
+yyerror(const char *msg)
+{
+ sendto_opmask_butone(0, SNO_ALL, "Config file parse error line %d: %s",
+ lineno, msg);
+ log_write(LS_CONFIG, L_ERROR, 0, "Config file parse error line %d: %s",
+ lineno, msg);
+}
+
/*
* rehash
*
else
tmp = &tmp2->next;
}
+
for (i = 0; i <= HighestFd; i++) {
if ((acptr = LocalClientArray[i])) {
assert(!IsMe(acptr));
}
}
}
+
return ret;
}
break;
if (deny->flags & DENY_FLAGS_REALNAME) { /* K: by real name */
- if (0 == match(deny->hostmask + 2, realname))
+ if (0 == match(deny->hostmask, realname))
break;
} else if (deny->flags & DENY_FLAGS_IP) { /* k: by IP */
Debug((DEBUG_DEBUG, "ip: %08x network: %08x/%i mask: %08x",
- cli_ip(cptr).s_addr, deny->s_addr, deny->bits, NETMASK(deny->bits)));
- if ((cli_ip(cptr).s_addr & NETMASK(deny->bits)) == deny->s_addr)
+ cli_ip(cptr).s_addr, deny->address, deny->bits, NETMASK(deny->bits)));
+ if ((cli_ip(cptr).s_addr & NETMASK(deny->bits)) == deny->address)
break;
}
else if (0 == match(deny->hostmask, host))