diff options
-rw-r--r-- | include/inspircd_io.h | 14 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 121 | ||||
-rwxr-xr-x | src/svn-rev.sh | 2 |
3 files changed, 129 insertions, 8 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h index e98bb3d66..ac0587177 100644 --- a/include/inspircd_io.h +++ b/include/inspircd_io.h @@ -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. diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index 4fa87a5f1..62d7fc955 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -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); diff --git a/src/svn-rev.sh b/src/svn-rev.sh index 5f044e139..5e7dbd4a6 100755 --- a/src/svn-rev.sh +++ b/src/svn-rev.sh @@ -1 +1 @@ -echo 3629 +echo 3631 |