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

Problem: formatting errors

Solution: apply clang-format-diff
parent 1fdb152b
......@@ -464,20 +464,20 @@ int zmq::options_t::setsockopt (int option_,
case ZMQ_SOCKS_USERNAME:
/* Make empty string or NULL equivalent. */
if (optval_ == NULL || optvallen_ == 0) {
socks_proxy_username.clear();
socks_proxy_username.clear ();
return 0;
} else {
return do_setsockopt_string_allow_empty_strict (
optval_, optvallen_, &socks_proxy_username, 255);
optval_, optvallen_, &socks_proxy_username, 255);
}
case ZMQ_SOCKS_PASSWORD:
/* Make empty string or NULL equivalent. */
if (optval_ == NULL || optvallen_ == 0) {
socks_proxy_password.clear();
socks_proxy_password.clear ();
return 0;
} else {
return do_setsockopt_string_allow_empty_strict (
optval_, optvallen_, &socks_proxy_password, 255);
optval_, optvallen_, &socks_proxy_password, 255);
}
case ZMQ_TCP_KEEPALIVE:
if (is_int && (value == -1 || value == 0 || value == 1)) {
......
......@@ -668,14 +668,14 @@ zmq::own_t *zmq::session_base_t::create_connecter_tcp (io_thread_t *io_thread_,
address_t *proxy_address = new (std::nothrow) address_t (
protocol_name::tcp, options.socks_proxy_address, this->get_ctx ());
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_);
alloc_assert(connecter);
if (!options.socks_proxy_username.empty ()) {
connecter->set_auth_method_basic(options.socks_proxy_username,
options.socks_proxy_password);
}
return connecter;
alloc_assert (connecter);
if (!options.socks_proxy_username.empty ()) {
connecter->set_auth_method_basic (options.socks_proxy_username,
options.socks_proxy_password);
}
return connecter;
}
return new (std::nothrow)
tcp_connecter_t (io_thread_, this, options, _addr, wait_);
......
......@@ -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_,
std::string password_) :
zmq::socks_basic_auth_request_t::socks_basic_auth_request_t (
std::string username_, std::string password_) :
username (username_),
password (password_)
{
......@@ -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;
*ptr++ = 0x01;
*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_) :
{
}
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_,
stream_connecter_base_t (
io_thread_, session_, options_, addr_, delayed_start_),
_proxy_addr (proxy_addr_),
_auth_method(socks_no_auth_required),
_auth_method (socks_no_auth_required),
_status (unplugged)
{
zmq_assert (_addr->protocol == protocol_name::tcp);
......@@ -76,8 +76,8 @@ zmq::socks_connecter_t::~socks_connecter_t ()
void zmq::socks_connecter_t::set_auth_method_none ()
{
_auth_method = socks_no_auth_required;
_auth_username.clear();
_auth_password.clear();
_auth_username.clear ();
_auth_password.clear ();
}
void zmq::socks_connecter_t::set_auth_method_basic (const std::string username,
......@@ -103,8 +103,10 @@ void zmq::socks_connecter_t::in_event ()
if (rc == -1)
error ();
else {
if (choice.method == socks_basic_auth) expected_status = sending_basic_auth_request;
else expected_status = sending_request;
if (choice.method == socks_basic_auth)
expected_status = sending_basic_auth_request;
else
expected_status = sending_request;
}
}
} else if (_status == waiting_for_auth_response) {
......@@ -112,7 +114,8 @@ void zmq::socks_connecter_t::in_event ()
if (rc == 0 || rc == -1)
error ();
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);
if (rc == -1)
error ();
......@@ -141,7 +144,8 @@ void zmq::socks_connecter_t::in_event ()
error ();
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);
set_pollout (_handle);
_status = sending_basic_auth_request;
......@@ -157,23 +161,20 @@ void zmq::socks_connecter_t::in_event ()
_status = sending_request;
}
}
}
void zmq::socks_connecter_t::out_event ()
{
zmq_assert (_status == waiting_for_proxy_connection
|| _status == sending_greeting
|| _status == sending_basic_auth_request
|| _status == sending_request);
zmq_assert (
_status == waiting_for_proxy_connection || _status == sending_greeting
|| _status == sending_basic_auth_request || _status == sending_request);
if (_status == waiting_for_proxy_connection) {
const int rc = static_cast<int> (check_proxy_connection ());
if (rc == -1)
error ();
else {
_greeting_encoder.encode (
socks_greeting_t (_auth_method));
_greeting_encoder.encode (socks_greeting_t (_auth_method));
_status = sending_greeting;
}
} else if (_status == sending_greeting) {
......@@ -241,9 +242,10 @@ void zmq::socks_connecter_t::start_connecting ()
int zmq::socks_connecter_t::process_server_response (
const socks_choice_t &response_)
{
return response_.method == socks_no_auth_required ||
response_.method == socks_basic_auth ?
0 : -1;
return response_.method == socks_no_auth_required
|| response_.method == socks_basic_auth
? 0
: -1;
}
int zmq::socks_connecter_t::process_server_response (
......
......@@ -248,7 +248,7 @@ void zmq::thread_t::stop ()
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 (
......
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