Module: kamailio
Branch: master
Commit: 3d002d8f42eb24e978bc86cd3b4565872e65eb1e
URL:
https://github.com/kamailio/kamailio/commit/3d002d8f42eb24e978bc86cd3b45658…
Author: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic(a)gmail.com>
Date: 2016-04-26T15:55:30+02:00
erlang: extend error message function with variable number of arguments
- wrap around vsnprintf
---
Modified: modules/erlang/handle_emsg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3d002d8f42eb24e978bc86cd3b45658…
Patch:
https://github.com/kamailio/kamailio/commit/3d002d8f42eb24e978bc86cd3b45658…
---
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);
}