mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-24 09:12:30 +02:00
Problem: formatting inconsistent
Solution: applied clang-format
This commit is contained in:
@@ -28,26 +28,25 @@
|
||||
*/
|
||||
|
||||
#include "testutil.hpp"
|
||||
#if defined (ZMQ_HAVE_WINDOWS)
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# include <stdexcept>
|
||||
# define close closesocket
|
||||
#if defined(ZMQ_HAVE_WINDOWS)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <stdexcept>
|
||||
#define close closesocket
|
||||
#else
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
zap_handler (void *handler)
|
||||
static void zap_handler (void *handler)
|
||||
{
|
||||
// Process ZAP requests forever
|
||||
while (true) {
|
||||
char *version = s_recv (handler);
|
||||
if (!version)
|
||||
break; // Terminating
|
||||
break; // Terminating
|
||||
|
||||
char *sequence = s_recv (handler);
|
||||
char *domain = s_recv (handler);
|
||||
@@ -57,20 +56,19 @@ zap_handler (void *handler)
|
||||
|
||||
assert (streq (version, "1.0"));
|
||||
assert (streq (mechanism, "NULL"));
|
||||
|
||||
|
||||
s_sendmore (handler, version);
|
||||
s_sendmore (handler, sequence);
|
||||
if (streq (domain, "TEST")) {
|
||||
s_sendmore (handler, "200");
|
||||
s_sendmore (handler, "OK");
|
||||
s_sendmore (handler, "anonymous");
|
||||
s_send (handler, "");
|
||||
}
|
||||
else {
|
||||
s_send (handler, "");
|
||||
} else {
|
||||
s_sendmore (handler, "400");
|
||||
s_sendmore (handler, "BAD DOMAIN");
|
||||
s_sendmore (handler, "");
|
||||
s_send (handler, "");
|
||||
s_send (handler, "");
|
||||
}
|
||||
free (version);
|
||||
free (sequence);
|
||||
@@ -84,7 +82,7 @@ zap_handler (void *handler)
|
||||
|
||||
int main (void)
|
||||
{
|
||||
setup_test_environment();
|
||||
setup_test_environment ();
|
||||
size_t len = MAX_SOCKET_STRING;
|
||||
char my_endpoint[MAX_SOCKET_STRING];
|
||||
void *ctx = zmq_ctx_new ();
|
||||
@@ -100,7 +98,7 @@ int main (void)
|
||||
void *zap_thread = zmq_threadstart (&zap_handler, handler);
|
||||
|
||||
// We bounce between a binding server and a connecting client
|
||||
|
||||
|
||||
// We first test client/server with no ZAP domain
|
||||
// Libzmq does not call our ZAP handler, the connect must succeed
|
||||
void *server = zmq_socket (ctx, ZMQ_DEALER);
|
||||
@@ -117,7 +115,7 @@ int main (void)
|
||||
close_zero_linger (client);
|
||||
close_zero_linger (server);
|
||||
|
||||
// Now define a ZAP domain for the server; this enables
|
||||
// Now define a ZAP domain for the server; this enables
|
||||
// authentication. We're using the wrong domain so this test
|
||||
// must fail.
|
||||
server = zmq_socket (ctx, ZMQ_DEALER);
|
||||
@@ -171,19 +169,19 @@ int main (void)
|
||||
int s;
|
||||
|
||||
unsigned short int port;
|
||||
rc = sscanf(my_endpoint, "tcp://127.0.0.1:%hu", &port);
|
||||
rc = sscanf (my_endpoint, "tcp://127.0.0.1:%hu", &port);
|
||||
assert (rc == 1);
|
||||
|
||||
ip4addr.sin_family = AF_INET;
|
||||
ip4addr.sin_port = htons(port);
|
||||
#if defined (ZMQ_HAVE_WINDOWS) && (_WIN32_WINNT < 0x0600)
|
||||
ip4addr.sin_port = htons (port);
|
||||
#if defined(ZMQ_HAVE_WINDOWS) && (_WIN32_WINNT < 0x0600)
|
||||
ip4addr.sin_addr.s_addr = inet_addr ("127.0.0.1");
|
||||
#else
|
||||
inet_pton(AF_INET, "127.0.0.1", &ip4addr.sin_addr);
|
||||
inet_pton (AF_INET, "127.0.0.1", &ip4addr.sin_addr);
|
||||
#endif
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
rc = connect (s, (struct sockaddr*) &ip4addr, sizeof ip4addr);
|
||||
rc = connect (s, (struct sockaddr *) &ip4addr, sizeof ip4addr);
|
||||
assert (rc > -1);
|
||||
// send anonymous ZMTP/1.0 greeting
|
||||
send (s, "\x01\x00", 2, 0);
|
||||
|
||||
Reference in New Issue
Block a user