diff options
Diffstat (limited to 'lib/ic/c_src')
27 files changed, 0 insertions, 2124 deletions
diff --git a/lib/ic/c_src/Makefile b/lib/ic/c_src/Makefile deleted file mode 100644 index 35d6013279..0000000000 --- a/lib/ic/c_src/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# -# %CopyrightBegin% -# -# Copyright Ericsson AB 1998-2016. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions 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 deleted file mode 100644 index c0dad59557..0000000000 --- a/lib/ic/c_src/Makefile.in +++ /dev/null @@ -1,165 +0,0 @@ -# -# %CopyrightBegin% -# -# Copyright Ericsson AB 1998-2016. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions 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 -ifeq ($(V),0) -AR_OUT = rc -else -AR_OUT = rcv -endif -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 -# ---------------------------------------------------- - -_create_dirs := $(shell mkdir -p $(OBJDIR) $(LIBDIR)) - -$(LIBRARY): $(OBJ_FILES) - -$(V_AR) $(AR_OUT) $@ $(OBJ_FILES) - -$(V_RANLIB) $@ - -$(OBJDIR)/%.o: %.c - $(V_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_DIR) "$(RELEASE_PATH)/usr/include" - $(INSTALL_DIR) "$(RELEASE_PATH)/usr/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" - $(INSTALL_DATA) $(IDL_FILES) $(H_FILES) "$(RELEASE_PATH)/usr/include" - $(INSTALL_DATA) $(LIBRARY) "$(RELEASE_PATH)/usr/lib" - -release_docs_spec: - - - - - - diff --git a/lib/ic/c_src/Makefile.win32 b/lib/ic/c_src/Makefile.win32 deleted file mode 100644 index 670a17f958..0000000000 --- a/lib/ic/c_src/Makefile.win32 +++ /dev/null @@ -1,109 +0,0 @@ -# -# %CopyrightBegin% -# -# Copyright Ericsson AB 1999-2016. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions 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 deleted file mode 100644 index 6e55a13f4f..0000000000 --- a/lib/ic/c_src/ic.c +++ /dev/null @@ -1,613 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index ef66f67d55..0000000000 --- a/lib/ic/c_src/ic_tmo.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 2004-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 81610facbc..0000000000 --- a/lib/ic/c_src/oe_ei_code_erlang_binary.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 2001-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * %CopyrightEnd% - * - */ -#include <ic.h> - - -int oe_encode_erlang_binary(CORBA_Environment *ev, erlang_binary *binary) { - - int size = ev->_iout; - - 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 deleted file mode 100644 index 7d872ce94f..0000000000 --- a/lib/ic/c_src/oe_ei_decode_longlong.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index d071d09a43..0000000000 --- a/lib/ic/c_src/oe_ei_decode_ulonglong.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index bb6899b7b3..0000000000 --- a/lib/ic/c_src/oe_ei_decode_wchar.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index d2a8270291..0000000000 --- a/lib/ic/c_src/oe_ei_decode_wstring.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 + 1)*sizeof(char)); - - if ((error_code = ei_decode_string(buf, index, tmp_space)) < 0) { - free(tmp_space); - 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 */ - 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 deleted file mode 100644 index 9d2c1d5aa3..0000000000 --- a/lib/ic/c_src/oe_ei_encode_atom.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * %CopyrightEnd% - * - */ -#include <ic.h> - -#include <string.h> - - -#define DIRTY_ATOM_ENC_MAX(LATIN1_CHARS) ((LATIN1_CHARS)*2 + 3) - - -int oe_ei_encode_atom(CORBA_Environment *ev, const char *p) { - int size = ev->_iout; - size_t len = strlen(p); - - if (size + DIRTY_ATOM_ENC_MAX(len) >= ev->_outbufsz) { - - ei_encode_atom_len(0,&size,p,len); - - 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_len(ev->_outbuf,&ev->_iout,p,len); -} - diff --git a/lib/ic/c_src/oe_ei_encode_char.c b/lib/ic/c_src/oe_ei_encode_char.c deleted file mode 100644 index 9079cb4ecc..0000000000 --- a/lib/ic/c_src/oe_ei_encode_char.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 95fed6ff25..0000000000 --- a/lib/ic/c_src/oe_ei_encode_double.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 57a0fc0d0f..0000000000 --- a/lib/ic/c_src/oe_ei_encode_list_header.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index c0d8599b95..0000000000 --- a/lib/ic/c_src/oe_ei_encode_long.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index ac208f1982..0000000000 --- a/lib/ic/c_src/oe_ei_encode_longlong.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index ebd0d0b6ef..0000000000 --- a/lib/ic/c_src/oe_ei_encode_pid.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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; - - 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 deleted file mode 100644 index a4ecf846b7..0000000000 --- a/lib/ic/c_src/oe_ei_encode_port.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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; - - 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 deleted file mode 100644 index 8dcbc3aeb7..0000000000 --- a/lib/ic/c_src/oe_ei_encode_ref.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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; - - 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 deleted file mode 100644 index 8612835e2b..0000000000 --- a/lib/ic/c_src/oe_ei_encode_string.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * %CopyrightEnd% - * - */ -#include <ic.h> - - -int oe_ei_encode_string(CORBA_Environment *ev, const char *p) { - int size = ev->_iout; - - 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 deleted file mode 100644 index c36edbf493..0000000000 --- a/lib/ic/c_src/oe_ei_encode_term.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * %CopyrightEnd% - * - */ -#include <ic.h> - - -int oe_ei_encode_term(CORBA_Environment *ev, void *t) { - int size = ev->_iout; - - 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 deleted file mode 100644 index 64f8b4b873..0000000000 --- a/lib/ic/c_src/oe_ei_encode_tuple_header.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 249235935e..0000000000 --- a/lib/ic/c_src/oe_ei_encode_ulong.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 7997f4ea39..0000000000 --- a/lib/ic/c_src/oe_ei_encode_ulonglong.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 4bc6256c32..0000000000 --- a/lib/ic/c_src/oe_ei_encode_version.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index 0fd4027886..0000000000 --- a/lib/ic/c_src/oe_ei_encode_wchar.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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 deleted file mode 100644 index a799d475e7..0000000000 --- a/lib/ic/c_src/oe_ei_encode_wstring.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2016. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions 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; -} - - |