aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ic/c_src
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/ic/c_src
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/ic/c_src')
-rw-r--r--lib/ic/c_src/Makefile24
-rw-r--r--lib/ic/c_src/Makefile.in160
-rw-r--r--lib/ic/c_src/Makefile.win32108
-rw-r--r--lib/ic/c_src/ic.c612
-rw-r--r--lib/ic/c_src/ic_tmo.c135
-rw-r--r--lib/ic/c_src/oe_ei_code_erlang_binary.c105
-rw-r--r--lib/ic/c_src/oe_ei_decode_longlong.c25
-rw-r--r--lib/ic/c_src/oe_ei_decode_ulonglong.c25
-rw-r--r--lib/ic/c_src/oe_ei_decode_wchar.c25
-rw-r--r--lib/ic/c_src/oe_ei_decode_wstring.c107
-rw-r--r--lib/ic/c_src/oe_ei_encode_atom.c46
-rw-r--r--lib/ic/c_src/oe_ei_encode_char.c44
-rw-r--r--lib/ic/c_src/oe_ei_encode_double.c43
-rw-r--r--lib/ic/c_src/oe_ei_encode_list_header.c41
-rw-r--r--lib/ic/c_src/oe_ei_encode_long.c44
-rw-r--r--lib/ic/c_src/oe_ei_encode_longlong.c44
-rw-r--r--lib/ic/c_src/oe_ei_encode_pid.c45
-rw-r--r--lib/ic/c_src/oe_ei_encode_port.c46
-rw-r--r--lib/ic/c_src/oe_ei_encode_ref.c46
-rw-r--r--lib/ic/c_src/oe_ei_encode_string.c47
-rw-r--r--lib/ic/c_src/oe_ei_encode_term.c48
-rw-r--r--lib/ic/c_src/oe_ei_encode_tuple_header.c44
-rw-r--r--lib/ic/c_src/oe_ei_encode_ulong.c43
-rw-r--r--lib/ic/c_src/oe_ei_encode_ulonglong.c44
-rw-r--r--lib/ic/c_src/oe_ei_encode_version.c42
-rw-r--r--lib/ic/c_src/oe_ei_encode_wchar.c27
-rw-r--r--lib/ic/c_src/oe_ei_encode_wstring.c62
27 files changed, 2082 insertions, 0 deletions
diff --git a/lib/ic/c_src/Makefile b/lib/ic/c_src/Makefile
new file mode 100644
index 0000000000..8256edda64
--- /dev/null
+++ b/lib/ic/c_src/Makefile
@@ -0,0 +1,24 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1998-2009. 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
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+#
+#
+# Invoke with GNU make or clearmake -C gnu.
+#
+
+include $(ERL_TOP)/make/run_make.mk
diff --git a/lib/ic/c_src/Makefile.in b/lib/ic/c_src/Makefile.in
new file mode 100644
index 0000000000..6eef7827b9
--- /dev/null
+++ b/lib/ic/c_src/Makefile.in
@@ -0,0 +1,160 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1998-2009. 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
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+#
+include $(ERL_TOP)/make/target.mk
+include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+CC = @CC@
+LIBS = @LIBS@
+
+LIBDIR = ../priv/lib/$(TARGET)
+OBJDIR = ../priv/obj/$(TARGET)
+INCDIR = ../include
+ERL_INTERFACE_FLAGS = \
+ -I$(ERL_TOP)/lib/erl_interface/include \
+ -I$(ERL_TOP)/lib/erl_interface/src
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+include ../vsn.mk
+VSN=$(IC_VSN)
+
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)/lib/ic-$(VSN)
+
+# ----------------------------------------------------
+# File Specs
+# ----------------------------------------------------
+
+IDL_FILES = \
+ $(INCDIR)/erlang.idl
+
+ifeq ($(findstring win32,$(TARGET)),win32)
+USING_MINGW=@MIXED_CYGWIN_MINGW@
+ifeq ($(USING_MINGW),yes)
+AR_OUT = rcv
+CC_FLAGS =
+LIBRARY = $(LIBDIR)/libic.a
+SKIP_BUILDING_BINARIES := false
+else
+LIBRARY = $(LIBDIR)/ic.lib
+AR_OUT = -out:
+CC_FLAGS = -MT
+endif
+ifeq ($(HOST_OS),)
+HOST_OS := $(shell $(ERL_TOP)/erts/autoconf/config.guess)
+endif
+ifeq ($(findstring solaris,$(HOST_OS)),solaris)
+SKIP_BUILDING_BINARIES := true
+endif
+else
+AR_OUT = rcv
+CC_FLAGS = @DED_CFLAGS@
+LIBRARY = $(LIBDIR)/libic.a
+SKIP_BUILDING_BINARIES := false
+endif
+
+C_FILES = \
+ ic.c \
+ ic_tmo.c \
+ oe_ei_encode_version.c \
+ oe_ei_encode_long.c \
+ oe_ei_encode_ulong.c \
+ oe_ei_encode_double.c \
+ oe_ei_encode_char.c \
+ oe_ei_encode_string.c \
+ oe_ei_encode_atom.c \
+ oe_ei_encode_pid.c \
+ oe_ei_encode_port.c \
+ oe_ei_encode_ref.c \
+ oe_ei_encode_term.c \
+ oe_ei_encode_tuple_header.c \
+ oe_ei_encode_list_header.c \
+ oe_ei_encode_longlong.c \
+ oe_ei_encode_ulonglong.c \
+ oe_ei_encode_wchar.c \
+ oe_ei_encode_wstring.c \
+ oe_ei_decode_longlong.c \
+ oe_ei_decode_ulonglong.c \
+ oe_ei_decode_wchar.c \
+ oe_ei_decode_wstring.c \
+ oe_ei_code_erlang_binary.c
+
+H_FILES = $(INCDIR)/ic.h
+
+OBJ_FILES= $(C_FILES:%.c=$(OBJDIR)/%.o)
+
+ALL_CFLAGS = @CFLAGS@ @DEFS@ -I$(INCDIR) $(ERL_INTERFACE_FLAGS) $(CFLAGS)
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+ifeq ($(SKIP_BUILDING_BINARIES), true)
+debug opt:
+else
+debug opt: $(LIBRARY)
+endif
+
+clean:
+ rm -f $(LIBRARY) $(OBJ_FILES)
+ rm -f core *~
+
+docs:
+
+# ----------------------------------------------------
+# Special Build Targets
+# ----------------------------------------------------
+
+$(OBJDIR):
+ -mkdir -p $(OBJDIR)
+
+$(LIBDIR):
+ -mkdir -p $(LIBDIR)
+
+$(LIBRARY): $(OBJDIR) $(LIBDIR) $(OBJ_FILES)
+ -$(AR) $(AR_OUT) $@ $(OBJ_FILES)
+ -$(RANLIB) $@
+
+$(OBJDIR)/%.o: %.c
+ $(CC) $(CC_FLAGS) -c -o $@ $(ALL_CFLAGS) $<
+
+# ----------------------------------------------------
+# Release Target
+# ----------------------------------------------------
+include $(ERL_TOP)/make/otp_release_targets.mk
+
+release_spec: opt
+ $(INSTALL_DIR) $(RELSYSDIR)/c_src
+ $(INSTALL_DIR) $(RELSYSDIR)/include
+ $(INSTALL_DIR) $(RELSYSDIR)/priv/lib
+ $(INSTALL_DATA) ic.c ic_tmo.c $(RELSYSDIR)/c_src
+ $(INSTALL_DATA) $(IDL_FILES) $(H_FILES) $(RELSYSDIR)/include
+ $(INSTALL_DATA) $(LIBRARY) $(RELSYSDIR)/priv/lib
+
+release_docs_spec:
+
+
+
+
+
+
diff --git a/lib/ic/c_src/Makefile.win32 b/lib/ic/c_src/Makefile.win32
new file mode 100644
index 0000000000..d782555788
--- /dev/null
+++ b/lib/ic/c_src/Makefile.win32
@@ -0,0 +1,108 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1999-2009. 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
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+#
+
+CC = cl.exe
+LIBRARIAN = lib.exe /nologo
+
+IC_INCLUDE = ..\include
+EI_INCLUDE = \erts\lib\erl_interface\src
+
+CFLAGS = /MT /nologo /Ox /I$(IC_INCLUDE) /I$(EI_INCLUDE)
+TARGET = win32
+OBJDIR = ..\priv\obj\$(TARGET)
+LIBDIR = ..\priv\lib\$(TARGET)
+
+
+C_FILES = \
+ ic.c \
+ oe_ei_encode_version.c \
+ oe_ei_encode_long.c \
+ oe_ei_encode_ulong.c \
+ oe_ei_encode_double.c \
+ oe_ei_encode_char.c \
+ oe_ei_encode_string.c \
+ oe_ei_encode_atom.c \
+ oe_ei_encode_pid.c \
+ oe_ei_encode_port.c \
+ oe_ei_encode_ref.c \
+ oe_ei_encode_term.c \
+ oe_ei_encode_tuple_header.c \
+ oe_ei_encode_list_header.c \
+ oe_ei_encode_longlong.c \
+ oe_ei_encode_ulonglong.c \
+ oe_ei_encode_wchar.c \
+ oe_ei_encode_wstring.c \
+ oe_ei_decode_longlong.c \
+ oe_ei_decode_ulonglong.c \
+ oe_ei_decode_wchar.c \
+ oe_ei_decode_wstring.c
+
+OBJ_FILES = \
+ $(OBJDIR)\ic.obj \
+ $(OBJDIR)\oe_ei_encode_version.obj \
+ $(OBJDIR)\oe_ei_encode_long.obj \
+ $(OBJDIR)\oe_ei_encode_ulong.obj \
+ $(OBJDIR)\oe_ei_encode_double.obj \
+ $(OBJDIR)\oe_ei_encode_char.obj \
+ $(OBJDIR)\oe_ei_encode_string.obj \
+ $(OBJDIR)\oe_ei_encode_atom.obj \
+ $(OBJDIR)\oe_ei_encode_pid.obj \
+ $(OBJDIR)\oe_ei_encode_port.obj \
+ $(OBJDIR)\oe_ei_encode_ref.obj \
+ $(OBJDIR)\oe_ei_encode_term.obj \
+ $(OBJDIR)\oe_ei_encode_tuple_header.obj \
+ $(OBJDIR)\oe_ei_encode_list_header.obj \
+ $(OBJDIR)\oe_ei_encode_longlong.obj \
+ $(OBJDIR)\oe_ei_encode_ulonglong.obj \
+ $(OBJDIR)\oe_ei_encode_wchar.obj \
+ $(OBJDIR)\oe_ei_encode_wstring.obj \
+ $(OBJDIR)\oe_ei_decode_longlong.obj \
+ $(OBJDIR)\oe_ei_decode_ulonglong.obj \
+ $(OBJDIR)\oe_ei_decode_wchar.obj \
+ $(OBJDIR)\oe_ei_decode_wstring.obj
+
+
+LIBRARY = $(LIBDIR)\ic.lib
+
+
+all: $(OBJDIR) $(LIBDIR) $(LIBRARY)
+
+release:
+ echo "Nothing to do"
+
+clean:
+ -del $(OBJ_FILES) $(LIBRARY)
+
+$(LIBRARY): $(OBJ_FILES)
+ $(LIBRARIAN) /OUT:$@ $**
+
+{}.c{$(OBJDIR)}.obj:
+ $(CC) $(CFLAGS) /c /Fo$@ $<
+
+$(OBJDIR):
+ -mkdir $(OBJDIR)
+
+$(LIBDIR):
+ -mkdir $(LIBDIR)
+
+$(LIBRARY):
+
+
+{}.c: $(EI_INCLUDE)\ei.h $(IC_INCLUDE)\ic.
diff --git a/lib/ic/c_src/ic.c b/lib/ic/c_src/ic.c
new file mode 100644
index 0000000000..1ace9ea1af
--- /dev/null
+++ b/lib/ic/c_src/ic.c
@@ -0,0 +1,612 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+static int oe_send(CORBA_Environment *env);
+
+void CORBA_free(void *p)
+{
+ if (p != NULL)
+ free(p);
+}
+
+
+CORBA_char *CORBA_string_alloc(CORBA_unsigned_long len)
+{
+ return (CORBA_char *) malloc(len+1);
+}
+
+
+CORBA_wchar *CORBA_wstring_alloc(CORBA_unsigned_long len)
+{
+ return (CORBA_wchar *) malloc(len*(__OE_WCHAR_SIZE_OF__+1));
+}
+
+
+CORBA_Environment *CORBA_Environment_alloc(int inbufsz, int outbufsz)
+{
+ CORBA_Environment *env;
+
+ env = malloc(sizeof(CORBA_Environment));
+
+ if (env != NULL) {
+
+ /* CORBA */
+ env->_major = CORBA_NO_EXCEPTION;
+
+ /* Set by user */
+ env->_fd= -1;
+ env->_inbufsz = inbufsz;
+ env->_inbuf = malloc(inbufsz);
+ env->_outbufsz = outbufsz;
+ env->_outbuf = malloc(outbufsz);
+ env->_memchunk = __OE_MEMCHUNK__;
+ env->_regname[0] = '\0';
+ env->_to_pid = NULL;
+ env->_from_pid = NULL;
+
+ /* Set by client or server */
+ env->_iin = 0;
+ env->_iout = 0;
+ env->_operation[0] = '\0';
+ env->_received = 0;
+ /* env->_caller */
+ /* env->_unique */
+ env->_exc_id = NULL;
+ env->_exc_value = NULL;
+ env->_ref_counter_1 = 0;
+ env->_ref_counter_2 = 0;
+ env->_ref_counter_3 = 0;
+ }
+
+ return env;
+}
+
+#if 0
+/* NOT EXPORTED SO FAR */
+void CORBA_Environment_free(CORBA_Environment *env)
+{
+
+ CORBA_free(env->_inbuf);
+ CORBA_free(env->_outbuf);
+ CORBA_exception_free(env);
+ CORBA_free(env);
+}
+#endif
+
+
+CORBA_char *CORBA_exception_id(CORBA_Environment *env)
+{
+
+ return env->_exc_id;
+}
+
+void *CORBA_exception_value(CORBA_Environment *env)
+{
+
+ return env->_exc_value;
+}
+
+void CORBA_exception_free(CORBA_Environment *env)
+{
+
+ /* Setting major value */
+ env->_major=CORBA_NO_EXCEPTION;
+
+ /* Freeing storage */
+ CORBA_free(env->_exc_id);
+ CORBA_free(env->_exc_value);
+ env->_exc_id = env->_exc_value = NULL;
+}
+
+void CORBA_exc_set(CORBA_Environment *env,
+ CORBA_exception_type Major,
+ CORBA_char *Id,
+ CORBA_char *Value)
+{
+ int ilen,vlen;
+
+ /* Create exception only if exception not already set */
+ if (env->_major == CORBA_NO_EXCEPTION) {
+
+ /* Counting lengths */
+ ilen = strlen(Id)+1;
+ vlen = strlen(Value)+1;
+
+ /* Allocating storage */
+ env->_exc_id = (CORBA_char *) malloc(ilen);
+ env->_exc_value = (CORBA_char *) malloc(vlen);
+
+ /* Initiating */
+ env->_major = Major;
+ strcpy(env->_exc_id,Id);
+ strcpy(env->_exc_value,Value);
+ }
+}
+
+#define ERLANG_REF_NUM_SIZE 18
+#define ERLANG_REF_MASK (~(~((unsigned int)0) << ERLANG_REF_NUM_SIZE))
+
+/* Initiating message reference */
+void ic_init_ref(CORBA_Environment *env, erlang_ref *ref)
+{
+
+ strcpy(ref->node, erl_thisnodename());
+
+ ref->len = 3;
+
+ ++env->_ref_counter_1;
+ env->_ref_counter_1 &= ERLANG_REF_MASK;
+ if (env->_ref_counter_1 == 0)
+ if (++env->_ref_counter_2 == 0)
+ ++env->_ref_counter_3;
+ ref->n[0] = env->_ref_counter_1;
+ ref->n[1] = env->_ref_counter_2;
+ ref->n[2] = env->_ref_counter_3;
+
+ ref->creation = erl_thiscreation();
+}
+
+/* Comparing message references */
+int ic_compare_refs(erlang_ref *ref1, erlang_ref *ref2)
+{
+ int i;
+
+ if(strcmp(ref1->node, ref2->node) != 0)
+ return -1;
+
+ if (ref1->len != ref2->len)
+ return -1;
+
+ for (i = 0; i < ref1->len; i++)
+ if (ref1->n[i] != ref2->n[i])
+ return -1;
+
+ return 0;
+}
+
+/* Length counter for wide strings */
+int ic_wstrlen(CORBA_wchar * p)
+{
+ int len = 0;
+
+ while(1) {
+ if (p[len] == 0)
+ return len;
+
+ len+=1;
+ }
+}
+
+
+/* Wide string compare function */
+int ic_wstrcmp(CORBA_wchar * ws1, CORBA_wchar * ws2)
+{
+ int index = 0;
+
+ while(1) {
+ if (ws1[index] == ws2[index]) {
+
+ if (ws1[index] == 0)
+ return 0;
+
+ index += 1;
+
+ } else
+ return -1;
+ }
+}
+
+/* For backward compatibility -- replaced by prepare_request_decoding() */
+int ___call_info___(CORBA_Object obj, CORBA_Environment *env)
+{
+ return oe_prepare_request_decoding(env);
+}
+
+/* #define DEBUG_MAP */
+
+#if defined(DEBUG_MAP)
+
+#define PRINT_MAPS(P, M, S) print_maps(P, M, S)
+#define PRINT_MAP(T, M) print_map(T, "", M)
+
+static void print_map(char *title, char *prefix, oe_map_t *map)
+{
+ if (map == NULL) {
+ fprintf(stdout, "%s => NULL\n", title);
+ return;
+ }
+
+ fprintf(stdout, "%s%s\n", prefix, title);
+
+ {
+ int j, len = map->length;
+
+ fprintf(stdout, "%s length: %d\n", prefix, len);
+ fprintf(stdout, "%s operations: 0x%X%d\n", prefix, map->operations);
+
+ for (j = 0 ; j < len ; j++) {
+ fprintf(stdout, "%s operation[%d]:\n", prefix, j);
+
+ if (map->operations[j].interface != NULL) {
+ fprintf(stdout, "%s intf: %s\n", prefix,
+ map->operations[j].interface);
+ } else {
+ fprintf(stdout, "%s intf: NULL\n", prefix);
+ }
+ fprintf(stdout, "%s name: %s\n", prefix,
+ map->operations[j].name);
+ fprintf(stdout, "%s func: 0x%X\n", prefix,
+ map->operations[j].function);
+ }
+ }
+ fflush(stdout);
+}
+
+static void print_maps(char* title, oe_map_t * maps, int size)
+{
+ int i;
+ char p[64];
+
+ fprintf(stdout, "%s\n", title);
+
+ for (i = 0 ; i < size ; i++) {
+ sprintf(p, "map[%d]:", i);
+ print_map(p, " ", &maps[i]);
+ }
+ fprintf(stdout, "\n");
+ fflush(stdout);
+}
+
+#else
+
+#define PRINT_MAPS(P, M, S)
+#define PRINT_MAP(T, M)
+
+#endif /* if defined(DEBUG_MAP) */
+
+
+/* Generic server switch */
+int oe_exec_switch(CORBA_Object obj, CORBA_Environment *env, oe_map_t *map)
+{
+ /* Setting local variables */
+ int res = 0;
+ int index = 0;
+
+ /* XXX map may be NULL !! */
+ int length = map->length;
+ char* op = env->_operation;
+
+ PRINT_MAP("switching on map", map);
+
+ /* Initiating exception indicator */
+ env->_major = CORBA_NO_EXCEPTION;
+
+ if ((res = oe_prepare_request_decoding(env) < 0))
+ return res;
+#if defined(DEBUG_MAP)
+ fprintf(stdout, "looking for operation: %s\n", op); fflush(stdout);
+#endif
+ for (index = 0; index < length; index++) {
+#if defined(DEBUG_MAP)
+ fprintf(stdout, "map->operations[%d].name: %s\n",
+ index, map->operations[index].name);
+ fflush(stdout);
+#endif
+ if(strcmp(map->operations[index].name, op) == 0) {
+#if defined(DEBUG_MAP)
+ fprintf(stdout, "calling map->operations[%d].function: 0x%X\n",
+ index, map->operations[index].function);
+ fflush(stdout);
+#endif
+ return map->operations[index].function(obj, env);
+ }
+ }
+ /* Bad call */
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, BAD_OPERATION,
+ "Invalid operation");
+ return -1;
+}
+
+/* For backward compatibility */
+int ___switch___(CORBA_Object obj, CORBA_Environment *env, oe_map_t *map)
+{
+ return oe_exec_switch(obj, env, map);
+}
+
+
+oe_map_t* oe_merge_maps(oe_map_t *maps, int size)
+{
+ int i, j, length, len, maplen, malloc_size;
+ void *memp;
+ oe_map_t *merged;
+
+ if ((maps == NULL) || (size <= 0))
+ return NULL;
+
+ PRINT_MAPS("merging maps", maps, size);
+
+ length = 0;
+ for (i = 0; i < size; i++)
+ length += (maps[i].length);
+
+ maplen = OE_ALIGN(sizeof(oe_map_t));
+ malloc_size = maplen + OE_ALIGN(length*sizeof(oe_operation_t));
+ if ((memp = malloc(malloc_size)) == NULL)
+ return NULL;
+
+ merged = memp;
+ merged->length = length;
+ merged->operations = (oe_operation_t *)((char*)memp + maplen);
+
+ for (i = 0, len = 0; i < size; i++) {
+ for(j = 0 ; j < maps[i].length; j++)
+ merged->operations[len+j] = maps[i].operations[j];
+ len += maps[i].length;
+ }
+ PRINT_MAP("merged map", merged);
+ return merged;
+}
+
+/* For backward compatibility */
+oe_map_t* ___merge___(oe_map_t *maps, int size)
+{
+ return oe_merge_maps(maps, size);
+}
+
+/* Client send message (Erlang distribution protocol) */
+static int oe_send(CORBA_Environment *env)
+{
+ if (strlen(env->_regname) == 0) {
+ if (ei_send_encoded(env->_fd, env->_to_pid, env->_outbuf,
+ env->_iout) < 0) {
+ /* XXX Cannot send to peer? */
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, NO_RESPONSE,
+ "Cannot connect to server");
+ return -1;
+ }
+ } else {
+ if (ei_send_reg_encoded(env->_fd, env->_from_pid,
+ env->_regname, env->_outbuf,
+ env->_iout) < 0) {
+ /* XXX Cannot send to peer? */
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, NO_RESPONSE,
+ "Cannot connect to server");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/* Send notification (gen_server client) */
+int oe_send_notification(CORBA_Environment *env)
+{
+ return oe_send(env);
+}
+
+/* Send request and receive reply (gen_server client) */
+int oe_send_request_and_receive_reply(CORBA_Environment *env)
+{
+ int msgType = 0;
+ erlang_msg msg;
+
+ if (oe_send(env) < 0)
+ return -1;
+
+ do {
+ if ((msgType = ei_receive_encoded(env->_fd,
+ &env->_inbuf,
+ &env->_inbufsz,
+ &msg, &env->_iin)) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL,
+ "Cannot decode message");
+ return -1;
+ }
+ } while (msgType != ERL_SEND && msgType != ERL_REG_SEND);
+
+ /* Extracting return message header */
+ if (oe_prepare_reply_decoding(env) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL, "Bad message");
+ return -1;
+ }
+ return 0;
+}
+
+/* Prepare notification encoding (gen_server client) */
+int oe_prepare_notification_encoding(CORBA_Environment *env)
+{
+ env->_iout = 0;
+ oe_ei_encode_version(env);
+ oe_ei_encode_tuple_header(env, 2);
+ oe_ei_encode_atom(env, "$gen_cast");
+ return 0;
+}
+
+/* Prepare request encoding (gen_server client) */
+int oe_prepare_request_encoding(CORBA_Environment *env)
+{
+ int error = 0;
+
+ env->_iout = 0;
+ oe_ei_encode_version(env);
+ oe_ei_encode_tuple_header(env, 3);
+ oe_ei_encode_atom(env, "$gen_call");
+ oe_ei_encode_tuple_header(env, 2);
+ if ((error = oe_ei_encode_pid(env, env->_from_pid)) < 0)
+ return error;
+ if ((error = oe_ei_encode_ref(env, &env->_unique)) < 0)
+ return error;
+ return 0;
+}
+
+/* Prepare reply decoding (gen_server client) */
+int oe_prepare_reply_decoding(CORBA_Environment *env)
+{
+ int error = 0;
+ int version = 0;
+ erlang_ref unique;
+
+ env->_iin = 0;
+ env->_received = 0;
+
+ if ((error = ei_decode_version(env->_inbuf,
+ &env->_iin,
+ &version)) < 0)
+ return error;
+ if ((error = ei_decode_tuple_header(env->_inbuf,
+ &env->_iin,
+ &env->_received)) < 0)
+ return error;
+ if ((error = ei_decode_ref(env->_inbuf,
+ &env->_iin,
+ &unique)) < 0)
+ return error;
+ return ic_compare_refs(&env->_unique, &unique);
+}
+
+
+/* Prepare request decoding (gen_server server) */
+int oe_prepare_request_decoding(CORBA_Environment *env)
+{
+ char gencall_atom[10];
+ int error = 0;
+ int version = 0;
+
+ env->_iin = 0;
+ env->_received = 0;
+ memset(gencall_atom, 0, 10);
+ ei_decode_version(env->_inbuf, &env->_iin, &version);
+ ei_decode_tuple_header(env->_inbuf, &env->_iin, &env->_received);
+ ei_decode_atom(env->_inbuf, &env->_iin, gencall_atom);
+
+ if (strcmp(gencall_atom, "$gen_cast") == 0) {
+ if ((error = ei_decode_atom(env->_inbuf, &env->_iin,
+ env->_operation)) < 0) {
+ ei_decode_tuple_header(env->_inbuf, &env->_iin, &env->_received);
+ if ((error = ei_decode_atom(env->_inbuf, &env->_iin,
+ env->_operation)) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, BAD_OPERATION,
+ "Bad Message, cannot extract operation");
+ return error;
+ }
+ env->_received -= 1;
+ } else
+ env->_received -= 2;
+ return 0;
+ }
+ if (strcmp(gencall_atom, "$gen_call") == 0) {
+ ei_decode_tuple_header(env->_inbuf, &env->_iin, &env->_received);
+ if ((error = ei_decode_pid(env->_inbuf, &env->_iin,
+ &env->_caller)) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL,
+ "Bad Message, bad caller identity");
+ return error;
+ }
+ if ((error = ei_decode_ref(env->_inbuf, &env->_iin,
+ &env->_unique)) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL,
+ "Bad Message, bad message reference");
+ return error;
+ }
+ if ((error = ei_decode_atom(env->_inbuf, &env->_iin,
+ env->_operation)) < 0) {
+
+ ei_decode_tuple_header(env->_inbuf, &env->_iin, &env->_received);
+
+ if ((error = ei_decode_atom(env->_inbuf, &env->_iin,
+ env->_operation)) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, BAD_OPERATION,
+ "Bad Message, cannot extract operation");
+ return error;
+ }
+ env->_received -= 1;
+ return 0;
+ }
+ else {
+ env->_received -= 2;
+ return 0;
+ }
+ }
+
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL,
+ "Bad message, neither cast nor call");
+ return -1;
+}
+
+/* Prepare reply encoding (gen_server server) */
+int oe_prepare_reply_encoding(CORBA_Environment *env)
+{
+ env->_iout = 0;
+ oe_ei_encode_version(env);
+ oe_ei_encode_tuple_header(env, 2);
+ oe_ei_encode_ref(env, &env->_unique);
+ return 0;
+}
+
+/* ---- Function for making it more easy to implement a server */
+/* Server receive (possibly) send reply (gen_server server) */
+
+int oe_server_receive(CORBA_Environment *env, oe_map_t *map)
+{
+ int res = 0, loop = 1;
+ erlang_msg msg;
+
+ while (res >= 0 && loop > 0) {
+ res = ei_receive_encoded(env->_fd, &env->_inbuf, &env->_inbufsz,
+ &msg, &env->_iin);
+ switch(res) {
+ case ERL_SEND:
+ case ERL_REG_SEND:
+ oe_exec_switch(NULL, env, map);
+ switch(env->_major) {
+ case CORBA_NO_EXCEPTION:
+ break;
+ case CORBA_SYSTEM_EXCEPTION:
+ /* XXX stderr */
+ fprintf(stderr, "Request failure, reason : %s\n",
+ (char *) CORBA_exception_value(env));
+ CORBA_exception_free(env);
+ break;
+ default: /* Should not happen */
+ CORBA_exception_free(env);
+ break;
+ }
+ /* send reply */
+ /* XXX We are required to set env->_iout = 0 if oneway?? */
+ if (env->_iout > 0)
+ ei_send_encoded(env->_fd, &env->_caller, env->_outbuf,
+ env->_iout);
+ loop = 0;
+ break;
+ case ERL_TICK:
+ break;
+ default:
+ /* XXX */
+ if (res < 0) {
+ fprintf(stderr, "Result negative: %d\n", res);
+ loop = 0;
+ }
+ break;
+ }
+ }
+
+ return 0;
+}
+
diff --git a/lib/ic/c_src/ic_tmo.c b/lib/ic/c_src/ic_tmo.c
new file mode 100644
index 0000000000..78698a6a89
--- /dev/null
+++ b/lib/ic/c_src/ic_tmo.c
@@ -0,0 +1,135 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 2004-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+static int oe_send_tmo(CORBA_Environment *env, unsigned int ms);
+
+/* Client send message (Erlang distribution protocol) */
+static int oe_send_tmo(CORBA_Environment *env, unsigned int ms)
+{
+ if (strlen(env->_regname) == 0) {
+ if (ei_send_encoded_tmo(env->_fd, env->_to_pid, env->_outbuf,
+ env->_iout, ms) < 0) {
+ /* XXX Cannot send to peer? */
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, NO_RESPONSE,
+ "Cannot connect to server");
+ return -1;
+ }
+ } else {
+ if (ei_send_reg_encoded_tmo(env->_fd, env->_from_pid,
+ env->_regname, env->_outbuf,
+ env->_iout, ms) < 0) {
+ /* XXX Cannot send to peer? */
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, NO_RESPONSE,
+ "Cannot connect to server");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/* Send notification (gen_server client) */
+int oe_send_notification_tmo(CORBA_Environment *env, unsigned int send_ms)
+{
+ return oe_send_tmo(env, send_ms);
+}
+
+/* Send request and receive reply (gen_server client) */
+int oe_send_request_and_receive_reply_tmo(CORBA_Environment *env,
+ unsigned int send_ms,
+ unsigned int recv_ms)
+{
+ int msgType = 0;
+ erlang_msg msg;
+
+ if (oe_send_tmo(env, send_ms) < 0)
+ return -1;
+
+ do {
+ if ((msgType = ei_receive_encoded_tmo(env->_fd,
+ &env->_inbuf,
+ &env->_inbufsz,
+ &msg, &env->_iin,
+ recv_ms)) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL,
+ "Cannot decode message");
+ return -1;
+ }
+ } while (msgType != ERL_SEND && msgType != ERL_REG_SEND);
+
+ /* Extracting return message header */
+ if (oe_prepare_reply_decoding(env) < 0) {
+ CORBA_exc_set(env, CORBA_SYSTEM_EXCEPTION, MARSHAL, "Bad message");
+ return -1;
+ }
+ return 0;
+}
+
+/* Server receive (possibly) send reply (gen_server server) */
+
+int oe_server_receive_tmo(CORBA_Environment *env, oe_map_t *map,
+ unsigned int send_ms,
+ unsigned int recv_ms)
+{
+ int res = 0, loop = 1;
+ erlang_msg msg;
+
+ while (res >= 0 && loop > 0) {
+ res = ei_receive_encoded_tmo(env->_fd, &env->_inbuf, &env->_inbufsz,
+ &msg, &env->_iin, recv_ms);
+ switch(res) {
+ case ERL_SEND:
+ case ERL_REG_SEND:
+ oe_exec_switch(NULL, env, map);
+ switch(env->_major) {
+ case CORBA_NO_EXCEPTION:
+ break;
+ case CORBA_SYSTEM_EXCEPTION:
+ /* XXX stderr */
+ fprintf(stderr, "Request failure, reason : %s\n",
+ (char *) CORBA_exception_value(env));
+ CORBA_exception_free(env);
+ break;
+ default: /* Should not happen */
+ CORBA_exception_free(env);
+ break;
+ }
+ /* send reply */
+ /* XXX We are required to set env->_iout = 0 if oneway?? */
+ if (env->_iout > 0)
+ ei_send_encoded_tmo(env->_fd, &env->_caller, env->_outbuf,
+ env->_iout, send_ms);
+ loop = 0;
+ break;
+ case ERL_TICK:
+ break;
+ default:
+ /* XXX */
+ if (res < 0) {
+ fprintf(stderr, "Result negative: %d\n", res);
+ loop = 0;
+ }
+ break;
+ }
+ }
+
+ return 0;
+}
+
diff --git a/lib/ic/c_src/oe_ei_code_erlang_binary.c b/lib/ic/c_src/oe_ei_code_erlang_binary.c
new file mode 100644
index 0000000000..f790f8bd69
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_code_erlang_binary.c
@@ -0,0 +1,105 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 2001-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_encode_erlang_binary(CORBA_Environment *ev, erlang_binary *binary) {
+
+ int size = ev->_iout;
+
+ (int) ei_encode_binary(0, &size, binary->_buffer, binary->_length);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_binary(ev->_outbuf, &ev->_iout, binary->_buffer, binary->_length);
+}
+
+
+
+int oe_sizecalc_erlang_binary(CORBA_Environment *ev, int* _index, int* _size) {
+
+ long _malloc_size = 0;
+ int _error = 0;
+
+ if(*_size == 0)
+ *_size = ((*_size + sizeof(erlang_binary))+sizeof(double)-1)&~(sizeof(double)-1);
+
+ if ((_error = ei_decode_binary(ev->_inbuf, _index, 0, &_malloc_size)) < 0)
+ return _error;
+
+ *_size = ((*_size + (int)_malloc_size)+sizeof(double)-1)&~(sizeof(double)-1);
+
+ return 0;
+}
+
+
+int oe_decode_erlang_binary(CORBA_Environment *ev, char *_first, int* _index, erlang_binary *binary) {
+
+ long _length = 0;
+ int _error = 0;
+
+ if((char*) binary == _first)
+ *_index = ((*_index + sizeof(erlang_binary))+sizeof(double)-1)&~(sizeof(double)-1);
+
+ binary->_buffer = (CORBA_octet *)(_first+*_index);
+
+ if ((_error = ei_decode_binary(ev->_inbuf, &ev->_iin, binary->_buffer, &_length)) < 0)
+ return _error;
+
+ binary->_length = (CORBA_unsigned_long)_length;
+
+ *_index = ((*_index)+_length+sizeof(double)-1)&~(sizeof(double)-1);
+
+ return 0;
+}
+
+
+
+int print_erlang_binary(erlang_binary *binary) {
+
+ int i=0;
+
+ if (binary == NULL)
+ return -1;
+
+ fprintf(stdout,"binary->_length : %ld\n",binary->_length);
+ fprintf(stdout,"binary->_buffer : ");
+ if(binary->_buffer != NULL) {
+ for (i=0; i<binary->_length; i++)
+ fprintf(stdout,"%c",binary->_buffer[i]);
+ fprintf(stdout,"\n");
+ } else
+ fprintf(stdout,"NULL\n");
+ return 0;
+}
diff --git a/lib/ic/c_src/oe_ei_decode_longlong.c b/lib/ic/c_src/oe_ei_decode_longlong.c
new file mode 100644
index 0000000000..1fd5c8420a
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_decode_longlong.c
@@ -0,0 +1,25 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_decode_longlong(const char *buf, int *index, CORBA_long_long *p) {
+ return ei_decode_long(buf, index, p);
+}
diff --git a/lib/ic/c_src/oe_ei_decode_ulonglong.c b/lib/ic/c_src/oe_ei_decode_ulonglong.c
new file mode 100644
index 0000000000..26e4294783
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_decode_ulonglong.c
@@ -0,0 +1,25 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_decode_ulonglong(const char *buf, int *index, CORBA_unsigned_long_long *p) {
+ return ei_decode_ulong(buf, index, p);
+}
diff --git a/lib/ic/c_src/oe_ei_decode_wchar.c b/lib/ic/c_src/oe_ei_decode_wchar.c
new file mode 100644
index 0000000000..b68cdb829f
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_decode_wchar.c
@@ -0,0 +1,25 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_decode_wchar(const char *buf, int *index, CORBA_wchar *p) {
+ return ei_decode_ulong(buf, index, p);
+}
diff --git a/lib/ic/c_src/oe_ei_decode_wstring.c b/lib/ic/c_src/oe_ei_decode_wstring.c
new file mode 100644
index 0000000000..b89922f4b8
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_decode_wstring.c
@@ -0,0 +1,107 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+/* Scratch function */
+int oe_ei_decode_wstring(const char *buf, int *index, CORBA_wchar *p) {
+
+ int length,error_code,type,tmp=0;
+ char * tmp_space = NULL;
+
+
+ if ((error_code = ei_get_type(buf, index, &type, &length)) < 0)
+ return error_code;
+
+ switch(type) {
+
+ case ERL_LIST_EXT: /* A list */
+ case ERL_NIL_EXT: /* An empty list */
+
+ if (p) { /* Decoding part */
+
+ if ((error_code = ei_decode_list_header(buf, index, &length)) < 0)
+ return error_code;
+
+ if (length != 0) {
+ for(tmp = 0; tmp < length; tmp++)
+ if ((error_code = oe_ei_decode_wchar(buf, index, &(p[tmp]))) < 0)
+ return error_code;
+
+ /* Read list tail also */
+ if ((error_code = ei_decode_list_header(buf, index, &length)) < 0)
+ return error_code;
+ }
+
+ p[tmp] = 0; /* Wide NULL */
+
+ } else { /* Allocation counting part */
+
+ if ((error_code = ei_decode_list_header(buf, index, &length)) < 0)
+ return error_code;
+
+ if (length != 0) {
+ for(tmp = 0; tmp < length; tmp++)
+ if ((error_code = oe_ei_decode_wchar(buf, index, 0)) < 0)
+ return error_code;
+
+ /* Read list tail also */
+ if ((error_code = ei_decode_list_header(buf, index, &length)) < 0)
+ return error_code;
+ }
+ }
+
+ break;
+
+ case ERL_STRING_EXT: /* A string */
+
+ if (p) { /* Decoding part */
+
+ /* Allocate temporary string */
+ tmp_space = (char*) malloc(length*(__OE_WCHARSZ__+1));
+
+ if ((error_code = ei_decode_string(buf, index, tmp_space)) < 0)
+ return error_code;
+
+ /* Assign characters to wide characters */
+ for(tmp = 0; tmp < length; tmp++)
+ p[tmp] = tmp_space[tmp];
+
+ p[tmp] = 0; /* Wide NULL */
+
+ /* Free temporary string */
+ CORBA_free(tmp_space);
+
+ } else { /* Allocation counting part */
+
+ if ((error_code = ei_decode_string(buf, index, 0)) < 0)
+ return error_code;
+
+ }
+ break;
+
+ default: /* Bad header */
+ return -1;
+ }
+
+ return 0;
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_atom.c b/lib/ic/c_src/oe_ei_encode_atom.c
new file mode 100644
index 0000000000..d16df25859
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_atom.c
@@ -0,0 +1,46 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_atom(CORBA_Environment *ev, const char *p) {
+ int size = ev->_iout;
+
+ (int) ei_encode_atom(0,&size,p);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_atom(ev->_outbuf,&ev->_iout,p);
+}
+
diff --git a/lib/ic/c_src/oe_ei_encode_char.c b/lib/ic/c_src/oe_ei_encode_char.c
new file mode 100644
index 0000000000..a180b908af
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_char.c
@@ -0,0 +1,44 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_char(CORBA_Environment *ev, char p) {
+ int size = ev->_iout + __OE_CHARSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_char(ev->_outbuf, &ev->_iout, p);
+}
+
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_double.c b/lib/ic/c_src/oe_ei_encode_double.c
new file mode 100644
index 0000000000..931b91ab90
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_double.c
@@ -0,0 +1,43 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_double(CORBA_Environment *ev, double p) {
+ int size = ev->_iout + __OE_DOUBLESZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_double(ev->_outbuf, &ev->_iout, p);
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_list_header.c b/lib/ic/c_src/oe_ei_encode_list_header.c
new file mode 100644
index 0000000000..b93ad9c22a
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_list_header.c
@@ -0,0 +1,41 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_list_header(CORBA_Environment *ev, int arity) {
+ int size = ev->_iout + __OE_LISTHDRSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_list_header(ev->_outbuf, &ev->_iout, arity);
+}
diff --git a/lib/ic/c_src/oe_ei_encode_long.c b/lib/ic/c_src/oe_ei_encode_long.c
new file mode 100644
index 0000000000..1f2e62a999
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_long.c
@@ -0,0 +1,44 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_long(CORBA_Environment *ev, long p) {
+ int size = ev->_iout + __OE_LONGSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_long(ev->_outbuf, &ev->_iout, p);
+}
+
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_longlong.c b/lib/ic/c_src/oe_ei_encode_longlong.c
new file mode 100644
index 0000000000..79b4eef6a8
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_longlong.c
@@ -0,0 +1,44 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_longlong(CORBA_Environment *ev, CORBA_long_long p) {
+ int size = ev->_iout + __OE_LONGLONGSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ /* CORBA_long_long = long because of erl_interface limitation */
+ return ei_encode_long(ev->_outbuf, &ev->_iout, p);
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_pid.c b/lib/ic/c_src/oe_ei_encode_pid.c
new file mode 100644
index 0000000000..b7083f84a0
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_pid.c
@@ -0,0 +1,45 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_pid(CORBA_Environment *ev, const erlang_pid *p) {
+ int size = ev->_iout;
+
+ (int) ei_encode_pid(NULL, &size, p);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_pid(ev->_outbuf, &ev->_iout, p);
+}
diff --git a/lib/ic/c_src/oe_ei_encode_port.c b/lib/ic/c_src/oe_ei_encode_port.c
new file mode 100644
index 0000000000..981f82c08d
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_port.c
@@ -0,0 +1,46 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_port(CORBA_Environment *ev, const erlang_port *p) {
+ int size = ev->_iout;
+
+ (int) ei_encode_port(NULL, &size, p);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_port(ev->_outbuf, &ev->_iout, p);
+}
+
diff --git a/lib/ic/c_src/oe_ei_encode_ref.c b/lib/ic/c_src/oe_ei_encode_ref.c
new file mode 100644
index 0000000000..d321469b45
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_ref.c
@@ -0,0 +1,46 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_ref(CORBA_Environment *ev, const erlang_ref *p) {
+ int size = ev->_iout;
+
+ (int) ei_encode_ref(NULL, &size, p);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_ref(ev->_outbuf, &ev->_iout, p);
+}
+
diff --git a/lib/ic/c_src/oe_ei_encode_string.c b/lib/ic/c_src/oe_ei_encode_string.c
new file mode 100644
index 0000000000..48de73b5a8
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_string.c
@@ -0,0 +1,47 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_string(CORBA_Environment *ev, const char *p) {
+ int size = ev->_iout;
+
+ (int) ei_encode_string(0,&size,p);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_string(ev->_outbuf,&ev->_iout,p);
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_term.c b/lib/ic/c_src/oe_ei_encode_term.c
new file mode 100644
index 0000000000..48de152ac6
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_term.c
@@ -0,0 +1,48 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_term(CORBA_Environment *ev, void *t) {
+ int size = ev->_iout;
+
+ (int) ei_encode_term(NULL, &size, t);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ return ei_encode_term(ev->_outbuf, &ev->_iout, t);
+}
+
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_tuple_header.c b/lib/ic/c_src/oe_ei_encode_tuple_header.c
new file mode 100644
index 0000000000..c2d92a79fb
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_tuple_header.c
@@ -0,0 +1,44 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_tuple_header(CORBA_Environment *ev, int arity) {
+ int size = ev->_iout + __OE_TUPLEHDRSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_tuple_header(ev->_outbuf, &ev->_iout, arity);
+}
+
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_ulong.c b/lib/ic/c_src/oe_ei_encode_ulong.c
new file mode 100644
index 0000000000..d1a9cf1aa1
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_ulong.c
@@ -0,0 +1,43 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_ulong(CORBA_Environment *ev, unsigned long p) {
+ int size = ev->_iout + __OE_ULONGSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_ulong(ev->_outbuf, &ev->_iout, p);
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_ulonglong.c b/lib/ic/c_src/oe_ei_encode_ulonglong.c
new file mode 100644
index 0000000000..1260053116
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_ulonglong.c
@@ -0,0 +1,44 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_ulonglong(CORBA_Environment *ev, CORBA_unsigned_long_long p) {
+ int size = ev->_iout + __OE_ULONGLONGSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ /* CORBA_long_long = long because of erl_interface limitation */
+ return ei_encode_ulong(ev->_outbuf, &ev->_iout, p);
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_version.c b/lib/ic/c_src/oe_ei_encode_version.c
new file mode 100644
index 0000000000..2448b32916
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_version.c
@@ -0,0 +1,42 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1998-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_version(CORBA_Environment *ev) {
+ int size = ev->_iout + __OE_VSNSZ__;
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ if ((buf = realloc(buf,bufsz)) != NULL) {
+ ev->_outbuf = buf;
+ ev->_outbufsz += ev->_memchunk;
+ }
+ else {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+ }
+
+ return ei_encode_version(ev->_outbuf, &ev->_iout);
+}
+
diff --git a/lib/ic/c_src/oe_ei_encode_wchar.c b/lib/ic/c_src/oe_ei_encode_wchar.c
new file mode 100644
index 0000000000..6b9505aab0
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_wchar.c
@@ -0,0 +1,27 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_wchar(CORBA_Environment *ev, CORBA_wchar p) {
+ return oe_ei_encode_ulong(ev, p);
+}
+
+
diff --git a/lib/ic/c_src/oe_ei_encode_wstring.c b/lib/ic/c_src/oe_ei_encode_wstring.c
new file mode 100644
index 0000000000..6f26c53623
--- /dev/null
+++ b/lib/ic/c_src/oe_ei_encode_wstring.c
@@ -0,0 +1,62 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 1999-2009. 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
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ *
+ */
+#include <ic.h>
+
+
+int oe_ei_encode_wstring(CORBA_Environment *ev, CORBA_wchar *p) {
+
+ int len,wchar,size,tmp,error_code;
+
+ len = ic_wstrlen(p);
+ size = ev->_iout + __OE_LISTHDRSZ__ +(len * __OE_WCHARSZ__);
+
+ if (size >= ev->_outbufsz) {
+ char *buf = ev->_outbuf;
+ int bufsz = ev->_outbufsz + ev->_memchunk;
+
+ while (size >= bufsz)
+ bufsz += ev->_memchunk;
+
+ if ((buf = realloc(buf, bufsz)) == NULL) {
+ CORBA_exc_set(ev, CORBA_SYSTEM_EXCEPTION, NO_MEMORY, "End of heap memory while encoding");
+ return -1; /* OUT OF MEMORY */
+ }
+
+ ev->_outbuf = buf;
+ ev->_outbufsz = bufsz;
+ }
+
+ /* Encode the wide string */
+ error_code = 0;
+
+ if ((error_code = oe_ei_encode_list_header(ev, len)) < 0)
+ return error_code;
+
+ for(tmp = 0; tmp < len; tmp++)
+ if ((error_code = oe_ei_encode_wchar(ev, p[tmp])) < 0)
+ return error_code;
+
+ if ((error_code = oe_ei_encode_empty_list(ev)) < 0)
+ return error_code;
+
+ return 0;
+}
+
+