diff --git a/utils.cc b/utils.cc index 2b3e92f..7da81b4 100644 --- a/utils.cc +++ b/utils.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include "utils.h" @@ -41,6 +42,18 @@ std::string get_comm_name(void) return comm; } +std::vector string_split(std::string str, char delim) +{ + std::vector vstr; + std::stringstream ss(str); + std::string s; + + while (getline(ss, s, delim)) + vstr.push_back(s); + + return vstr; +} + static enum_table ht_mmap_prot[] = { { "PROT_NONE", 0 }, { "PROT_READ", 1 }, diff --git a/utils.h b/utils.h index 1725496..5e75577 100644 --- a/utils.h +++ b/utils.h @@ -10,6 +10,7 @@ #include #include +#include #ifndef _GNU_SOURCE # define _GNU_SOURCE @@ -31,6 +32,8 @@ std::string asprintf(const char* fmt, ...); std::string get_comm_name(void); +std::vector string_split(std::string str, char delim); + struct enum_table { const char *str; int val;