aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee/include')
-rw-r--r--contrib/epee/include/console_handler.h28
-rw-r--r--contrib/epee/include/net/http_client.h3
-rw-r--r--contrib/epee/include/readline_buffer.h6
-rw-r--r--contrib/epee/include/string_tools.h12
4 files changed, 31 insertions, 18 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index a3b2d30eb..b8336b270 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -52,11 +52,10 @@ namespace epee
, m_has_read_request(false)
, m_read_status(state_init)
{
- m_reader_thread = boost::thread(std::bind(&async_stdin_reader::reader_thread_func, this));
#ifdef HAVE_READLINE
m_readline_buffer.start();
- m_readline_thread = boost::thread(std::bind(&async_stdin_reader::readline_thread_func, this));
#endif
+ m_reader_thread = boost::thread(std::bind(&async_stdin_reader::reader_thread_func, this));
}
~async_stdin_reader()
@@ -115,7 +114,6 @@ namespace epee
m_reader_thread.join();
#ifdef HAVE_READLINE
m_readline_buffer.stop();
- m_readline_thread.join();
#endif
}
}
@@ -193,16 +191,6 @@ namespace epee
return true;
}
-#ifdef HAVE_READLINE
- void readline_thread_func()
- {
- while (m_run.load(std::memory_order_relaxed))
- {
- m_readline_buffer.process();
- }
- }
-#endif
-
void reader_thread_func()
{
while (true)
@@ -212,12 +200,20 @@ namespace epee
std::string line;
bool read_ok = true;
+#ifdef HAVE_READLINE
+reread:
+#endif
if (wait_stdin_data())
{
if (m_run.load(std::memory_order_relaxed))
{
#ifdef HAVE_READLINE
- m_readline_buffer.get_line(line);
+ switch (m_readline_buffer.get_line(line))
+ {
+ case rdln::empty: goto eof;
+ case rdln::partial: goto reread;
+ case rdln::full: break;
+ }
#else
std::getline(std::cin, line);
#endif
@@ -229,6 +225,9 @@ namespace epee
read_ok = false;
}
if (std::cin.eof()) {
+#ifdef HAVE_READLINE
+eof:
+#endif
m_read_status = state_eos;
m_response_cv.notify_one();
break;
@@ -263,7 +262,6 @@ namespace epee
boost::thread m_reader_thread;
std::atomic<bool> m_run;
#ifdef HAVE_READLINE
- boost::thread m_readline_thread;
rdln::readline_buffer m_readline_buffer;
#endif
diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h
index 67e63f7bf..8e099e2bc 100644
--- a/contrib/epee/include/net/http_client.h
+++ b/contrib/epee/include/net/http_client.h
@@ -293,6 +293,9 @@ using namespace std;
, m_lock()
{}
+ const std::string &get_host() const { return m_host_buff; };
+ const std::string &get_port() const { return m_port; };
+
bool set_server(const std::string& address, boost::optional<login> user)
{
http::url_content parsed{};
diff --git a/contrib/epee/include/readline_buffer.h b/contrib/epee/include/readline_buffer.h
index 28a153414..cda7e34f9 100644
--- a/contrib/epee/include/readline_buffer.h
+++ b/contrib/epee/include/readline_buffer.h
@@ -8,25 +8,25 @@
namespace rdln
{
+ typedef enum { empty, partial, full } linestatus;
class readline_buffer : public std::stringbuf
{
public:
readline_buffer();
void start();
void stop();
- int process();
bool is_running() const
{
return m_cout_buf != NULL;
}
- void get_line(std::string& line) const;
+ linestatus get_line(std::string& line) const;
void set_prompt(const std::string& prompt);
static void add_completion(const std::string& command);
static const std::vector<std::string>& get_completions();
protected:
virtual int sync();
-
+
private:
std::streambuf* m_cout_buf;
static std::vector<std::string>& completion_commands();
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index 258caa49e..ce7b2fb87 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -314,6 +314,18 @@ POP_WARNINGS
return str;
}
//----------------------------------------------------------------------------
+ inline std::string pad_string(std::string s, size_t n, char c = ' ', bool prepend = false)
+ {
+ if (s.size() < n)
+ {
+ if (prepend)
+ s = std::string(n - s.size(), c) + s;
+ else
+ s.append(n - s.size(), c);
+ }
+ return s;
+ }
+ //----------------------------------------------------------------------------
template<class t_pod_type>
std::string pod_to_hex(const t_pod_type& s)
{