return true;
}
-bool NoValidation(const char* tag, const char* value, void* data)
+bool NoValidation(ServerConfig* conf, const char* tag, const char* value, void* data)
{
log(DEBUG,"No validation for <%s:%s>",tag,value);
return true;
}
-bool ValidateTempDir(const char* tag, const char* value, void* data)
+bool ValidateTempDir(ServerConfig* conf, const char* tag, const char* value, void* data)
{
char* x = (char*)data;
if (!*x)
return true;
}
-bool ValidateMaxTargets(const char* tag, const char* value, void* data)
+bool ValidateMaxTargets(ServerConfig* conf, const char* tag, const char* value, void* data)
{
int* x = (int*)data;
if ((*x < 0) || (*x > 31))
return true;
}
-bool ValidateSoftLimit(const char* tag, const char* value, void* data)
+bool ValidateSoftLimit(ServerConfig* conf, const char* tag, const char* value, void* data)
{
int* x = (int*)data;
if ((*x < 1) || (*x > MAXCLIENTS))
return true;
}
-bool ValidateMaxConn(const char* tag, const char* value, void* data)
+bool ValidateMaxConn(ServerConfig* conf, const char* tag, const char* value, void* data)
{
int* x = (int*)data;
if (*x > SOMAXCONN)
return true;
}
-bool ValidateDnsTimeout(const char* tag, const char* value, void* data)
+bool ValidateDnsTimeout(ServerConfig* conf, const char* tag, const char* value, void* data)
{
int* x = (int*)data;
if (!*x)
return true;
}
-bool ValidateDnsServer(const char* tag, const char* value, void* data)
+bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, void* data)
{
char* x = (char*)data;
if (!*x)
return true;
}
-bool ValidateModPath(const char* tag, const char* value, void* data)
+bool ValidateModPath(ServerConfig* conf, const char* tag, const char* value, void* data)
{
char* x = (char*)data;
if (!*x)
}
-bool ValidateServerName(const char* tag, const char* value, void* data)
+bool ValidateServerName(ServerConfig* conf, const char* tag, const char* value, void* data)
{
char* x = (char*)data;
if (!strchr(x,'.'))
return true;
}
-bool ValidateNetBufferSize(const char* tag, const char* value, void* data)
+bool ValidateNetBufferSize(ServerConfig* conf, const char* tag, const char* value, void* data)
{
if ((!ServerInstance->Config->NetBufferSize) || (ServerInstance->Config->NetBufferSize > 65535) || (ServerInstance->Config->NetBufferSize < 1024))
{
return true;
}
-bool ValidateMaxWho(const char* tag, const char* value, void* data)
+bool ValidateMaxWho(ServerConfig* conf, const char* tag, const char* value, void* data)
{
if ((!ServerInstance->Config->MaxWhoResults) || (ServerInstance->Config->MaxWhoResults > 65535) || (ServerInstance->Config->MaxWhoResults < 1))
{
return true;
}
-bool ValidateLogLevel(const char* tag, const char* value, void* data)
+bool ValidateLogLevel(ServerConfig* conf, const char* tag, const char* value, void* data)
{
const char* dbg = (const char*)data;
ServerInstance->Config->LogLevel = DEFAULT;
return true;
}
-bool ValidateMotd(const char* tag, const char* value, void* data)
+bool ValidateMotd(ServerConfig* conf, const char* tag, const char* value, void* data)
{
- readfile(ServerInstance->Config->MOTD,ServerInstance->Config->motd);
+ conf->ReadFile(ServerInstance->Config->MOTD,ServerInstance->Config->motd);
return true;
}
-bool ValidateRules(const char* tag, const char* value, void* data)
+bool ValidateRules(ServerConfig* conf, const char* tag, const char* value, void* data)
{
- readfile(ServerInstance->Config->RULES,ServerInstance->Config->rules);
+ conf->ReadFile(ServerInstance->Config->RULES,ServerInstance->Config->rules);
return true;
}
/* Callback called before processing the first <connect> tag
*/
-bool InitConnect(const char* tag)
+bool InitConnect(ServerConfig* conf, const char* tag)
{
log(DEFAULT,"Reading connect classes...");
ServerInstance->Config->Classes.clear();
/* Callback called to process a single <connect> tag
*/
-bool DoConnect(const char* tag, char** entries, void** values, int* types)
+bool DoConnect(ServerConfig* conf, const char* tag, char** entries, void** values, int* types)
{
ConnectClass c;
char* allow = (char*)values[0]; /* Yeah, there are a lot of values. Live with it. */
/* Callback called when there are no more <connect> tags
*/
-bool DoneConnect(const char* tag)
+bool DoneConnect(ServerConfig* conf, const char* tag)
{
log(DEBUG,"DoneConnect called for tag: %s",tag);
return true;
/* Callback called before processing the first <uline> tag
*/
-bool InitULine(const char* tag)
+bool InitULine(ServerConfig* conf, const char* tag)
{
ServerInstance->Config->ulines.clear();
return true;
/* Callback called to process a single <uline> tag
*/
-bool DoULine(const char* tag, char** entries, void** values, int* types)
+bool DoULine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types)
{
char* server = (char*)values[0];
log(DEBUG,"Read ULINE '%s'",server);
/* Callback called when there are no more <uline> tags
*/
-bool DoneULine(const char* tag)
+bool DoneULine(ServerConfig* conf, const char* tag)
{
return true;
}
/* Callback called before processing the first <module> tag
*/
-bool InitModule(const char* tag)
+bool InitModule(ServerConfig* conf, const char* tag)
{
old_module_names.clear();
new_module_names.clear();
/* Callback called to process a single <module> tag
*/
-bool DoModule(const char* tag, char** entries, void** values, int* types)
+bool DoModule(ServerConfig* conf, const char* tag, char** entries, void** values, int* types)
{
char* modname = (char*)values[0];
new_module_names.push_back(modname);
/* Callback called when there are no more <module> tags
*/
-bool DoneModule(const char* tag)
+bool DoneModule(ServerConfig* conf, const char* tag)
{
// now create a list of new modules that are due to be loaded
// and a seperate list of modules which are due to be unloaded
/* Callback called before processing the first <banlist> tag
*/
-bool InitMaxBans(const char* tag)
+bool InitMaxBans(ServerConfig* conf, const char* tag)
{
ServerInstance->Config->maxbans.clear();
return true;
/* Callback called to process a single <banlist> tag
*/
-bool DoMaxBans(const char* tag, char** entries, void** values, int* types)
+bool DoMaxBans(ServerConfig* conf, const char* tag, char** entries, void** values, int* types)
{
char* channel = (char*)values[0];
int* limit = (int*)values[1];
/* Callback called when there are no more <banlist> tags.
*/
-bool DoneMaxBans(const char* tag)
+bool DoneMaxBans(ServerConfig* conf, const char* tag)
{
return true;
}
break;
}
- Values[Index].validation_function(Values[Index].tag, Values[Index].value, Values[Index].val);
+ Values[Index].validation_function(this, Values[Index].tag, Values[Index].value, Values[Index].val);
}
/* Claim memory for use when reading multiple tags
/* XXX - Make this use ConfValueInteger and so on */
for (int Index = 0; MultiValues[Index].tag; Index++)
{
- MultiValues[Index].init_function(MultiValues[Index].tag);
+ MultiValues[Index].init_function(this, MultiValues[Index].tag);
int number_of_tags = ConfValueEnum(this->config_data, MultiValues[Index].tag);
break;
}
}
- MultiValues[Index].validation_function(MultiValues[Index].tag, (char**)MultiValues[Index].items, ptr, MultiValues[Index].datatype);
+ MultiValues[Index].validation_function(this, MultiValues[Index].tag, (char**)MultiValues[Index].items, ptr, MultiValues[Index].datatype);
}
- MultiValues[Index].finish_function(MultiValues[Index].tag);
+ MultiValues[Index].finish_function(this, MultiValues[Index].tag);
}
/* Free any memory we claimed
return 0;
}
+
+/** Read the contents of a file located by `fname' into a file_cache pointed at by `F'.
+ */
+bool ServerConfig::ReadFile(file_cache &F, const char* fname)
+{
+ FILE* file;
+ char linebuf[MAXBUF];
+
+ F.clear();
+ file = fopen(fname,"r");
+
+ if (file)
+ {
+ while (!feof(file))
+ {
+ fgets(linebuf,sizeof(linebuf),file);
+ linebuf[strlen(linebuf)-1]='\0';
+
+ if (!*linebuf)
+ {
+ strcpy(linebuf," ");
+ }
+
+ if (!feof(file))
+ {
+ F.push_back(linebuf);
+ }
+ }
+
+ fclose(file);
+ }
+ else
+ return false;
+
+ return true;
+}
+