changeset 423:6727fec3c326

Rename nn_conn_send_msg() to nn_conn_send_msg_v() and add new nn_conn_send_msg().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 24 May 2012 11:09:48 +0300
parents 8eb2839a565c
children aeb24b1b5e77
files network.c network.h
diffstat 2 files changed, 20 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/network.c	Thu May 24 08:11:34 2012 +0300
+++ b/network.c	Thu May 24 11:09:48 2012 +0300
@@ -519,20 +519,14 @@
 }
 
 
-BOOL nn_conn_send_msg(nn_conn_t *conn, const char *user, const char *fmt, ...)
+BOOL nn_conn_send_msg(nn_conn_t *conn, const char *user, const char *str)
 {
-    char *tmp, *msg;
-    va_list ap;
+    char *msg;
 
-    va_start(ap, fmt);
-    tmp = th_strdup_vprintf(fmt, ap);
-    va_end(ap);
-
-    if (tmp == NULL)
+    if (str == NULL)
         return FALSE;
-
-    msg = th_strdup_printf("<USER>%s</USER><MESSAGE>%s</MESSAGE>", user, tmp);
-    th_free(tmp);
+    
+    msg = th_strdup_printf("<USER>%s</USER><MESSAGE>%s</MESSAGE>", user, str);
 
     if (msg != NULL)
     {
@@ -543,3 +537,16 @@
     else
         return FALSE;
 }
+
+
+BOOL nn_conn_send_msg_v(nn_conn_t *conn, const char *user, const char *fmt, ...)
+{
+    char *tmp;
+    va_list ap;
+
+    va_start(ap, fmt);
+    tmp = th_strdup_vprintf(fmt, ap);
+    va_end(ap);
+
+    return nn_conn_send_msg(conn, user, tmp);
+}
--- a/network.h	Thu May 24 08:11:34 2012 +0300
+++ b/network.h	Thu May 24 11:09:48 2012 +0300
@@ -116,7 +116,8 @@
 void        nn_conn_reset(nn_conn_t *);
 int         nn_conn_pull(nn_conn_t *);
 BOOL        nn_conn_send_buf(nn_conn_t *, const char *buf, const size_t len);
-BOOL        nn_conn_send_msg(nn_conn_t *, const char *user, const char *fmt, ...);
+BOOL        nn_conn_send_msg(nn_conn_t *, const char *user, const char *str);
+BOOL        nn_conn_send_msg_v(nn_conn_t *, const char *user, const char *fmt, ...);
 BOOL        nn_conn_check(nn_conn_t *);