Browse files

Removed double blank lines in examples

  • Loading branch information...
1 parent 832b7e7 commit 90b2c691fb43f9cf4e20e2492814334d8acc0b6d @hintjens hintjens committed Dec 27, 2012
View
BIN examples/C/.clonesrv5.c.kate-swp
Binary file not shown.
View
8 examples/C/asyncsrv.c
@@ -53,9 +53,8 @@ static void server_worker (void *args, zctx_t *ctx, void *pipe);
void *server_task (void *args)
{
- zctx_t *ctx = zctx_new ();
-
// Frontend socket talks to clients over TCP
+ zctx_t *ctx = zctx_new ();
void *frontend = zsocket_new (ctx, ZMQ_ROUTER);
zsocket_bind (frontend, "tcp://*:5570");
@@ -106,7 +105,6 @@ server_worker (void *args, zctx_t *ctx, void *pipe)
}
}
-
// The main thread simply starts several clients, and a server, and then
// waits for the server to finish.
@@ -116,8 +114,6 @@ int main (void)
zthread_new (client_task, NULL);
zthread_new (client_task, NULL);
zthread_new (server_task, NULL);
-
- // Run for 5 seconds then quit
- zclock_sleep (5 * 1000);
+ zclock_sleep (5 * 1000); // Run for 5 seconds then quit
return 0;
}
View
3 examples/C/bstar.c
@@ -232,7 +232,6 @@ bstar_new (int primary, char *local, char *remote)
return self;
}
-
// .split destructor
// The destructor shuts down the bstar reactor:
@@ -249,7 +248,6 @@ bstar_destroy (bstar_t **self_p)
}
}
-
// .split zloop method
// The zloop method returns the underlying zloop reactor, so we can add
// additional timers and readers:
@@ -260,7 +258,6 @@ bstar_zloop (bstar_t *self)
return self->loop;
}
-
// .split voter method
// The voter method registers a client voter socket. Messages received
// on this socket provide the CLIENT_REQUEST events for the Binary Star
View
1 examples/C/bstarsrv.c
@@ -116,7 +116,6 @@ s_state_machine (bstar_t *fsm)
return exception;
}
-
// .split main task
// This is our main task. First we bind/connect our sockets with our
// peer and make sure we will get state messages correctly. We use
View
2 examples/C/clone.c
@@ -4,7 +4,6 @@
// If no server replies within this time, abandon request
#define GLOBAL_TIMEOUT 4000 // msecs
-
// =====================================================================
// Synchronous part, works in our application thread
@@ -120,7 +119,6 @@ clone_get (clone_t *self, char *key)
return NULL;
}
-
// .split working with servers
// The back-end agent manages a set of servers, which we implement using
// our simple class model:
View
1 examples/C/clonesrv5.c
@@ -20,7 +20,6 @@ typedef struct {
void *collector; // Collect updates from clients
} clonesrv_t;
-
int main (void)
{
clonesrv_t *self = (clonesrv_t *) zmalloc (sizeof (clonesrv_t));
View
11 examples/C/double
@@ -0,0 +1,11 @@
+while (<>) {
+ $lineno++;
+ chop while (/\s$/);
+ if (/^$/) {
+ $blank = $blank + 1;
+ print " $lineno\n" if $blank > 1;
+ }
+ else {
+ $blank = 0;
+ }
+}
View
1 examples/C/fileio3.c
@@ -103,7 +103,6 @@ server_thread (void *args, zctx_t *ctx, void *pipe)
fclose (file);
}
-
// The main task starts the client and server threads; it's easier
// to test this as a single process with threads, than as multiple
// processes:
View
4 examples/C/flcliapi.c
@@ -10,7 +10,6 @@
// Server considered dead if silent for this long
#define SERVER_TTL 6000 // msecs
-
// .split API structure
// This API works in two halves, a common pattern for APIs that need to
// run in the background. One half is an front-end object our application
@@ -97,7 +96,6 @@ flcliapi_request (flcliapi_t *self, zmsg_t **request_p)
return reply;
}
-
// .split back-end agent
// Here we see the back-end agent. It runs as an attached thread, talking
// to its parent over a pipe socket. It is a fairly complex piece of work
@@ -160,7 +158,6 @@ server_tickless (const char *key, void *server, void *arg)
return 0;
}
-
// .split back-end agent class
// We build the agent as a class that's capable of processing messages
// coming in from its various sockets:
@@ -288,7 +285,6 @@ agent_router_message (agent_t *self)
zmsg_destroy (&reply);
}
-
// .split back-end agent implementation
// Finally here's the agent task itself, which polls its two sockets
// and processes incoming messages:
View
1 examples/C/flclient2.c
@@ -55,7 +55,6 @@ int main (int argc, char *argv [])
return 0;
}
-
// .split class implementation
// Here is the flclient class implementation. Each instance has a context,
// a DEALER socket it uses to talk to the servers, a counter of how many
View
11 examples/C/hwclient.c
@@ -1,22 +1,15 @@
// Hello World client
-// Connects REQ socket to tcp://localhost:5555
-// Sends "Hello" to server, expects "World" back
-
#include <zmq.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
-#include <assert.h>
int main (void)
{
- void *context = zmq_ctx_new ();
-
- // Socket to talk to server
printf ("Connecting to hello world server...\n");
+ void *context = zmq_ctx_new ();
void *requester = zmq_socket (context, ZMQ_REQ);
- int rc = zmq_connect (requester, "tcp://localhost:5555");
- assert (rc == 0);
+ zmq_connect (requester, "tcp://localhost:5555");
int request_nbr;
for (request_nbr = 0; request_nbr != 10; request_nbr++) {
View
5 examples/C/hwserver.c
@@ -1,6 +1,4 @@
// Hello World server
-// Binds REP socket to tcp://*:5555
-// Expects "Hello" from client, replies with "World"
#include <zmq.h>
#include <stdio.h>
@@ -10,9 +8,8 @@
int main (void)
{
- void *context = zmq_ctx_new ();
-
// Socket to talk to clients
+ void *context = zmq_ctx_new ();
void *responder = zmq_socket (context, ZMQ_REP);
int rc = zmq_bind (responder, "tcp://*:5555");
assert (rc == 0);
View
5 examples/C/identity.c
@@ -1,13 +1,10 @@
-// Demonstrate identities as used by the request-reply pattern. Run this
-// program by itself. Note that the utility functions s_ are provided by
-// zhelpers.h. It gets boring for everyone to keep repeating this code.
+// Demonstrate request-reply identities
#include "zhelpers.h"
int main (void)
{
void *context = zmq_ctx_new ();
-
void *sink = zmq_socket (context, ZMQ_ROUTER);
zmq_bind (sink, "inproc://example");
View
2 examples/C/interface.c
@@ -5,7 +5,6 @@
#include <uuid/uuid.h>
#include "udplib.c"
-
// =====================================================================
// Synchronous part, works in our application thread
@@ -61,7 +60,6 @@ interface_recv (interface_t *self)
return msg;
}
-
// =====================================================================
// Asynchronous part, works in the background
View
20 examples/C/kvmsg.c
@@ -162,9 +162,7 @@ kvmsg_recv (void *socket)
return self;
}
-
// Send key-value message to socket; any empty frames are sent as such.
-
void
kvmsg_send (kvmsg_t *self, void *socket)
{
@@ -218,7 +216,6 @@ kvmsg_dup (kvmsg_t *self)
// .skip
// Return key from last read message, if any, else NULL
-
char *
kvmsg_key (kvmsg_t *self)
{
@@ -238,9 +235,7 @@ kvmsg_key (kvmsg_t *self)
return NULL;
}
-
// Set message key as provided
-
void
kvmsg_set_key (kvmsg_t *self, char *key)
{
@@ -253,9 +248,7 @@ kvmsg_set_key (kvmsg_t *self, char *key)
self->present [FRAME_KEY] = 1;
}
-
// Set message key using printf format
-
void
kvmsg_fmt_key (kvmsg_t *self, char *format, ...)
{
@@ -269,9 +262,7 @@ kvmsg_fmt_key (kvmsg_t *self, char *format, ...)
kvmsg_set_key (self, value);
}
-
// Return sequence nbr from last read message, if any
-
int64_t
kvmsg_sequence (kvmsg_t *self)
{
@@ -293,9 +284,7 @@ kvmsg_sequence (kvmsg_t *self)
return 0;
}
-
// Set message sequence number
-
void
kvmsg_set_sequence (kvmsg_t *self, int64_t sequence)
{
@@ -319,7 +308,6 @@ kvmsg_set_sequence (kvmsg_t *self, int64_t sequence)
}
// Return body from last read message, if any, else NULL
-
byte *
kvmsg_body (kvmsg_t *self)
{
@@ -330,9 +318,7 @@ kvmsg_body (kvmsg_t *self)
return NULL;
}
-
// Set message body
-
void
kvmsg_set_body (kvmsg_t *self, byte *body, size_t size)
{
@@ -345,9 +331,7 @@ kvmsg_set_body (kvmsg_t *self, byte *body, size_t size)
memcpy (zmq_msg_data (msg), body, size);
}
-
// Set message body using printf format
-
void
kvmsg_fmt_body (kvmsg_t *self, char *format, ...)
{
@@ -361,9 +345,7 @@ kvmsg_fmt_body (kvmsg_t *self, char *format, ...)
kvmsg_set_body (self, (byte *) value, strlen (value));
}
-
// Return body size from last read message, if any, else zero
-
size_t
kvmsg_size (kvmsg_t *self)
{
@@ -404,7 +386,6 @@ kvmsg_set_uuid (kvmsg_t *self)
self->present [FRAME_UUID] = 1;
}
-
// .split property methods
// These methods get/set a specified message property:
@@ -425,7 +406,6 @@ kvmsg_get_prop (kvmsg_t *self, char *name)
return "";
}
-
// Set message property. Property name cannot contain '='. Max length of
// value is 255 chars.
void
View
6 examples/C/kvsimple.c
@@ -27,7 +27,6 @@ struct _kvmsg {
char key [KVMSG_KEY_MAX + 1];
};
-
// .split constructor and destructor
// Here are the constructor and destructor for the class:
@@ -71,7 +70,6 @@ kvmsg_destroy (kvmsg_t **self_p)
}
}
-
// .split recv method
// The recv method reads a key-value message from socket, and returns a new
// kvmsg instance:
@@ -103,7 +101,6 @@ kvmsg_recv (void *socket)
return self;
}
-
// .split send method
// The send method sends a multi-frame key-value message to a socket:
@@ -125,7 +122,6 @@ kvmsg_send (kvmsg_t *self, void *socket)
}
}
-
// .split key methods
// These methods let the caller get and set the message key, as a
// fixed string and as a printf formatted string:
@@ -174,7 +170,6 @@ kvmsg_fmt_key (kvmsg_t *self, char *format, ...)
kvmsg_set_key (self, value);
}
-
// .split sequence methods
// These two methods let the caller get and set the message sequence number:
@@ -260,7 +255,6 @@ kvmsg_fmt_body (kvmsg_t *self, char *format, ...)
kvmsg_set_body (self, (byte *) value, strlen (value));
}
-
// .split size method
// The size method returns the body size of the last-read message, if any:
View
1 examples/C/lbbroker3.c
@@ -66,7 +66,6 @@ typedef struct {
zlist_t *workers; // List of ready workers
} lbbroker_t;
-
// .split reactor design
// In the reactor design, each time a message arrives on a socket, the
// reactor passes it to a handler function. We have two handlers; one
View
4 examples/C/mdcliapi2.c
@@ -28,7 +28,6 @@ void s_mdcli_connect_to_broker (mdcli_t *self)
zclock_log ("I: connecting to broker at %s...", self->broker);
}
-
// The constructor and destructor are the same as in mdcliapi, except
// we don't do retries, so there's no retries property.
// .skip
@@ -50,7 +49,6 @@ mdcli_new (char *broker, int verbose)
return self;
}
-
// Destructor
void
@@ -66,7 +64,6 @@ mdcli_destroy (mdcli_t **self_p)
}
}
-
// Set request timeout
void
@@ -105,7 +102,6 @@ mdcli_send (mdcli_t *self, char *service, zmsg_t **request_p)
return 0;
}
-
// .skip
// The recv method waits for a reply message and returns that to the
// caller.
View
6 examples/C/mdwrkapi.c
@@ -30,7 +30,6 @@ struct _mdwrk_t {
zframe_t *reply_to; // Return identity, if any
};
-
// .split utility functions
// We have two utility functions; to send a message to the broker and
// to (re-)connect to the broker:
@@ -59,7 +58,6 @@ s_mdwrk_send_to_broker (mdwrk_t *self, char *command, char *option,
zmsg_send (&msg, self->worker);
}
-
// Connect or reconnect to broker
void s_mdwrk_connect_to_broker (mdwrk_t *self)
@@ -79,7 +77,6 @@ void s_mdwrk_connect_to_broker (mdwrk_t *self)
self->heartbeat_at = zclock_time () + self->heartbeat;
}
-
// .split constructor and destructor
// Here we have the constructor and destructor for our mdwrk class:
@@ -103,7 +100,6 @@ mdwrk_new (char *broker,char *service, int verbose)
return self;
}
-
// Destructor
void
@@ -120,7 +116,6 @@ mdwrk_destroy (mdwrk_t **self_p)
}
}
-
// .split configure worker
// We provide two methods to configure the worker API. You can set the
// heartbeat interval and retries to match the expected network performance.
@@ -133,7 +128,6 @@ mdwrk_set_heartbeat (mdwrk_t *self, int heartbeat)
self->heartbeat = heartbeat;
}
-
// Set reconnect delay
void
View
8 examples/C/peering3.c
@@ -104,7 +104,6 @@ int main (int argc, char *argv [])
{
// First argument is this broker's name
// Other arguments are our peers' names
- //
if (argc < 2) {
printf ("syntax: peering3 me {you}...\n");
return 0;
@@ -113,9 +112,8 @@ int main (int argc, char *argv [])
printf ("I: preparing broker at %s...\n", self);
srandom ((unsigned) time (NULL));
- zctx_t *ctx = zctx_new ();
-
// Prepare local frontend and backend
+ zctx_t *ctx = zctx_new ();
void *localfe = zsocket_new (ctx, ZMQ_ROUTER);
zsocket_bind (localfe, "ipc://%s-localfe.ipc", self);
@@ -191,9 +189,7 @@ int main (int argc, char *argv [])
// Track if capacity changes during this iteration
int previous = local_capacity;
-
- // Handle reply from local worker
- zmsg_t *msg = NULL;
+ zmsg_t *msg = NULL; // Reply from local worker
if (primary [0].revents & ZMQ_POLLIN) {
msg = zmsg_recv (localbe);
View
3 examples/C/titanic.c
@@ -93,7 +93,6 @@ titanic_request (void *args, zctx_t *ctx, void *pipe)
mdwrk_destroy (&worker);
}
-
// .split Titanic reply service
// The "titanic.reply" task checks if there's a reply for the specified
// request (by UUID), and returns a 200 OK, 300 Pending, or 400 Unknown
@@ -137,7 +136,6 @@ titanic_reply (void *context)
return 0;
}
-
// .split Titanic close task
// The "titanic.close" task removes any waiting replies for the request
// (specified by UUID). It's idempotent, so safe to call more than once
@@ -172,7 +170,6 @@ titanic_close (void *context)
return 0;
}
-
// .split worker task
// This is the main thread for the Titanic worker. It starts three child
// threads; for the request, reply, and close services. It then dispatches
View
3 examples/C/udplib.c
@@ -77,7 +77,6 @@ s_handle_io_error (char *reason)
}
}
-
// Constructor
static udp_t *
@@ -131,7 +130,6 @@ udp_new (int port_nbr)
return self;
}
-
// Destructor
static void
@@ -146,7 +144,6 @@ udp_destroy (udp_t **self_p)
}
}
-
// Returns UDP socket handle
static int

0 comments on commit 90b2c69

Please sign in to comment.