Author: Bleep <helveytw@home.com>
[ircu2.10.12-pk.git] / ircd / chkconf.c
index 7d0fdb0a89b7eccbbdcc45f449ab442075578c95..00608cbf3c080ad56cd3640a6ca681734c792fe4 100644 (file)
 #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)
+
 
 /*
  * 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;
@@ -122,7 +140,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 +163,9 @@ int main(int argc, char *argv[])
 static struct ConfItem *chk_initconf(void)
 {
   FBFILE *file;
-  char line[512], *tmp, *s, *crule;
+  char line[512];
+  char *tmp;
+  struct CRuleNode* crule;
   int ccount = 0, flags = 0;
   struct ConfItem *aconf = NULL, *ctop = NULL;
 
@@ -180,34 +201,29 @@ static struct ConfItem *chk_initconf(void)
     /*
      * Do quoting of characters and # detection.
      */
-    for (tmp = line; *tmp; tmp++)
-    {
-      if (*tmp == '\\')
-      {
-        switch (*(tmp + 1))
-        {
-          case 'n':
-            *tmp = '\n';
-            break;
-          case 'r':
-            *tmp = '\r';
-            break;
-          case 't':
-            *tmp = '\t';
-            break;
-          case '0':
-            *tmp = '\0';
-            break;
-          default:
-            *tmp = *(tmp + 1);
-            break;
+    for (tmp = line; *tmp; ++tmp) {
+      if (*tmp == '\\') {
+        switch (*(tmp + 1)) {
+        case 'n':
+          *tmp = '\n';
+          break;
+        case 'r':
+          *tmp = '\r';
+          break;
+        case 't':
+          *tmp = '\t';
+          break;
+        case '0':
+          *tmp = '\0';
+          break;
+        default:
+          *tmp = *(tmp + 1);
+          break;
         }
-        if (!*(tmp + 1))
+        if ('\0' == *(tmp + 1))
           break;
         else
-          for (s = tmp; (*s = *++s);)
-            ;
-        tmp++;
+          strcpy(tmp + 1, tmp + 2);
       }
       else if (*tmp == '#')
         *tmp = '\0';
@@ -413,7 +429,7 @@ 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)
@@ -455,9 +471,9 @@ 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;