]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Test stuff for improved multi-tags in core
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 10 Mar 2006 16:22:09 +0000 (16:22 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 10 Mar 2006 16:22:09 +0000 (16:22 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3632 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd_io.h
src/inspircd_io.cpp
src/svn-rev.sh

index e98bb3d660f0cf1fcfb99729e2efbccc2c82bf46..ac05871773ffd6f72bd4a2ea433bb01aa9ed638b 100644 (file)
@@ -33,7 +33,8 @@
 #define NONE 50
 
 typedef bool (*Validator)(const char*, const char*, void*);
-typedef bool (*MultiValidator)(const char*, const char**, void**, int**);
+typedef bool (*MultiValidator)(const char*, char**, void**, int*);
+typedef bool (*MultiNotify)(const char*);
 
 enum ConfigDataType { DT_NOTHING, DT_INTEGER, DT_CHARPTR, DT_BOOLEAN };
 
@@ -46,11 +47,12 @@ struct InitialConfig {
 };
 
 struct MultiConfig {
-       char* tag;
-       char** items;
-       void** values;
-       ConfigDataType** datatype;
-       MultiValidator validation_function;
+       const char* tag;
+       char* items[12];
+       int datatype[12];
+       MultiNotify     init_function;
+       MultiValidator  validation_function;
+       MultiNotify     finish_function;
 };
 
 /** This class holds the bulk of the runtime configuration for the ircd.
index 4fa87a5f18392776cd7920cc8488b2b46ab2a712..62d7fc95565a69ffbb0878bfbf3010b8c1942352 100644 (file)
@@ -316,6 +316,54 @@ bool ValidateRules(const char* tag, const char* value, void* data)
        return true;
 }
 
+bool InitConnect(const char* tag)
+{
+       log(DEBUG,"InitConnect called for tag: %s",tag);
+       return true;
+}
+
+bool DoConnect(const char* tag, char** entries, void** values, int* types)
+{
+       log(DEBUG,"DoConnect called for tag: %s",tag);
+       return true;
+}
+
+bool DoneConnect(const char* tag)
+{
+       log(DEBUG,"DoneConnect called for tag: %s",tag);
+       return true;
+}
+
+bool InitULine(const char* tag)
+{
+       return true;
+}
+
+bool DoULine(const char* tag, char** entries, void** values, int* types)
+{
+       return true;
+}
+
+bool DoneULine(const char* tag)
+{
+       return true;
+}
+
+bool InitModule(const char* tag)
+{
+       return true;
+}
+
+bool DoModule(const char* tag, char** entries, void** values, int* types)
+{
+       return true;
+}
+
+bool DoneModule(const char* tag)
+{
+       return true;
+}
+
 
 void ServerConfig::Read(bool bail, userrec* user)
 {
@@ -356,6 +404,29 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"options",     "hidebans",             &this->HideBans,                DT_BOOLEAN, NoValidation},
                {"options",     "hidewhois",            &this->HideWhoisServer,         DT_CHARPTR, NoValidation},
                {"options",     "tempdir",              &this->TempDir,                 DT_CHARPTR, ValidateTempDir},
+               {"pid",         "file",                 &this->PID,                     DT_CHARPTR, NoValidation},
+               {NULL}
+       };
+
+       static MultiConfig MultiValues[] = {
+
+               {"connect",
+                               {"allow",       "deny",         "password",     "timeout",      "pingfreq"      "flood",
+                               "threshold"     "sendq"         "recvq"         "localmax"      "globalmax",    NULL},
+                               {DT_CHARPTR,    DT_CHARPTR,     DT_CHARPTR,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER,
+                                DT_INTEGER,    DT_INTEGER,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER},
+                               InitConnect,DoConnect,DoneConnect},
+
+               {"uline",
+                               {"server",      NULL},
+                               {DT_CHARPTR},
+                               InitULine,DoULine,DoneULine},
+
+               {"module",
+                               {"name",        NULL},
+                               {DT_CHARPTR},
+                               InitModule,DoModule,DoneModule},
+
                {NULL}
        };
        
@@ -437,6 +508,55 @@ void ServerConfig::Read(bool bail, userrec* user)
                Values[Index].validation_function(Values[Index].tag, Values[Index].value, Values[Index].val);
        }
 
+       char* data[12];
+       void* ptr[12];
+       int r_i[12];
+       int* ptr_i[12];
+
+       for (int n = 0; n < 12; n++)
+       {
+               data[n] = new char[MAXBUF];
+               ptr_i[n] = &r_i[n];
+       }
+
+       for (int Index = 0; MultiValues[Index].tag; Index++)
+       {
+               MultiValues[Index].init_function(MultiValues[Index].tag);
+
+               int number_of_tags = ConfValueEnum((char*)MultiValues[Index].tag, &this->config_f);
+
+               for (int tagnum = 0; tagnum < number_of_tags; tagnum++)
+               {
+                       for (int valuenum = 0; MultiValues[Index].items[valuenum]; valuenum++)
+                       {
+                               ConfValue((char*)MultiValues[Index].tag,(char*)MultiValues[Index].items[valuenum], valuenum, data[valuenum], &this->config_f);
+
+                               switch (MultiValues[Index].datatype[valuenum])
+                               {
+                                       case DT_CHARPTR:
+                                               ptr[valuenum] = data[valuenum];
+                                       break;
+                                       case DT_INTEGER:
+                                               *ptr_i[valuenum] = atoi(data[valuenum]);
+                                               ptr[valuenum] = ptr_i[valuenum];
+                                       break;
+                                       case DT_BOOLEAN:
+                                               *ptr_i[valuenum] = ((*data[valuenum] == tolower('y')) || (*data[valuenum] == tolower('t')) || (*data[valuenum] == '1'));
+                                               ptr[valuenum] = ptr_i[valuenum];
+                                       break;
+                                       default:
+                                       break;
+                               }
+                               MultiValues[Index].validation_function(MultiValues[Index].tag, (char**)MultiValues[Index].items, ptr, MultiValues[Index].datatype);
+                       }
+               }
+
+               MultiValues[Index].finish_function(MultiValues[Index].tag);
+       }
+
+       for (int n = 0; n < 12; n++)
+               delete[] data[n];
+
        log(DEFAULT,"Reading connect classes...");
        Classes.clear();
 
@@ -533,7 +653,6 @@ void ServerConfig::Read(bool bail, userrec* user)
        log(DEFAULT,"Applying K lines, Q lines and Z lines...");
        apply_lines(APPLY_ALL);
 
-       ConfValue("pid","file",0,Config->PID,&Config->config_f);
        // write once here, to try it out and make sure its ok
        WritePID(Config->PID);
 
index 5f044e139c837f6407e6b0138b00ce261f16fd47..5e7dbd4a6c9353c81d7429be3dc7ef1fc6f6cef0 100755 (executable)
@@ -1 +1 @@
-echo 3629
+echo 3631