basic email parsing

This commit is contained in:
2025-06-07 20:55:16 +03:00
parent 259b8543a4
commit 9da589839c
11 changed files with 205 additions and 239 deletions

View File

@@ -42,6 +42,7 @@ std::string get_local_ip_address() {
inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
std::string value(addressBuffer);
//TODO: better way to determine local IP address
if (!strncmp(value.c_str(), "192.168", 7)) {
return value;
}
@@ -68,6 +69,26 @@ std::string get_path_relative_to_home(std::string path) {
return std::string(std::getenv("HOME")) + "/" + path;
}
std::string get_application_home_path() {
return get_path_relative_to_home(".local/share/checks_parser");
}
std::map<std::string, std::string> get_params_from_string(std::string parametersString) {
parametersString = boost::regex_replace(parametersString, boost::regex("%26"), "&");
parametersString = boost::regex_replace(parametersString, boost::regex("%3D"), "=");
std::vector<std::string> parameters = split(parametersString, "&");
std::map<std::string, std::string> paramsMap;
for (auto &parameter : parameters) {
std::vector<std::string> values = split(parameter, "=");
paramsMap.insert(std::pair<std::string, std::string> (values[0], values[1]));
}
return paramsMap;
}
template <typename T>
bool vector_contains_element(const std::vector<T>& vector, const T& to_find) {
for (const T& element : vector) {

View File

@@ -11,6 +11,9 @@ std::string to_utf8(std::wstring wide_string);
std::wstring from_utf8(std::string string);
std::string get_path_relative_to_home(std::string path);
std::string get_application_home_path();
std::map<std::string, std::string> get_params_from_string(std::string);
const std::map<std::string, ColumnType> column_names = {
{"date", ColumnType::date},