aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/src/misc/ei_x_encode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/erl_interface/src/misc/ei_x_encode.c')
-rw-r--r--lib/erl_interface/src/misc/ei_x_encode.c72
1 files changed, 52 insertions, 20 deletions
diff --git a/lib/erl_interface/src/misc/ei_x_encode.c b/lib/erl_interface/src/misc/ei_x_encode.c
index fa1e26ccbb..14d0b56b8f 100644
--- a/lib/erl_interface/src/misc/ei_x_encode.c
+++ b/lib/erl_interface/src/misc/ei_x_encode.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2001-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2001-2013. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -99,7 +99,8 @@ int ei_x_encode_string(ei_x_buff* x, const char* s)
int ei_x_encode_string_len(ei_x_buff* x, const char* s, int len)
{
int i = x->index;
- ei_encode_string_len(NULL, &i, s, len);
+ if (ei_encode_string_len(NULL, &i, s, len) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_string_len(x->buff, &x->index, s, len);
@@ -108,7 +109,8 @@ int ei_x_encode_string_len(ei_x_buff* x, const char* s, int len)
int ei_x_encode_binary(ei_x_buff* x, const void* p, int len)
{
int i = x->index;
- ei_encode_binary(NULL, &i, p, len);
+ if (ei_encode_binary(NULL, &i, p, len) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_binary(x->buff, &x->index, p, len);
@@ -117,7 +119,8 @@ int ei_x_encode_binary(ei_x_buff* x, const void* p, int len)
int ei_x_encode_long(ei_x_buff* x, long n)
{
int i = x->index;
- ei_encode_long(NULL, &i, n);
+ if (ei_encode_long(NULL, &i, n) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_long(x->buff, &x->index, n);
@@ -126,7 +129,8 @@ int ei_x_encode_long(ei_x_buff* x, long n)
int ei_x_encode_ulong(ei_x_buff* x, unsigned long n)
{
int i = x->index;
- ei_encode_ulong(NULL, &i, n);
+ if (ei_encode_ulong(NULL, &i, n) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_ulong(x->buff, &x->index, n);
@@ -135,7 +139,8 @@ int ei_x_encode_ulong(ei_x_buff* x, unsigned long n)
int ei_x_encode_char(ei_x_buff* x, char p)
{
int i = x->index;
- ei_encode_char(NULL, &i, p);
+ if (ei_encode_char(NULL, &i, p) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_char(x->buff, &x->index, p);
@@ -144,7 +149,8 @@ int ei_x_encode_char(ei_x_buff* x, char p)
int ei_x_encode_boolean(ei_x_buff* x, int p)
{
int i = x->index;
- ei_encode_boolean(NULL, &i, p);
+ if (ei_encode_boolean(NULL, &i, p) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_boolean(x->buff, &x->index, p);
@@ -153,7 +159,8 @@ int ei_x_encode_boolean(ei_x_buff* x, int p)
int ei_x_encode_double(ei_x_buff* x, double dbl)
{
int i = x->index;
- ei_encode_double(NULL, &i, dbl);
+ if (ei_encode_double(NULL, &i, dbl) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_double(x->buff, &x->index, dbl);
@@ -162,7 +169,8 @@ int ei_x_encode_double(ei_x_buff* x, double dbl)
int ei_x_encode_list_header(ei_x_buff* x, long n)
{
int i = x->index;
- ei_encode_list_header(NULL, &i, n);
+ if (ei_encode_list_header(NULL, &i, n) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_list_header(x->buff, &x->index, n);
@@ -171,7 +179,8 @@ int ei_x_encode_list_header(ei_x_buff* x, long n)
int ei_x_encode_empty_list(ei_x_buff* x)
{
int i = x->index;
- ei_encode_empty_list(NULL, &i);
+ if (ei_encode_empty_list(NULL, &i) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_empty_list(x->buff, &x->index);
@@ -180,7 +189,8 @@ int ei_x_encode_empty_list(ei_x_buff* x)
int ei_x_encode_version(ei_x_buff* x)
{
int i = x->index;
- ei_encode_version(NULL, &i);
+ if (ei_encode_version(NULL, &i) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_version(x->buff, &x->index);
@@ -189,7 +199,8 @@ int ei_x_encode_version(ei_x_buff* x)
int ei_x_encode_tuple_header(ei_x_buff* x, long n)
{
int i = x->index;
- ei_encode_tuple_header(NULL, &i, n);
+ if (ei_encode_tuple_header(NULL, &i, n) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_tuple_header(x->buff, &x->index, n);
@@ -197,22 +208,39 @@ int ei_x_encode_tuple_header(ei_x_buff* x, long n)
int ei_x_encode_atom(ei_x_buff* x, const char* s)
{
- return ei_x_encode_atom_len(x, s, strlen(s));
+ return ei_x_encode_atom_len_as(x, s, strlen(s), ERLANG_LATIN1, ERLANG_LATIN1);
}
int ei_x_encode_atom_len(ei_x_buff* x, const char* s, int len)
{
+ return ei_x_encode_atom_len_as(x, s, len, ERLANG_LATIN1, ERLANG_LATIN1);
+}
+
+int ei_x_encode_atom_as(ei_x_buff* x, const char* s,
+ erlang_char_encoding from_enc,
+ erlang_char_encoding to_enc)
+{
+ return ei_x_encode_atom_len_as(x, s, strlen(s), from_enc, to_enc);
+}
+
+int ei_x_encode_atom_len_as(ei_x_buff* x, const char* s, int len,
+ erlang_char_encoding from_enc,
+ erlang_char_encoding to_enc)
+{
int i = x->index;
- ei_encode_atom_len(NULL, &i, s, len);
+ if (ei_encode_atom_len_as(NULL, &i, s, len, from_enc, to_enc) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
- return ei_encode_atom_len(x->buff, &x->index, s, len);
+ return ei_encode_atom_len_as(x->buff, &x->index, s, len, from_enc, to_enc);
}
+
int ei_x_encode_pid(ei_x_buff* x, const erlang_pid* pid)
{
int i = x->index;
- ei_encode_pid(NULL, &i, pid);
+ if (ei_encode_pid(NULL, &i, pid) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_pid(x->buff, &x->index, pid);
@@ -221,7 +249,8 @@ int ei_x_encode_pid(ei_x_buff* x, const erlang_pid* pid)
int ei_x_encode_fun(ei_x_buff* x, const erlang_fun* fun)
{
int i = x->index;
- ei_encode_fun(NULL, &i, fun);
+ if (ei_encode_fun(NULL, &i, fun) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_fun(x->buff, &x->index, fun);
@@ -230,7 +259,8 @@ int ei_x_encode_fun(ei_x_buff* x, const erlang_fun* fun)
int ei_x_encode_ref(ei_x_buff* x, const erlang_ref* ref)
{
int i = x->index;
- ei_encode_ref(NULL, &i, ref);
+ if (ei_encode_ref(NULL, &i, ref) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_ref(x->buff, &x->index, ref);
@@ -239,7 +269,8 @@ int ei_x_encode_ref(ei_x_buff* x, const erlang_ref* ref)
int ei_x_encode_port(ei_x_buff* x, const erlang_port* port)
{
int i = x->index;
- ei_encode_port(NULL, &i, port);
+ if (ei_encode_port(NULL, &i, port) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_port(x->buff, &x->index, port);
@@ -248,7 +279,8 @@ int ei_x_encode_port(ei_x_buff* x, const erlang_port* port)
int ei_x_encode_trace(ei_x_buff* x, const erlang_trace* trace)
{
int i = x->index;
- ei_encode_trace(NULL, &i, trace);
+ if (ei_encode_trace(NULL, &i, trace) == -1)
+ return -1;
if (!x_fix_buff(x, i))
return -1;
return ei_encode_trace(x->buff, &x->index, trace);