Refactoring: how to report to error logs

This commit is contained in:
Felipe Zimmerle
2016-12-01 01:05:29 -03:00
parent e6b58014db
commit bfc30dad34
29 changed files with 236 additions and 161 deletions

View File

@@ -206,6 +206,17 @@ unsigned char *c2x(unsigned what, unsigned char *where) {
}
void replaceAll(std::string *str, const std::string& from,
const std::string& to) {
size_t start_pos = 0;
while ((start_pos = str->find(from, start_pos)) != std::string::npos) {
size_t end_pos = start_pos + from.length();
str->replace(start_pos, from.length(), to);
start_pos += to.length();
}
}
} // namespace string
} // namespace utils
} // namespace modsecurity

View File

@@ -66,6 +66,8 @@ std::string tolower(std::string str);
std::string toupper(std::string str);
std::vector<std::string> split(std::string str, char delimiter);
void chomp(std::string *str);
void replaceAll(std::string *str, const std::string& from,
const std::string& to);
unsigned char x2c(unsigned char *what);
unsigned char xsingle2c(unsigned char *what);