Permalink
Browse files

Added zmsg_append method

  • Loading branch information...
hintjens committed Mar 1, 2011
1 parent 7dc2fd6 commit 32c9e6d3f89e08a9f9e5f1697c1d533e3b5444f5
Showing with 20 additions and 2 deletions.
  1. +20 −2 examples/C/zmsg.c
View
@@ -1,5 +1,5 @@
/* =========================================================================
- zmsg.h
+ zmsg.c
Multipart message class for example applications.
@@ -59,6 +59,9 @@ void zmsg_body_fmt (zmsg_t *self, char *format, ...);
void zmsg_push (zmsg_t *self, char *part);
char *zmsg_pop (zmsg_t *self);
+// Generic append message part to end
+void zmsg_append (zmsg_t *self, char *part);
+
// Read and set message envelopes
char *zmsg_address (zmsg_t *self);
void zmsg_wrap (zmsg_t *self, char *address, char *delim);
@@ -381,7 +384,7 @@ zmsg_push (zmsg_t *self, char *part)
memmove (&self->_part_size [1], &self->_part_size [0],
(ZMSG_MAX_PARTS - 1) * sizeof (size_t));
s_set_part (self, 0, (void *) part, strlen (part));
- self->_part_count += 1;
+ self->_part_count++;
}
@@ -406,6 +409,21 @@ zmsg_pop (zmsg_t *self)
}
+// --------------------------------------------------------------------------
+// Append message part to end of message parts
+
+void
+zmsg_append (zmsg_t *self, char *part)
+{
+ assert (self);
+ assert (part);
+ assert (self->_part_count < ZMSG_MAX_PARTS - 1);
+
+ s_set_part (self, self->_part_count - 1, (void *) part, strlen (part));
+ self->_part_count++;
+}
+
+
// --------------------------------------------------------------------------
// Return pointer to outer message address, if any
// Caller should not modify the provided data

0 comments on commit 32c9e6d

Please sign in to comment.