Commit 3c06ec11 authored by Luca Boccassi's avatar Luca Boccassi

Problem: formatting errors

Solution: apply clang-format-diff
parent 1fdb152b
...@@ -464,7 +464,7 @@ int zmq::options_t::setsockopt (int option_, ...@@ -464,7 +464,7 @@ int zmq::options_t::setsockopt (int option_,
case ZMQ_SOCKS_USERNAME: case ZMQ_SOCKS_USERNAME:
/* Make empty string or NULL equivalent. */ /* Make empty string or NULL equivalent. */
if (optval_ == NULL || optvallen_ == 0) { if (optval_ == NULL || optvallen_ == 0) {
socks_proxy_username.clear(); socks_proxy_username.clear ();
return 0; return 0;
} else { } else {
return do_setsockopt_string_allow_empty_strict ( return do_setsockopt_string_allow_empty_strict (
...@@ -473,7 +473,7 @@ int zmq::options_t::setsockopt (int option_, ...@@ -473,7 +473,7 @@ int zmq::options_t::setsockopt (int option_,
case ZMQ_SOCKS_PASSWORD: case ZMQ_SOCKS_PASSWORD:
/* Make empty string or NULL equivalent. */ /* Make empty string or NULL equivalent. */
if (optval_ == NULL || optvallen_ == 0) { if (optval_ == NULL || optvallen_ == 0) {
socks_proxy_password.clear(); socks_proxy_password.clear ();
return 0; return 0;
} else { } else {
return do_setsockopt_string_allow_empty_strict ( return do_setsockopt_string_allow_empty_strict (
......
...@@ -670,9 +670,9 @@ zmq::own_t *zmq::session_base_t::create_connecter_tcp (io_thread_t *io_thread_, ...@@ -670,9 +670,9 @@ zmq::own_t *zmq::session_base_t::create_connecter_tcp (io_thread_t *io_thread_,
alloc_assert (proxy_address); alloc_assert (proxy_address);
socks_connecter_t *connecter = new (std::nothrow) socks_connecter_t ( socks_connecter_t *connecter = new (std::nothrow) socks_connecter_t (
io_thread_, this, options, _addr, proxy_address, wait_); io_thread_, this, options, _addr, proxy_address, wait_);
alloc_assert(connecter); alloc_assert (connecter);
if (!options.socks_proxy_username.empty ()) { if (!options.socks_proxy_username.empty ()) {
connecter->set_auth_method_basic(options.socks_proxy_username, connecter->set_auth_method_basic (options.socks_proxy_username,
options.socks_proxy_password); options.socks_proxy_password);
} }
return connecter; return connecter;
......
...@@ -129,8 +129,8 @@ void zmq::socks_choice_decoder_t::reset () ...@@ -129,8 +129,8 @@ void zmq::socks_choice_decoder_t::reset ()
} }
zmq::socks_basic_auth_request_t::socks_basic_auth_request_t (std::string username_, zmq::socks_basic_auth_request_t::socks_basic_auth_request_t (
std::string password_) : std::string username_, std::string password_) :
username (username_), username (username_),
password (password_) password (password_)
{ {
...@@ -145,9 +145,9 @@ zmq::socks_basic_auth_request_encoder_t::socks_basic_auth_request_encoder_t () : ...@@ -145,9 +145,9 @@ zmq::socks_basic_auth_request_encoder_t::socks_basic_auth_request_encoder_t () :
{ {
} }
void zmq::socks_basic_auth_request_encoder_t::encode (const socks_basic_auth_request_t &req_) void zmq::socks_basic_auth_request_encoder_t::encode (
const socks_basic_auth_request_t &req_)
{ {
unsigned char *ptr = _buf; unsigned char *ptr = _buf;
*ptr++ = 0x01; *ptr++ = 0x01;
*ptr++ = static_cast<unsigned char> (req_.username.size ()); *ptr++ = static_cast<unsigned char> (req_.username.size ());
...@@ -186,7 +186,8 @@ zmq::socks_auth_response_t::socks_auth_response_t (uint8_t response_code_) : ...@@ -186,7 +186,8 @@ zmq::socks_auth_response_t::socks_auth_response_t (uint8_t response_code_) :
{ {
} }
zmq::socks_auth_response_decoder_t::socks_auth_response_decoder_t () : _bytes_read (0) zmq::socks_auth_response_decoder_t::socks_auth_response_decoder_t () :
_bytes_read (0)
{ {
} }
......
...@@ -61,7 +61,7 @@ zmq::socks_connecter_t::socks_connecter_t (class io_thread_t *io_thread_, ...@@ -61,7 +61,7 @@ zmq::socks_connecter_t::socks_connecter_t (class io_thread_t *io_thread_,
stream_connecter_base_t ( stream_connecter_base_t (
io_thread_, session_, options_, addr_, delayed_start_), io_thread_, session_, options_, addr_, delayed_start_),
_proxy_addr (proxy_addr_), _proxy_addr (proxy_addr_),
_auth_method(socks_no_auth_required), _auth_method (socks_no_auth_required),
_status (unplugged) _status (unplugged)
{ {
zmq_assert (_addr->protocol == protocol_name::tcp); zmq_assert (_addr->protocol == protocol_name::tcp);
...@@ -76,8 +76,8 @@ zmq::socks_connecter_t::~socks_connecter_t () ...@@ -76,8 +76,8 @@ zmq::socks_connecter_t::~socks_connecter_t ()
void zmq::socks_connecter_t::set_auth_method_none () void zmq::socks_connecter_t::set_auth_method_none ()
{ {
_auth_method = socks_no_auth_required; _auth_method = socks_no_auth_required;
_auth_username.clear(); _auth_username.clear ();
_auth_password.clear(); _auth_password.clear ();
} }
void zmq::socks_connecter_t::set_auth_method_basic (const std::string username, void zmq::socks_connecter_t::set_auth_method_basic (const std::string username,
...@@ -103,8 +103,10 @@ void zmq::socks_connecter_t::in_event () ...@@ -103,8 +103,10 @@ void zmq::socks_connecter_t::in_event ()
if (rc == -1) if (rc == -1)
error (); error ();
else { else {
if (choice.method == socks_basic_auth) expected_status = sending_basic_auth_request; if (choice.method == socks_basic_auth)
else expected_status = sending_request; expected_status = sending_basic_auth_request;
else
expected_status = sending_request;
} }
} }
} else if (_status == waiting_for_auth_response) { } else if (_status == waiting_for_auth_response) {
...@@ -112,7 +114,8 @@ void zmq::socks_connecter_t::in_event () ...@@ -112,7 +114,8 @@ void zmq::socks_connecter_t::in_event ()
if (rc == 0 || rc == -1) if (rc == 0 || rc == -1)
error (); error ();
else if (_auth_response_decoder.message_ready ()) { else if (_auth_response_decoder.message_ready ()) {
const socks_auth_response_t auth_response = _auth_response_decoder.decode (); const socks_auth_response_t auth_response =
_auth_response_decoder.decode ();
rc = process_server_response (auth_response); rc = process_server_response (auth_response);
if (rc == -1) if (rc == -1)
error (); error ();
...@@ -141,7 +144,8 @@ void zmq::socks_connecter_t::in_event () ...@@ -141,7 +144,8 @@ void zmq::socks_connecter_t::in_event ()
error (); error ();
if (expected_status == sending_basic_auth_request) { if (expected_status == sending_basic_auth_request) {
_basic_auth_request_encoder.encode (socks_basic_auth_request_t (_auth_username, _auth_password)); _basic_auth_request_encoder.encode (
socks_basic_auth_request_t (_auth_username, _auth_password));
reset_pollin (_handle); reset_pollin (_handle);
set_pollout (_handle); set_pollout (_handle);
_status = sending_basic_auth_request; _status = sending_basic_auth_request;
...@@ -157,23 +161,20 @@ void zmq::socks_connecter_t::in_event () ...@@ -157,23 +161,20 @@ void zmq::socks_connecter_t::in_event ()
_status = sending_request; _status = sending_request;
} }
} }
} }
void zmq::socks_connecter_t::out_event () void zmq::socks_connecter_t::out_event ()
{ {
zmq_assert (_status == waiting_for_proxy_connection zmq_assert (
|| _status == sending_greeting _status == waiting_for_proxy_connection || _status == sending_greeting
|| _status == sending_basic_auth_request || _status == sending_basic_auth_request || _status == sending_request);
|| _status == sending_request);
if (_status == waiting_for_proxy_connection) { if (_status == waiting_for_proxy_connection) {
const int rc = static_cast<int> (check_proxy_connection ()); const int rc = static_cast<int> (check_proxy_connection ());
if (rc == -1) if (rc == -1)
error (); error ();
else { else {
_greeting_encoder.encode ( _greeting_encoder.encode (socks_greeting_t (_auth_method));
socks_greeting_t (_auth_method));
_status = sending_greeting; _status = sending_greeting;
} }
} else if (_status == sending_greeting) { } else if (_status == sending_greeting) {
...@@ -241,9 +242,10 @@ void zmq::socks_connecter_t::start_connecting () ...@@ -241,9 +242,10 @@ void zmq::socks_connecter_t::start_connecting ()
int zmq::socks_connecter_t::process_server_response ( int zmq::socks_connecter_t::process_server_response (
const socks_choice_t &response_) const socks_choice_t &response_)
{ {
return response_.method == socks_no_auth_required || return response_.method == socks_no_auth_required
response_.method == socks_basic_auth ? || response_.method == socks_basic_auth
0 : -1; ? 0
: -1;
} }
int zmq::socks_connecter_t::process_server_response ( int zmq::socks_connecter_t::process_server_response (
......
...@@ -248,7 +248,7 @@ void zmq::thread_t::stop () ...@@ -248,7 +248,7 @@ void zmq::thread_t::stop ()
bool zmq::thread_t::is_current_thread () const bool zmq::thread_t::is_current_thread () const
{ {
return bool( pthread_equal(pthread_self (), _descriptor) ); return bool(pthread_equal (pthread_self (), _descriptor));
} }
void zmq::thread_t::setSchedulingParameters ( void zmq::thread_t::setSchedulingParameters (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment