From 509e9201fd1918caf8fb08160064e7dbeef24dee Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Thu, 23 Apr 2020 15:08:44 +0200 Subject: [HICN-600] correct hicn apps on windows Signed-off-by: Angelo Mantellini Change-Id: I78656e5b3821024913b01b095e4368f53d02a5d1 --- apps/higet/higet.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'apps/higet') diff --git a/apps/higet/higet.cc b/apps/higet/higet.cc index 5877c96b3..7584148a9 100644 --- a/apps/higet/higet.cc +++ b/apps/higet/higet.cc @@ -16,9 +16,8 @@ #include #include #include - -#include -#include +#include +#include #define ASIO_STANDALONE #include @@ -114,12 +113,9 @@ class ReadBytesCallbackImplementation // read next chunk size const char *begin = (const char *)payload->data(); const char *end = (const char *)payload->tail(); - - using std::experimental::make_boyer_moore_searcher; - auto it = std::experimental::search( - begin, end, - make_boyer_moore_searcher(chunk_separator.begin(), - chunk_separator.end())); + const char *begincrlf2 = (const char *)chunk_separator.c_str(); + const char *endcrlf2 = begincrlf2 + chunk_separator.size(); + auto it = std::search(begin, end, begincrlf2, endcrlf2); if (it != end) { chunk_size_ = std::stoul(begin, 0, 16); content_size_ += chunk_size_; @@ -200,9 +196,15 @@ class ReadBytesCallbackImplementation void print_bar(long value, long max_value, bool last) { float progress = (float)value / max_value; +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + int barWidth = csbi.srWindow.Right - csbi.srWindow.Left + 7; +#else struct winsize size; ioctl(STDOUT_FILENO, TIOCGWINSZ, &size); int barWidth = size.ws_col - 8; +#endif std::cout << "["; int pos = barWidth * progress; -- cgit 1.2.3-korg