- // read the configuration file on startup.
- // it is perfectly valid to set <filter file> to the value of the
- // main config file, then append your <keyword> tags to the bottom
- // of the main config... but rather messy. That's why the capability
- // of using a seperate config file is provided.
- Srv = Me;
- Conf = new ConfigReader;
- std::string filterfile = Conf->ReadValue("filter","file",0);
- MyConf = new ConfigReader(filterfile);
- if ((filterfile == "") || (!MyConf->Verify()))
- {
- printf("Error, could not find <filter file=\"\"> definition in your config file!\n");
- log(DEFAULT,"Error, could not find <filter file=\"\"> definition in your config file!");
- return;
- }
- Srv->Log(DEFAULT,std::string("m_filter_pcre: read configuration from ")+filterfile);
-
- filters.clear();
- for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
- {
- std::string pattern = MyConf->ReadValue("keyword","pattern",index);
- re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL);
- if (!re)
- {
- log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error);
- log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str());
- }
- else
- {
- filters.push_back(re);
- log(DEFAULT,"Regular expression %s loaded.", pattern.c_str());
- }
- }
-