[sr-dev] git:4.3:abf6abc9: erlang: extend error message function with variable number of arguments
Seudin Kasumovic
seudin.kasumovic at gmail.com
Tue Apr 26 16:00:44 CEST 2016
Module: kamailio
Branch: 4.3
Commit: abf6abc91a8d5d95ab25e9797202f8a8a31abc1a
URL: https://github.com/kamailio/kamailio/commit/abf6abc91a8d5d95ab25e9797202f8a8a31abc1a
Author: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Date: 2016-04-26T16:00:07+02:00
erlang: extend error message function with variable number of arguments
- wrap around vsnprintf
(cherry picked from commit 3d002d8f42eb24e978bc86cd3b4565872e65eb1e)
---
Modified: modules/erlang/handle_emsg.c
---
Diff: https://github.com/kamailio/kamailio/commit/abf6abc91a8d5d95ab25e9797202f8a8a31abc1a.diff
Patch: https://github.com/kamailio/kamailio/commit/abf6abc91a8d5d95ab25e9797202f8a8a31abc1a.patch
---
diff --git a/modules/erlang/handle_emsg.c b/modules/erlang/handle_emsg.c
index 0d03d97..4dbb0a2 100644
--- a/modules/erlang/handle_emsg.c
+++ b/modules/erlang/handle_emsg.c
@@ -22,6 +22,7 @@
*/
#include <stdio.h>
+#include <stdarg.h>
#include <string.h>
#include <ei.h>
@@ -43,7 +44,7 @@ int handle_req_ref_tuple(cnode_handler_t *phandler, erlang_msg * msg);
int handle_rpc_response(cnode_handler_t *phandler, erlang_msg * msg, int arity);
int handle_rex_call(cnode_handler_t *phandler,erlang_ref_ex_t *ref, erlang_pid *pid);
int handle_net_kernel(cnode_handler_t *phandler, erlang_msg * msg);
-void encode_error_msg(ei_x_buff *response, erlang_ref_ex_t *ref, const char *type, const char *msg );
+void encode_error_msg(ei_x_buff *response, erlang_ref_ex_t *ref, const char *type, const char *msg, ...);
int handle_reg_send(cnode_handler_t *phandler, erlang_msg * msg)
{
@@ -826,8 +827,16 @@ int handle_erlang_msg(cnode_handler_t *phandler, erlang_msg * msg)
return 0;
}
-void encode_error_msg(ei_x_buff *response, erlang_ref_ex_t *ref, const char *type, const char *msg )
+void encode_error_msg(ei_x_buff *response, erlang_ref_ex_t *ref, const char *type, const char *msg, ... )
{
+ char buffer[256];
+ va_list args;
+ va_start (args, msg);
+
+ vsnprintf (buffer, 255, msg, args);
+
+ va_end (args);
+
ei_x_encode_tuple_header(response, 2);
if (ref->with_node)
@@ -842,5 +851,5 @@ void encode_error_msg(ei_x_buff *response, erlang_ref_ex_t *ref, const char *typ
ei_x_encode_tuple_header(response,2);
ei_x_encode_atom(response, type);
- ei_x_encode_string(response, msg);
+ ei_x_encode_string(response, buffer);
}
More information about the sr-dev
mailing list