mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-15 23:36:19 +00:00
refactor(userspace/engine): re-implement wrap_text() function in falco_utils
The function implementation was removed, however it was still defined in the .h header. Moreover, this will now be required in order to replace its lua equivalent. Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
parent
3201479392
commit
cf83a91d4e
@ -27,6 +27,31 @@ namespace falco
|
||||
namespace utils
|
||||
{
|
||||
|
||||
std::string wrap_text(const std::string& str, uint32_t indent, uint32_t line_len)
|
||||
{
|
||||
std::string ret;
|
||||
size_t len = str.size();
|
||||
size_t cur_len = 0;
|
||||
for(uint32_t l = 0; l < len; l++)
|
||||
{
|
||||
if(cur_len > (line_len - indent) && l != 0 && str[l] == ' ')
|
||||
{
|
||||
cur_len = 0;
|
||||
while (l < len && str[l++] == ' ');
|
||||
l--;
|
||||
ret += "\n";
|
||||
for(uint32_t m = 0; m < indent; m++)
|
||||
{
|
||||
ret += " ";
|
||||
}
|
||||
}
|
||||
ret += str.at(l);
|
||||
cur_len++;
|
||||
}
|
||||
ret += "\n";
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t hardware_concurrency()
|
||||
{
|
||||
auto hc = std::thread::hardware_concurrency();
|
||||
|
@ -40,7 +40,7 @@ namespace falco
|
||||
namespace utils
|
||||
{
|
||||
|
||||
std::string wrap_text(const std::string& str, uint32_t initial_pos, uint32_t indent, uint32_t line_len);
|
||||
std::string wrap_text(const std::string& str, uint32_t indent, uint32_t linelen);
|
||||
|
||||
void readfile(const std::string& filename, std::string& data);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user