Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / chkconf.c
index edb489644db4077ad3a9b786dc763e958c5b50a8..0514704d8288ae291491041c847b4a5ae66f178d 100644 (file)
@@ -18,6 +18,8 @@
  *
  * $Id$
  */
+#include "config.h"
+
 #include "s_conf.h"
 #include "client.h"
 #include "class.h"
 #include <sys/stat.h>
 #include <unistd.h>
 
+/*
+ * stuff that isn't used by s_conf.c anymore
+ */
+#define CONF_ME                 0x0040
+#define CONF_KILL               0x0080
+#define CONF_ADMIN              0x0100
+#define CONF_CLASS              0x0400
+#define CONF_LISTEN_PORT        0x2000
+#define CONF_IPKILL             0x00010000
+#define CONF_CRULEALL           0x00200000
+#define CONF_CRULEAUTO          0x00400000
+#define CONF_TLINES             0x00800000
+
+#define CONF_KLINE              (CONF_KILL | CONF_IPKILL)
+#define CONF_CRULE              (CONF_CRULEALL | CONF_CRULEAUTO)
+
+/* DEFAULTMAXSENDQLENGTH went into the features subsystem... */
+#define DEFAULTMAXSENDQLENGTH 40000
 
 /*
  * For the connect rule patch..  these really should be in a header,
  * but i see h.h isn't included for some reason..  so they're here.
  */
-char *crule_parse(char *rule);
-void crule_free(char **elem);
+struct CRuleNode;
+
+struct CRuleNode* crule_parse(const char* rule);
+void crule_free(struct CRuleNode** elem);
 
 static void new_class(int cn);
 static char confchar(unsigned int status);
 static char *getfield(char *newline);
 static int validate(struct ConfItem *top);
 static struct ConfItem *chk_initconf(void);
-static struct ConfClass *get_class(int cn, int ism);
+static struct ConnectionClass *get_class(int cn, int ism);
 
 static int numclasses = 0, *classarr = (int *)NULL, debugflag = 0;
-static char *chk_configfile = CPATH;
+static char *chk_configfile = "";
 static char nullfield[] = "";
 static char maxsendq[12];
 
@@ -83,7 +105,7 @@ char *rpl_str(int numeric)
 
 int main(int argc, char *argv[])
 {
-  const char *dpath = DPATH;
+  const char *dpath = "./";
   chk_configfile = "ircd.conf";
 
   while (argc > 1)
@@ -122,7 +144,8 @@ int main(int argc, char *argv[])
 
   if (chdir(dpath))
   {
-    fprintf(stderr, "chdir(\"%s\") : %s\n", dpath, strerror(errno));
+    fprintf(stderr, "chdir(\"%s\") : %s\n", dpath, 
+            (strerror(errno)) ? strerror(errno) : "Unknown error");
     exit(-1);
   }
   else if (debugflag > 1)
@@ -144,7 +167,9 @@ int main(int argc, char *argv[])
 static struct ConfItem *chk_initconf(void)
 {
   FBFILE *file;
-  char line[512], *tmp, *crule;
+  char line[512];
+  char *tmp;
+  struct CRuleNode* crule;
   int ccount = 0, flags = 0;
   struct ConfItem *aconf = NULL, *ctop = NULL;
 
@@ -172,7 +197,7 @@ static struct ConfItem *chk_initconf(void)
     aconf->host        = NULL;
     aconf->passwd      = NULL;
     aconf->name        = NULL;
-    aconf->confClass   = NULL;
+    aconf->conn_class   = NULL;
     aconf->dns_pending = 0;
 
     if ((tmp = strchr(line, '\n')))
@@ -324,18 +349,18 @@ static struct ConfItem *chk_initconf(void)
         break;
       if (!(aconf->status & (CONF_CLASS | CONF_ME)))
       {
-        aconf->confClass = get_class(atoi(tmp), 0);
+        aconf->conn_class = get_class(atoi(tmp), 0);
         break;
       }
       if (aconf->status & CONF_ME)
-        aconf->confClass = get_class(atoi(tmp), 1);
+        aconf->conn_class = get_class(atoi(tmp), 1);
       break;
     }
-    if (!aconf->confClass && (aconf->status & (CONF_SERVER |
+    if (!aconf->conn_class && (aconf->status & (CONF_SERVER |
         CONF_ME | CONF_OPS | CONF_CLIENT)))
     {
       fprintf(stderr, "\tWARNING: No class.      Default 0\n");
-      aconf->confClass = get_class(0, 0);
+      aconf->conn_class = get_class(0, 0);
     }
     /*
      * If conf line is a class definition, create a class entry
@@ -357,7 +382,7 @@ static struct ConfItem *chk_initconf(void)
       else
         sprintf(maxsendq, "%d", atoi(tmp));
       new_class(atoi(aconf->host));
-      aconf->confClass = get_class(atoi(aconf->host), 0);
+      aconf->conn_class = get_class(atoi(aconf->host), 0);
       goto print_confline;
     }
 
@@ -368,7 +393,7 @@ static struct ConfItem *chk_initconf(void)
       else if (strchr(aconf->host, '/'))
         fprintf(stderr, "\t%s\n", "WARNING: / present in P-line "
             "for non-UNIXPORT configuration");
-      aconf->confClass = get_class(0, 0);
+      aconf->conn_class = get_class(0, 0);
       goto print_confline;
     }
 
@@ -408,11 +433,11 @@ static struct ConfItem *chk_initconf(void)
      *  any allocated storage immediately -- we're just looking
      *  for errors..  */
     if (aconf->status & CONF_CRULE)
-      if ((crule = (char *)crule_parse(aconf->name)) != NULL)
+      if ((crule = crule_parse(aconf->name)) != NULL)
         crule_free(&crule);
 
-    if (!aconf->confClass)
-      aconf->confClass = get_class(0, 0);
+    if (!aconf->conn_class)
+      aconf->conn_class = get_class(0, 0);
     sprintf(maxsendq, "%d", ConfClass(aconf));
 
     if ((aconf->status & CONF_ADMIN) && (!aconf->name ||
@@ -450,25 +475,25 @@ print_confline:
   return ctop;
 }
 
-static struct ConfClass *get_class(int cn, int ism)
+static struct ConnectionClass *get_class(int cn, int ism)
 {
-  static struct ConfClass cls;
+  static struct ConnectionClass cls;
   if (ism == 1)
   {
-    cls.conClass = (unsigned int)-1;
+    cls.cc_class = (unsigned int)-1;
     if ((cn >= 1) && (cn <= 64))
-      cls.conClass = cn;
+      cls.cc_class = cn;
     else
       fprintf(stderr, "\tWARNING: server numeric %d is not 1-64\n", cn);
   }
   else
   {
     int i = numclasses - 1;
-    cls.conClass = (unsigned int)-1;
+    cls.cc_class = (unsigned int)-1;
     for (; i >= 0; i--)
       if (classarr[i] == cn)
       {
-        cls.conClass = cn;
+        cls.cc_class = cn;
         break;
       }
     if (i == -1)
@@ -534,7 +559,7 @@ static int validate(struct ConfItem *top)
       {
         if (bconf == aconf || !(bconf->status & otype))
           continue;
-        if (bconf->confClass == aconf->confClass &&
+        if (bconf->conn_class == aconf->conn_class &&
             0 == ircd_strcmp(bconf->name, aconf->name) &&
             0 == ircd_strcmp(bconf->host, aconf->host))
         {