*CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0';
*OperOnlyStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0';
log_file = NULL;
- OperSpyWhois = nofork = HideBans = HideSplits = false;
- AllowHalfop = true;
+ forcedebug = OperSpyWhois = nofork = HideBans = HideSplits = false;
+ writelog = AllowHalfop = true;
dns_timeout = DieDelay = 5;
MaxTargets = 20;
NetBufferSize = 10240;
return true;
}
-bool ValidateNetworkName(const char* tag, const char* value, void* data)
-{
- char* x = (char*)data;
-
- log(DEFAULT,"<server:network> '%s'",x);
-
- return true;
-}
-
-bool ValidateServerDesc(const char* tag, const char* value, void* data)
-{
- char* x = (char*)data;
-
- log(DEFAULT,"<server:description> '%s'",x);
-
- return true;
-}
-
bool ValidateNetBufferSize(const char* tag, const char* value, void* data)
{
if ((!Config->NetBufferSize) || (Config->NetBufferSize > 65535) || (Config->NetBufferSize < 1024))
/* These tags can occur ONCE or not at all */
static InitialConfig Values[] = {
- {"options", "softlimit", &this->SoftLimit, DT_INTEGER, ValidateSoftLimit},
- {"options", "somaxconn", &this->MaxConn, DT_INTEGER, ValidateMaxConn},
+ {"options", "softlimit", &this->SoftLimit, DT_INTEGER, ValidateSoftLimit},
+ {"options", "somaxconn", &this->MaxConn, DT_INTEGER, ValidateMaxConn},
{"server", "name", &this->ServerName, DT_CHARPTR, ValidateServerName},
- {"server", "description", &this->ServerDesc, DT_CHARPTR, ValidateServerDesc},
- {"server", "network", &this->Network, DT_CHARPTR, ValidateNetworkName},
+ {"server", "description", &this->ServerDesc, DT_CHARPTR, NoValidation},
+ {"server", "network", &this->Network, DT_CHARPTR, NoValidation},
{"admin", "name", &this->AdminName, DT_CHARPTR, NoValidation},
{"admin", "email", &this->AdminEmail, DT_CHARPTR, NoValidation},
{"admin", "nick", &this->AdminNick, DT_CHARPTR, NoValidation},
{"files", "rules", &this->rules, DT_CHARPTR, ValidateRules},
{"power", "diepass", &this->diepass, DT_CHARPTR, NoValidation},
{"power", "pauseval", &this->DieDelay, DT_INTEGER, NoValidation},
- {"power", "restartpass", &this->restartpass, DT_CHARPTR, NoValidation},
- {"options", "prefixquit", &this->PrefixQuit, DT_CHARPTR, NoValidation},
+ {"power", "restartpass", &this->restartpass, DT_CHARPTR, NoValidation},
+ {"options", "prefixquit", &this->PrefixQuit, DT_CHARPTR, NoValidation},
{"die", "value", &this->DieValue, DT_CHARPTR, NoValidation},
- {"options", "loglevel", &debug, DT_CHARPTR, ValidateLogLevel},
- {"options", "netbuffersize", &this->NetBufferSize, DT_INTEGER, ValidateNetBufferSize},
- {"options", "maxwho", &this->MaxWhoResults, DT_INTEGER, ValidateMaxWho},
- {"options", "allowhalfop", &this->AllowHalfop, DT_BOOLEAN, NoValidation},
+ {"options", "loglevel", &debug, DT_CHARPTR, ValidateLogLevel},
+ {"options", "netbuffersize", &this->NetBufferSize, DT_INTEGER, ValidateNetBufferSize},
+ {"options", "maxwho", &this->MaxWhoResults, DT_INTEGER, ValidateMaxWho},
+ {"options", "allowhalfop", &this->AllowHalfop, DT_BOOLEAN, NoValidation},
{"dns", "server", &this->DNSServer, DT_CHARPTR, ValidateDnsServer},
{"dns", "timeout", &this->dns_timeout, DT_INTEGER, ValidateDnsTimeout},
- {"options", "moduledir", &this->ModPath, DT_CHARPTR, ValidateModPath},
- {"disabled", "commands", &this->DisabledCommands,DT_CHARPTR, NoValidation},
- {"options", "operonlystats", &this->OperOnlyStats, DT_CHARPTR, NoValidation},
- {"options", "customversion", &this->CustomVersion, DT_CHARPTR, NoValidation},
- {"options", "hidesplits", &this->HideSplits, DT_BOOLEAN, NoValidation},
+ {"options", "moduledir", &this->ModPath, DT_CHARPTR, ValidateModPath},
+ {"disabled", "commands", &this->DisabledCommands, DT_CHARPTR, NoValidation},
+ {"options", "operonlystats", &this->OperOnlyStats, DT_CHARPTR, NoValidation},
+ {"options", "customversion", &this->CustomVersion, DT_CHARPTR, NoValidation},
+ {"options", "hidesplits", &this->HideSplits, DT_BOOLEAN, NoValidation},
{"options", "hidebans", &this->HideBans, DT_BOOLEAN, NoValidation},
- {"options", "hidewhois", &this->HideWhoisServer, DT_CHARPTR, NoValidation},
- {"options", "operspywhois", &this->OperSpyWhois, DT_BOOLEAN, NoValidation},
+ {"options", "hidewhois", &this->HideWhoisServer, DT_CHARPTR, NoValidation},
+ {"options", "operspywhois", &this->OperSpyWhois, DT_BOOLEAN, NoValidation},
{"options", "tempdir", &this->TempDir, DT_CHARPTR, ValidateTempDir},
- {"pid", "file", &this->PID, DT_CHARPTR, NoValidation},
+ {"pid", "file", &this->PID, DT_CHARPTR, NoValidation},
{NULL}
};
/* If we succeeded, set the ircd config to the new one */
Config->config_data = newconfig;
- int c = 1;
+/* int c = 1;
std::string last;
for(ConfigDataHash::const_iterator i = this->config_data.begin(); i != this->config_data.end(); i++)
{
- if(i->first != last)
- c = 1;
- else
- c++;
+ c = (i->first != last) ? 1 : c+1;
+ last = i->first;
std::cout << "[" << i->first << " " << c << "/" << this->config_data.count(i->first) << "]" << std::endl;
for(KeyValList::const_iterator j = i->second.begin(); j != i->second.end(); j++)
- {
std::cout << "\t" << j->first << " = " << j->second << std::endl;
- }
std::cout << "[/" << i->first << " " << c << "/" << this->config_data.count(i->first) << "]" << std::endl;
-
- last = i->first;
}
-
- for(ConfigDataHash::const_iterator i = this->config_data.begin(); i != this->config_data.end(); i++)
- {
- std::cout << "There are " << ConfValueEnum(this->config_data, i->first) << " <" << i->first << "> tags" << std::endl;
-
- for(int j = 0; j < ConfValueEnum(this->config_data, i->first); j++)
- {
- std::string foo;
- if(ConfValue(this->config_data, i->first, "name", j, foo))
- {
- std::cout << "<" << i->first << ":name> " << foo << std::endl;
- }
- else
- {
- std::cout << "<" << i->first << ":name> undef" << std::endl;
- }
- }
- }
- }
+ */ }
else
{
log(DEFAULT, "There were errors in your configuration:\n%s", errstr.str().c_str());
if (bail)
{
/* Unneeded because of the log() aboive? */
- // printf("There were errors in your configuration:\n%s",errstr.str().c_str());
+ printf("There were errors in your configuration:\n%s",errstr.str().c_str());
Exit(0);
}
else
{
/* Leaving quotes, we have the value */
results.push_back(KeyVal(current_key, current_value));
- std::cout << "<" << tagname << ":" << current_key << "> " << current_value << std::endl;
+
+ // std::cout << "<" << tagname << ":" << current_key << "> " << current_value << std::endl;
+
in_quote = false;
got_key = false;
}
}
}
+ else if(pos == 0)
+ {
+ log(DEBUG, "No <%s> tags in config file.", tag.c_str());
+ }
else
{
- log(DEBUG, "ConfValue got an out-of-range index %d", pos);
+ log(DEBUG, "ConfValue got an out-of-range index %d, there are only %d occurences of %s", pos, target.count(tag), tag.c_str());
}
return false;
int ServerConfig::ConfValueEnum(ConfigDataHash &target, const char* tag)
{
- return ConfValueEnum(target, std::string(tag));
+ return target.count(tag);
}
int ServerConfig::ConfValueEnum(ConfigDataHash &target, const std::string &tag)
int ServerConfig::ConfVarEnum(ConfigDataHash &target, const char* tag, int index)
{
- return 1;
+ return ConfVarEnum(target, std::string(tag), index);
}
int ServerConfig::ConfVarEnum(ConfigDataHash &target, const std::string &tag, int index)
return iter->second.size();
}
+ else if(pos == 0)
+ {
+ log(DEBUG, "No <%s> tags in config file.", tag.c_str());
+ }
else
{
- log(DEBUG, "ConfVarEnum got an out-of-range index %d", pos);
+ log(DEBUG, "ConfVarEnum got an out-of-range index %d, there are only %d occurences of %s", pos, target.count(tag), tag.c_str());
}
return 0;
* a maximum of one second before it times out, using the DNS
* server specified in the configuration file.
*/
-bool BindSocket(int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr)
+bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr)
{
memset(&server,0,sizeof(server));
- struct in_addr addy;
+ insp_inaddr addy;
bool resolved = false;
char resolved_addr[128];
int BindPorts(bool bail)
{
char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
- sockaddr_in client,server;
+ insp_sockaddr client, server;
int clientportcount = 0;
int BoundPortCount = 0;