diff options
author | Lars Thorsen <[email protected]> | 2018-04-25 15:09:14 +0200 |
---|---|---|
committer | Lars Thorsen <[email protected]> | 2018-04-27 12:05:30 +0200 |
commit | 6bcdad20c24457393c0d9eeb385d0ff5aa872cd0 (patch) | |
tree | 63162ddfa38d92eaff2193b73277aba18160308c /lib/ic/examples | |
parent | 87b06e4ab91729f7415578c8ac0aacec28720ad9 (diff) | |
download | otp-6bcdad20c24457393c0d9eeb385d0ff5aa872cd0.tar.gz otp-6bcdad20c24457393c0d9eeb385d0ff5aa872cd0.tar.bz2 otp-6bcdad20c24457393c0d9eeb385d0ff5aa872cd0.zip |
Move the corba applcations to separate repository
All corba applications are moved to a separate repository.
E.g. orber, ic, cosEvent, cosEventDomain, cosNotifications
cosTime, cosTransactions, cosProperty and cosFileTransfer.
Diffstat (limited to 'lib/ic/examples')
42 files changed, 0 insertions, 3193 deletions
diff --git a/lib/ic/examples/all-against-all/Makefile b/lib/ic/examples/all-against-all/Makefile deleted file mode 100644 index e772cab94e..0000000000 --- a/lib/ic/examples/all-against-all/Makefile +++ /dev/null @@ -1,118 +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% -# -# -# Point this at your version of OTP -OTPROOT=/usr/local/otp/releases/otp_beam_sunos5_r7a - -# Type actual IC Version -ICVSN=4.0.4 - -# Type actual Erl Interface Vesrion -EIVSN=3.2.2 - -# Type actual Erl Interface Vesrion -JIVSN=1.2 - -# IDL file(s) -IDLS=random.idl - -# Own C-server files -CSRV=server callbacks - -# Own C-client files -CCL=client - -# Generated C-server files -GCSRVS=rmod_random__s - -# Generated C-server files -GCCLS=rmod_random - -# Includes -IFLAGS=-I$(OTPROOT)/lib/ic-$(ICVSN)/include \ - -I$(OTPROOT)/lib/erl_interface-$(EIVSN)/include - -LDFLAGS=-L$(OTPROOT)/lib/ic-$(ICVSN)/priv/lib \ - -L$(OTPROOT)/lib/erl_interface-$(EIVSN)/lib - -LDLIBS=-lic -lerl_interface -lei -lnsl -lsocket - - -# Erlang compiler -ERLC=$(OTPROOT)/bin/erlc - -# Erlang compiler flags. -EFLAGS='+{scoped_op_calls,true}' - -# C compiler -CC=gcc - -# C compiler flags -CFLAGS=-ggdb -O2 -Wall $(IFLAGS) - -# Java compiler -JAVAC=javac - -CLASSPATH= "./:$(OTPROOT)/lib/ic-$(ICVSN)/priv/ic.jar:$(OTPROOT)/lib/jinterface-$(JIVSN)/priv/OtpErlang.jar" -JFLAGS=-classpath $(CLASSPATH) -O - -JGENJFILES = \ - ./rmod/_randomImplBase.java \ - ./rmod/random.java \ - ./rmod/randomHolder.java \ - ./rmod/_randomStub.java \ - ./rmod/randomHelper.java - - -all: server client eall jall - - -server: - $(ERLC) $(EFLAGS) '+{be,c_server}' $(IDLS) - $(CC) $(IFLAGS) -c $(CSRV:=.c) $(GCSRVS:=.c) - $(CC) $(CSRV:=.o) $(GCSRVS:=.o) -o $@ $(LDFLAGS) $(LDLIBS) - -client: - $(ERLC) $(EFLAGS) '+{be,c_client}' $(IDLS) - $(CC) $(IFLAGS) -c $(CCL:=.c) $(GCCLS:=.c) - $(CC) $(CCL:=.o) $(GCCLS:=.o) -o $@ $(LDFLAGS) $(LDLIBS) - -eall: - $(ERLC) $(EFLAGS) '+{be,erl_genserv}' $(IDLS) - $(ERLC) *.erl - -jall: - $(ERLC) $(EFLAGS) '+{be,java}' $(IDLS) - $(JAVAC) $(JFLAGS) */*.java *.java - - -clean: - /bin/rm -rf $(GCCLS:=.o) $(GCCLS:=.c) $(GCSRVS:=.o) $(GCSRVS:=.c) $(CCL:=.o) $(CSRV:=.o) rmod.erl rmod_random.erl *.jam *.beam oe* *.h *.hrl *~ core server client *.class - - - - - - - - - - - diff --git a/lib/ic/examples/all-against-all/Makefile.win32 b/lib/ic/examples/all-against-all/Makefile.win32 deleted file mode 100644 index a8e480fd1f..0000000000 --- a/lib/ic/examples/all-against-all/Makefile.win32 +++ /dev/null @@ -1,139 +0,0 @@ -# -# %CopyrightBegin% -# -# Copyright Ericsson AB 2000-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% -# -# -# Point this at your version of OTP -OTPROOT=c:\Progra~1\erl5.0.1\ - -# Type actual IC Version -ICVSN=4.0.4 - -# Type actual Erl Interface Vesrion -EIVSN=3.2.2 - -# Type actual Erl Interface Vesrion -JIVSN=1.2 - -# IDL file(s) -IDLS=random.idl - -# Own C-server files -CSRV=server.c callbacks.c -CSRVO=server.obj callbacks.obj - -# Own C-client files -CCL=client.c -CCLO=client.obj - -# Generated C-server files -GCSRVS=rmod_random__s.c -GCSRVSO=rmod_random__s.obj - -# Generated C-client files -GCCLS=rmod_random.c -GCCLSO=rmod_random.obj - -# Includes -IFLAGS=-I"$(OTPROOT)\lib\ic-$(ICVSN)\include" \ - -I"$(OTPROOT)\lib\erl_interface-$(EIVSN)\include" - -LDFLAGS=/LIBPATH:"$(OTPROOT)\lib\ic-$(ICVSN)\priv\lib" \ - /LIBPATH:"$(OTPROOT)\lib\erl_interface-$(EIVSN)\lib" - -LDLIBS=ic.lib erl_interface.lib ei.lib ws2_32.lib - - -# Erlang compiler -ERLC=$(OTPROOT)\bin\erlc - -# Erlang compiler flags. -EFLAGS="+{scoped_op_calls,true}" - - -# C compiler -CC=cl - -# C compiler flags -CFLAGS=-MT -D__WIN32__ $(IFLAGS) - - -# Java compiler -JAVAC=c:\Progra~1\jdk1.3\bin\javac - -# Java -JAVA=c:\Progra~1\jdk1.3\bin\java - - -# Java compiler flags -CLASSPATH= ".;$(OTPROOT)\lib\ic-$(ICVSN)\priv\ic.jar;$(OTPROOT)\lib\jinterface-$(JIVSN)\priv\OtpErlang.jar" -JFLAGS=-classpath $(CLASSPATH) -O - - -all: server.exe client.exe client.beam client.class - - -server.exe: - $(ERLC) $(EFLAGS) "+{be,c_server}" $(IDLS) - $(CC) -c $(CFLAGS) $(CSRV) $(GCSRVS) - $(CC) -o server.exe $(CSRVO) $(GCSRVSO) -link $(LDFLAGS) $(LDLIBS) - - -client.exe: - $(ERLC) $(EFLAGS) "+{be,c_client}" $(IDLS) - $(CC) -c $(CFLAGS) $(CCL) $(GCCLS) - $(CC) -o client.exe $(CCLO) $(GCCLSO) -link $(LDFLAGS) $(LDLIBS) - -client.beam: - $(ERLC) $(EFLAGS) "+{be,erl_genserv}" $(IDLS) - $(ERLC) *.erl - -client.class: - $(ERLC) $(EFLAGS) "+{be,java}" $(IDLS) - $(JAVAC) $(JFLAGS) rmod/*.java - $(JAVAC) $(JFLAGS) *.java - -jclient.run: - $(JAVA) -classpath $(CLASSPATH) client - -jserver.run: - $(JAVA) -classpath $(CLASSPATH) server - - -clean: - -@del /f /q rmod - -@rmdir rmod - -@del *.jam - -@del *.beam - -@del oe* - -@del *.h - -@del *.hrl - -@del server.exe - -@del client.exe - -@del *.obj - -@del rmod_random*.c - -@del *~ - -@del *class - -@del rmod.erl - -@del rmod_random.erl - - - - - - diff --git a/lib/ic/examples/all-against-all/ReadMe b/lib/ic/examples/all-against-all/ReadMe deleted file mode 100644 index 7503291344..0000000000 --- a/lib/ic/examples/all-against-all/ReadMe +++ /dev/null @@ -1,122 +0,0 @@ -This is a short description on the use of Erlang,C or Java -client and servers against each other. -The base is a client that initiates and uses a random number -generator that lies on an server. - -There are two make files, one for Unix and one for Windows, -the Unix make file is just named "Makefile", while the Windows -is named "Makefile.win32". - -Instructions. - -1) On Makefile : - * Modify the OTPROOT variable on the Makefile to point - to the root for your erlang instalation. - * Modify IC and Erl_Interface versions to agree your - OTP version. - -2) Type "make" to build the example. - - -3) Start the empd deamon by using the command : - - epmd -daemon - - -4) Do this when you want to run : - - * an Erlang server. - - Start erlang with the options - - -setcookie <Some Cookie> -sname <SomeNodeName> - - In this example you should use : - - erl -setcookie flash -sname babbis - - * a C server. - - Just type : - - server - - * a Java server. - - Set and export the CLASSPATH variable to - point to the java classes located in java development kit, - the Otp's classes and the current directory. - Your classpath should look like this : - - .:<OTPROOT>/lib/ic-3.8.1/priv/ic.jar:<OTPROOT>/lib/jinterface_0.9.2/priv/OtpErlang.jar - - where : - - <OTPROOT> is the location there OTP is installed - - Then type : - - java server - - -5) Do this when you want to run : - - * an Erlang client. - - ** If you have no valid named erlang node, - start erlang with the options - - -setcookie <Some Cookie> -sname <SomeNodeName> - - In this example you should use : - - erl -setcookie flash -sname client - - On the erlang shell, type - - client:start(). - - ** If you have a valid named erlang node, started - whith the same "cookie", on the erlang shell, type - - client:start(). - - - * a C client, just type - - client - - - * a Java client. - - - Set and export the CLASSPATH variable to - point to the java classes located in java development kit, - the Otp's classes and the current directory. - Your classpath should look like this : - - .:<OTPROOT>/lib/ic-4.0/priv/ic.jar:<OTPROOT>/lib/jinterface_1.1/priv/OtpErlang.jar - - where : - - <OTPROOT> is the location there OTP is installed - - Then type : - - java client - - - -6) Please note that : - - * you must always have the same cookie in order to eastablish connection - between clients and servers. - - * you cannot start two servers with the same name. - In this example all servers share the same name in order to test - several constallations. Kill a server before starting another one. - - - - - diff --git a/lib/ic/examples/all-against-all/callbacks.c b/lib/ic/examples/all-against-all/callbacks.c deleted file mode 100644 index 4e6edeb5e0..0000000000 --- a/lib/ic/examples/all-against-all/callbacks.c +++ /dev/null @@ -1,46 +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 <stdlib.h> -#include "rmod_random__s.h" - - -rmod_random_produce__rs* -rmod_random_produce__cb(rmod_random oe_obj, double *rs, CORBA_Environment *oe_env) - -{ - *rs = (double) rand(); - - return (rmod_random_produce__rs*) NULL; -} - - -rmod_random_init__rs* -rmod_random_init__cb(rmod_random oe_obj, long* seed1, long* seed2, long* seed3, CORBA_Environment *oe_env) - -{ - srand(*seed1 * *seed2 * *seed3); - - return (rmod_random_init__rs*) NULL; -} - - - diff --git a/lib/ic/examples/all-against-all/client.c b/lib/ic/examples/all-against-all/client.c deleted file mode 100644 index 4f2f7e3eff..0000000000 --- a/lib/ic/examples/all-against-all/client.c +++ /dev/null @@ -1,154 +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% - * - */ - -/* Just include the interface function */ -#include "rmod_random.h" - - -/* Assign your own node name here */ -#define CLNODENAME "c50" -#define SNODENAME "babbis" -#define SREGNAME "rmod_random_impl" -#define COOKIE "flash" -#define INBUFSZ 1024 -#define OUTBUFSZ 1024 -#define HOSTNAMESZ 256 - - - -/* Stopping node */ -void client_exit(CORBA_Environment *env) { - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - - erl_close_connection(env->_fd); - exit(1); -} - - -int main(){ - - double result=0; - int i=0; - int error = 0; - erlang_pid pid; - char host[HOSTNAMESZ]; - char server_node[HOSTNAMESZ]; - char client_node[HOSTNAMESZ]; - CORBA_Environment *env; - - /* Initiate names */ -#ifdef __WIN32__ - WORD wVersionRequested; - WSADATA wsaData; - - wVersionRequested = MAKEWORD(1, 1); - if ((error = WSAStartup(wVersionRequested, &wsaData))) { - fprintf(stderr,"Can't initialize windows sockets: %d",error); - return 0; - } -#endif - error = gethostname(host,HOSTNAMESZ); - if (error) { -#ifdef __WIN32__ - fprintf(stderr,"can't find own hostname (error = %ld) !\n",WSAGetLastError()); -#else /* not __WIN32__ */ - fprintf(stderr,"can't find own hostname !\n"); -#endif - } - sprintf(client_node,"%s@%s",CLNODENAME,host); - sprintf(server_node,"%s@%s",SNODENAME,host); - - /* Create and init CORBA_Environment */ - env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ); - - /* Initiating the connection */ - erl_init(NULL,0); - erl_connect_init(50,COOKIE,0); - - /* Initiating pid*/ - strcpy(pid.node,client_node); - pid.num = 99; - pid.serial = 0; - pid.creation = 0; - - /* Fixing environment variable */ - env->_fd=erl_connect(server_node); - strcpy(env->_regname,SREGNAME); - env->_to_pid = NULL; - env->_from_pid = &pid; - - if (env->_fd < 0) { - fprintf(stderr,"Error : Cannot connect to Server\n"); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - exit(1); - } - - /* Calling the init function */ - rmod_random_init(NULL, 1, 2, 3, env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - printf("Init complete !\n"); - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - client_exit(env); - default: /* Should not come here */ - client_exit(env); - } - - /* Calling the produce function */ - for(i=1; i<=10; i++) { - result = rmod_random_produce(NULL, env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - client_exit(env); - default: /* Should not come here */ - client_exit(env); - } - - printf("the random number nr%d is %f\n",i,result); - } - - /* Closing the connection */ - erl_close_connection(env->_fd); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - - return 0; -} diff --git a/lib/ic/examples/all-against-all/client.erl b/lib/ic/examples/all-against-all/client.erl deleted file mode 100644 index 3c147037a0..0000000000 --- a/lib/ic/examples/all-against-all/client.erl +++ /dev/null @@ -1,54 +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% -%% -%% -%%---------------------------------------------------------------------- -%% File : client.erl -%% Purpose : -%%---------------------------------------------------------------------- - --module(client). - --export([produce/0,init/3,call/0]). - --define(SERVER,{rmod_random_impl, - list_to_atom("babbis@"++hd(tl(string:tokens(atom_to_list(node()),"@"))))}). --define(CLIENTMOD,'rmod_random'). - -produce() -> - ?CLIENTMOD:produce(?SERVER). - - -init(Seed1, Seed2, Seed3) -> - io:format("Init..."), - ?CLIENTMOD:init(?SERVER,Seed1, Seed2, Seed3), - io:format("ok\n"). - - -call() -> - init(1,2,3), - produce(0). - - -produce(10) -> - ok; -produce(Ctr) -> - N = produce(), - io:format("Random~p = ~p\n",[Ctr,N]), - produce(Ctr+1). diff --git a/lib/ic/examples/all-against-all/client.java b/lib/ic/examples/all-against-all/client.java deleted file mode 100644 index 48b5bc4f60..0000000000 --- a/lib/ic/examples/all-against-all/client.java +++ /dev/null @@ -1,61 +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% - * - */ -public class client { - - private static java.lang.String SNode = "client"; - private static java.lang.String PNode = "babbis"; - private static java.lang.String Cookie = "flash"; - private static java.lang.String Server = "rmod_random_impl"; - - private static rmod._randomStub stub; - - public static void main(String[] args) { - - try { - - stub = new rmod._randomStub(SNode,PNode,Cookie,Server); - int seed1 = 1; - int seed2 = 2; - int seed3 = 3; - double random = 0; - - System.out.print("\nClient initialization...."); - stub.init(seed1,seed2,seed3); - System.out.println("ok\n"); - - - for (int i = 0; i < 10; i++) { - random = stub.produce(); - System.out.println("Random" + i + " = " + random); - } - System.out.println("\nClient terminated.\n"); - - stub.__disconnect(); - - } catch( Exception e) { - System.out.println("Exception :"); - e.printStackTrace(); - } - - } - -} - diff --git a/lib/ic/examples/all-against-all/random.idl b/lib/ic/examples/all-against-all/random.idl deleted file mode 100644 index 3402dfee2c..0000000000 --- a/lib/ic/examples/all-against-all/random.idl +++ /dev/null @@ -1,51 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// - -#ifndef _RANDOM_IDL -#define _RANDOM_IDL - -module rmod { - - interface random { - - double produce(); - - oneway void init(in long seed1, in long seed2, in long seed3); - - }; - -}; - - -#endif - - - - - - - - - - - - - - - diff --git a/lib/ic/examples/all-against-all/rmod_random_impl.erl b/lib/ic/examples/all-against-all/rmod_random_impl.erl deleted file mode 100644 index 36b280c0b2..0000000000 --- a/lib/ic/examples/all-against-all/rmod_random_impl.erl +++ /dev/null @@ -1,49 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2000-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% -%% -%% --module(rmod_random_impl). --export([init/1, terminate/2]). --export([produce/1,init/4]). - - -init(Env) -> - {ok, []}. - -terminate(From, Reason) -> - ok. - - -produce(_Random) -> - case catch random:uniform() of - {'EXIT',_} -> - true; - RUnif -> - {reply,RUnif,[]} - end. - - -init(_Random,S1,S2,S3) -> - case catch random:seed(S1,S2,S3) of - {'EXIT',_} -> - true; - _ -> - {noreply,[]} - end. - diff --git a/lib/ic/examples/all-against-all/server.c b/lib/ic/examples/all-against-all/server.c deleted file mode 100644 index 6d46ea7673..0000000000 --- a/lib/ic/examples/all-against-all/server.c +++ /dev/null @@ -1,262 +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 <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <string.h> -#ifdef __WIN32__ -#include <winsock2.h> -#include <direct.h> -#include <windows.h> -#include <winbase.h> -#else /* not __WIN32__ */ -#include <errno.h> -#include <unistd.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#endif -#include "rmod_random__s.h" - -/* Used functions */ -static int getport(int sockd); -static int getlisten(int port); -static int init(int *sd, int *portnr, int *epmd_fd); -void terminate(int *fd, int *sd, int *epmd_fd); -static void server_loop(int fd, int sd); - -/* change these, or even better, make command-line args to program... */ -#define COOKIE "flash" -#define SERVER "babbis" -#define NODENAMESZ 512 -#define HOSTNAMESZ 256 -#define INBUFSZ 1024 -#define OUTBUFSZ 1024 - - -int main(int argc, char **argv) -{ - int sd; - int portnr; - int epmd_fd; - - /* crate file descriptors */ - if (init(&sd, &portnr, &epmd_fd) < 0) - return -1; - - /* start server loop */ - server_loop(sd,epmd_fd); - - return 0; -} - - - -static void server_loop(int sd, int epmd_fd) -{ - ErlConnect conn; - erlang_msg msg; - int status=1; - CORBA_Environment *env; - - /* Create and init CORBA_Environment */ - env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ); - - while (status >= 0) { - - status = 1; - - if ((env->_fd = erl_accept(sd,&conn)) < 0) { - /* error */ - fprintf(stderr,"Accept failed: %s\n",strerror(errno)); - } - else { - /* connection */ - fprintf(stderr,"Accepted connection from %s\n",conn.nodename); - - while (status >= 0) { - - /* write message to buffer */ - status = ei_receive_encoded(env->_fd, &env->_inbuf, &env->_inbufsz, &msg, &env->_iin); - switch(status) { - case ERL_SEND: - case ERL_REG_SEND : - /* do transaction with fd */ - rmod_random__switch(NULL,env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Request failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - break; - default: /* Should not come here */ - CORBA_exception_free(env); - break; - } - - /* send outdata */ - if (env->_iout > 0) - ei_send_encoded(env->_fd,&env->_caller,env->_outbuf,env->_iout); - break; - - case ERL_TICK : - break; - default : /* < 0 */ - printf("Connection terminated\n"); - break; - } - } - } - status=0; /* restart */ - } - - /* close file descriptors */ - terminate(&env->_fd, &sd, &epmd_fd); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); -} - - - -static int init(int *sd, int *portnr, int *epmd_fd) -{ - char host[HOSTNAMESZ]; - char servernode[NODENAMESZ]; - struct hostent *h; - int error = 0; - -#ifdef __WIN32__ - WORD wVersionRequested; - WSADATA wsaData; - - wVersionRequested = MAKEWORD(1, 1); - if ((error = WSAStartup(wVersionRequested, &wsaData))) { - fprintf(stderr,"Can't initialize windows sockets: %d",error); - } -#endif - /* get the host name */ - error = gethostname(host,HOSTNAMESZ); - if (error) { -#ifdef __WIN32__ - fprintf(stderr,"can't find own hostname (error = %ld) !\n",WSAGetLastError()); -#else /* not __WIN32__ */ - fprintf(stderr,"can't find own hostname !\n"); -#endif - } - else { - /* identify host */ - if (!(h = erl_gethostbyname(host))) - fprintf(stdout,"can't find own ip address\n"); - else { - - /* get a listen port. 0 means let system choose port number */ - *sd = getlisten(0); - - /* what port did we get? */ - /* this call not necessary if we specified port in call to getlisten() */ - *portnr = getport(*sd); - - /* make the nodename server@host */ - sprintf(servernode,"%s@%s",SERVER,host); - - /* initiate */ - erl_init(NULL,0); - - /* host, alive, alive@host, addr, cookie, creation */ - erl_connect_xinit(host,SERVER,servernode,(Erl_IpAddr)(h->h_addr_list[0]),COOKIE,0); - - /* let epmd know we are here */ - *epmd_fd = erl_publish(*portnr); - - return 0; - } - } - return -1; -} - - -void terminate(int *fd, int *sd, int *epmd_fd) { - - close(*fd); - - /* remove info from epnd */ - close(*epmd_fd); - - /* return socket */ - close(*sd); - -} - - - -/* tells you what port you are using on given socket */ -static int getport(int sockd) -{ - struct sockaddr_in addr; - int namelen = sizeof(addr); - int i; - - memset(&addr,0,sizeof(addr)); - - if ((i = getsockname(sockd,(struct sockaddr *)&addr,&namelen))<0) - return i; - - return ntohs(addr.sin_port); -} - - - -/* return a listen socket, bound to given port */ -/* specify port = 0 to let system assign port */ -static int getlisten(int port) -{ - int sockd; - struct sockaddr_in inaddr; - int opt = 1; - int i; - - /* get listen socket */ - if ((sockd = socket(AF_INET,SOCK_STREAM,0)) < 0) return sockd; - - if ((i=setsockopt(sockd,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)))<0) - return i; - - /* bind to requested port */ - memset(&inaddr,0,sizeof(inaddr)); - inaddr.sin_family = AF_INET; - inaddr.sin_addr.s_addr = htonl(INADDR_ANY); - inaddr.sin_port = htons(port); - - if ((i = bind(sockd,(struct sockaddr*) &inaddr, sizeof(inaddr))) < 0) - return i; - - listen(sockd,5); - - return sockd; -} - diff --git a/lib/ic/examples/all-against-all/server.erl b/lib/ic/examples/all-against-all/server.erl deleted file mode 100644 index c5fa2589ae..0000000000 --- a/lib/ic/examples/all-against-all/server.erl +++ /dev/null @@ -1,41 +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% -%% -%% --module(server). --export([start/0]). - - - -%% This starts up the random number server -start() -> - %% Start the gen server - {ok,Pid} = rmod_random:oe_create([],{local,'rmod_random_impl'}), - true. - - - - - - - - - - - diff --git a/lib/ic/examples/all-against-all/server.java b/lib/ic/examples/all-against-all/server.java deleted file mode 100644 index 79618ba8be..0000000000 --- a/lib/ic/examples/all-against-all/server.java +++ /dev/null @@ -1,83 +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% - * - */ -public class server { - - private static java.lang.String SNode = "babbis"; - private static java.lang.String Cookie = "flash"; - private static java.lang.String RegName = "rmod_random_impl"; - - public static void main(String[] args) { - - - System.out.println("\nServer running.\n"); - boolean serverState = true; - boolean recState = true; - - try { - - com.ericsson.otp.erlang.OtpServer self = new com.ericsson.otp.erlang.OtpServer(SNode, Cookie); - self.publishPort(); - - /* Server loop */ - while(serverState == true) { - - com.ericsson.otp.erlang.OtpConnection connection = self.accept(); - serverImpl srv = new serverImpl(); - com.ericsson.otp.erlang.OtpInputStream request; - com.ericsson.otp.erlang.OtpOutputStream reply; - com.ericsson.otp.erlang.OtpErlangPid client; - - /* Server loop */ - while(recState == true) { - - if (connection.isConnected() == true) - try { - - request = connection.receiveBuf(); - - reply = srv.invoke(request); - - if (reply != null) { - client = srv.__getCallerPid(); - - connection.sendBuf(client,reply); - } - - } catch( Exception e) { - System.out.println("Server terminated.\n\n"); - recState = false; - serverState = false; - } - } - - connection.close(); - } - - } catch( Exception e) { - System.out.println("Initialization exception :"); - e.printStackTrace(); - } - } -} - - - - diff --git a/lib/ic/examples/all-against-all/serverImpl.java b/lib/ic/examples/all-against-all/serverImpl.java deleted file mode 100644 index 336bc7e327..0000000000 --- a/lib/ic/examples/all-against-all/serverImpl.java +++ /dev/null @@ -1,43 +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% - * - */ -public class serverImpl extends rmod._randomImplBase { - - java.util.Random random = null; - - - public void init(int seed1, int seed2, int seed3) throws java.lang.Exception { - - random = new java.util.Random(seed1+seed2+seed3); - }; - - - public double produce() throws java.lang.Exception { - - return random.nextDouble(); - } - -} - - - - - - diff --git a/lib/ic/examples/c-client/Makefile b/lib/ic/examples/c-client/Makefile deleted file mode 100644 index 1bfaaed477..0000000000 --- a/lib/ic/examples/c-client/Makefile +++ /dev/null @@ -1,87 +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% -# -# -# Point this at your version of OTP -OTPROOT=/usr/local/otp/daily_build/otp_beam_sunos5_r8a.latest - -# Type actual IC Version -ICVSN=4.1.1 - -# Type actual Erl Interface Vesrion -EIVSN=3.3.0 - -# IDL file(s) -IDLS=random.idl - -# Own C-client files -CCL=client - -# Generated C-server files -GCCLS=oe_code_seed rmod_random - -# Includes -IFLAGS=-I$(OTPROOT)/lib/ic-$(ICVSN)/include \ - -I$(OTPROOT)/lib/erl_interface-$(EIVSN)/include - -LDFLAGS=-L$(OTPROOT)/lib/ic-$(ICVSN)/priv/lib \ - -L$(OTPROOT)/lib/erl_interface-$(EIVSN)/lib - -LDLIBS=-lic -lerl_interface -lei -lnsl -lsocket - - -# Erlang compiler -ERLC=$(OTPROOT)/bin/erlc - -# Erlang compiler flags. -EFLAGS='+{preproc_flags,"-I $(OTPROOT)/usr/include"}' '+{scoped_op_calls,true}' - - -# C compiler -CC=gcc - -# C compiler flags -CFLAGS=-ggdb -O2 -Wall $(IFLAGS) - - -all: server client - - -server: - $(ERLC) $(EFLAGS) '+{be,erl_genserv}' $(IDLS) - $(ERLC) *.erl - -client: - $(ERLC) $(EFLAGS) '+{be,c_client}' $(IDLS) - $(CC) $(IFLAGS) -c $(CCL:=.c) $(GCCLS:=.c) - $(CC) $(CCL:=.o) $(GCCLS:=.o) -o $@ $(LDFLAGS) $(LDLIBS) - - - -clean: - /bin/rm -f $(GCCLS:=.o) $(GCCLS:=.c) $(CCL:=.o) *.jam *.beam oe* rmod_random.erl *.h *.hrl *~ core client - - - - - - - - - diff --git a/lib/ic/examples/c-client/ReadMe b/lib/ic/examples/c-client/ReadMe deleted file mode 100644 index 28372c3be2..0000000000 --- a/lib/ic/examples/c-client/ReadMe +++ /dev/null @@ -1,46 +0,0 @@ -This is a short description on the use of the c-client demo, -a client that initiates and uses a random number generator -that lies on an Erlang-genserver. - -Instructions. - -1) On Makefile : - * Modify the OTPROOT variable on the Makefile to point - to the root for your erlang instalation. - * Modify IC and Erl_Interface versions to agree your - OTP version. - -2) Type "make" to build the example. - - -3) Start erlang with the options - -setcookie <Some Cookie> -sname <SomeNodeName> - - In this example you should use : - - erl -setcookie flash -sname babbis - - -4) On the erlang shell type : - -------------------------- - - rmod_random:oe_create([],{local,rmod_random_impl}). ( initializes the server ) - - or - - test:start(). - - - Then start a new terminal window and type : - ------------------------------------------- - - client ( calls the client ) - - - - - - - - - diff --git a/lib/ic/examples/c-client/client.c b/lib/ic/examples/c-client/client.c deleted file mode 100644 index 652d8376fd..0000000000 --- a/lib/ic/examples/c-client/client.c +++ /dev/null @@ -1,131 +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 the interface function and ei_connect */ -#include "rmod_random.h" -#include "ei_connect.h" - -/* Assign your own node name here */ -#define SNODE "babbis@balin" -#define SERVER "rmod_random_impl" -#define COOKIE "flash" -#define CLNODE "c47@balin" -#define INBUFSZ 1024 -#define OUTBUFSZ 1024 - -/* Stopping node */ -void client_exit(CORBA_Environment *env) { - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - - close(env->_fd); - exit(1); -} - -int main() -{ - double result=0; - int i=0; - erlang_pid pid; - CORBA_Environment *env; - seed idata; - ei_cnode ec; - - /* Create and init CORBA_Environment */ - env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ); - - /* Initialize seed */ - idata.seed1 = 1; - idata.seed2 = 2; - idata.seed3 = 3; - - /* Initiating the connection */ - ei_connect_init(&ec, "c47", COOKIE, 0); - - /* Initiating pid*/ - strcpy(pid.node,CLNODE); - pid.num = 99; - pid.serial = 0; - pid.creation = 0; - - /* Fixing environment variable */ - env->_fd = ei_connect(&ec, SNODE); - strcpy(env->_regname, SERVER); - env->_to_pid = NULL; - env->_from_pid = &pid; - - if (env->_fd < 0) { - fprintf(stderr,"Error : Cannot connect to Server\n"); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - exit(1); - } - - /* Calling the init function */ - rmod_random_init(NULL, &idata, env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - printf("Init complete !\n"); - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - client_exit(env); - default: /* Should not come here */ - client_exit(env); - } - - /* Calling the produce function */ - for(i=1; i<=10; i++) { - result = rmod_random_produce(NULL, env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - client_exit(env); - default: /* Should not come here */ - client_exit(env); - } - - printf("the random number nr%d is %f\n",i,result); - } - - /* Closing the connection */ - close(env->_fd); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - - return 0; -} - diff --git a/lib/ic/examples/c-client/random.idl b/lib/ic/examples/c-client/random.idl deleted file mode 100644 index 8f54058e2b..0000000000 --- a/lib/ic/examples/c-client/random.idl +++ /dev/null @@ -1,52 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// -#ifndef _RANDOM_IDL -#define _RANDOM_IDL - -struct seed { - long seed1; - long seed2; - long seed3; -}; - -module rmod { - - interface random { - - double produce(); - - oneway void init(in seed idata); - - }; - -}; - -#endif - - - - - - - - - - - - diff --git a/lib/ic/examples/c-client/rmod_random_impl.erl b/lib/ic/examples/c-client/rmod_random_impl.erl deleted file mode 100644 index 2948115f8d..0000000000 --- a/lib/ic/examples/c-client/rmod_random_impl.erl +++ /dev/null @@ -1,53 +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% -%% -%% --module('rmod_random_impl'). --include("oe_random.hrl"). --export([init/1, terminate/2]). --export([produce/1,init/2]). - - -init(Env) -> - {ok, []}. - -terminate(From, Reason) -> - ok. - - -produce(_Random) -> - case catch random:uniform() of - {'EXIT',_} -> - true; - RUnif -> - {reply,RUnif,[]} - end. - - -init(_Random,IData) -> - S1 = IData#seed.seed1, - S2 = IData#seed.seed2, - S3 = IData#seed.seed3, - case catch random:seed(S1,S2,S3) of - {'EXIT',_} -> - true; - _ -> - {noreply,[]} - end. - diff --git a/lib/ic/examples/c-client/test.erl b/lib/ic/examples/c-client/test.erl deleted file mode 100644 index d1fa40ff44..0000000000 --- a/lib/ic/examples/c-client/test.erl +++ /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% -%% -%% -% Start Erlang with : erl -sname <your name> -setcookie <your cookie> - --module(test). - --export([start/0,exec/0]). - - -start() -> - io:format("Starting server~n"), - rmod_random:oe_create([],{local,'rmod_random_impl'}). - -exec() -> - io:format("Running client~n"), - OutPut = os:cmd("client"), - io:format("~s",[OutPut]). - - - - - - - - - diff --git a/lib/ic/examples/c-server/Makefile b/lib/ic/examples/c-server/Makefile deleted file mode 100644 index be23d3ddf9..0000000000 --- a/lib/ic/examples/c-server/Makefile +++ /dev/null @@ -1,90 +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% -# -# -# Point this at your version of OTP -OTPROOT=/usr/local/otp/daily_build/otp_beam_sunos5_r8a.latest - -# Type actual IC Version -ICVSN=4.1.1 - -# Type actual Erl Interface Vesrion -EIVSN=3.3.0 - -# IDL file(s) -IDLS=random.idl - -# Own C-server files -CSRV=server callbacks - -# Own C-client files -CCL=client - -# Generated C-server files -GCSRVS=rmod_random__s - -# Generated C-server files -GCCLS=rmod_random - -# Includes -IFLAGS=-I$(OTPROOT)/lib/ic-$(ICVSN)/include \ - -I$(OTPROOT)/lib/erl_interface-$(EIVSN)/include - -LDFLAGS=-L$(OTPROOT)/lib/ic-$(ICVSN)/priv/lib \ - -L$(OTPROOT)/lib/erl_interface-$(EIVSN)/lib - -LDLIBS=-lic -lerl_interface -lei -lnsl -lsocket - - -# Erlang compiler -ERLC=$(OTPROOT)/bin/erlc - -# Erlang compiler flags. -EFLAGS='+{preproc_flags,"-I $(OTPROOT)/usr/include"}' '+{scoped_op_calls,true}' - - -# C compiler -CC=gcc - -# C compiler flags -CFLAGS=-ggdb -O2 -Wall $(IFLAGS) - - -all: server client erlclient - - -server: - $(ERLC) $(EFLAGS) '+{be,c_server}' $(IDLS) - $(CC) $(IFLAGS) -c $(CSRV:=.c) $(GCSRVS:=.c) - $(CC) $(CSRV:=.o) $(GCSRVS:=.o) -o $@ $(LDFLAGS) $(LDLIBS) - -client: - $(ERLC) $(EFLAGS) '+{be,c_client}' $(IDLS) - $(CC) $(IFLAGS) -c $(CCL:=.c) $(GCCLS:=.c) - $(CC) $(CCL:=.o) $(GCCLS:=.o) -o $@ $(LDFLAGS) $(LDLIBS) - -erlclient: - $(ERLC) $(EFLAGS) '+{be,erl_genserv}' $(IDLS) - $(ERLC) *.erl - - -clean: - /bin/rm -f $(GCCLS:=.o) $(GCCLS:=.c) $(GCSRVS:=.o) $(GCSRVS:=.c) $(CCL:=.o) $(CSRV:=.o) *.jam *.beam oe* *.h *.hrl *~ core server client - - diff --git a/lib/ic/examples/c-server/ReadMe b/lib/ic/examples/c-server/ReadMe deleted file mode 100644 index 69fce4cd07..0000000000 --- a/lib/ic/examples/c-server/ReadMe +++ /dev/null @@ -1,45 +0,0 @@ -This is a short description on the use of the client demo, -a client that initiates and uses a random number generator -that lies on a C-server. - -Instructions. - -1) Modify the OTPROOT variable on the Makefile to point - to the root for your erlang instalation. - Modify IC and Erl_Interface versions to agree your - OTP version. - -2) - Type : - ------ - - make ( generates and compiles all code ) - - server ( starts the c-server ) - - - To test the c-client against the c-server start a new terminal window and type : - -------------------------------------------------------------------------------- - - client ( calls the server ) - - - To test the erlang-client against the c-server start a new terminal window and type : - ------------------------------------------------------------------------------------- - - - erl -sname client -setcookie flash ( start erlang ) - - client:init(1,2,3). ( initiates the random generator ) - - client:produce(). ( calls the random generator ) - - - - - - - - - - diff --git a/lib/ic/examples/c-server/callbacks.c b/lib/ic/examples/c-server/callbacks.c deleted file mode 100644 index 2deca145f4..0000000000 --- a/lib/ic/examples/c-server/callbacks.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 <stdlib.h> -#include "rmod_random__s.h" - - -rmod_random_produce__rs* -rmod_random_produce__cb(rmod_random oe_obj, double *rs, CORBA_Environment *oe_env) - -{ - *rs = (double) rand(); - - return (rmod_random_produce__rs*) NULL; -} - - -rmod_random_init__rs* -rmod_random_init__cb(rmod_random oe_obj, long* seed1, long* seed2, long* seed3, CORBA_Environment *oe_env) - -{ - srand(*seed1 * *seed2 * *seed3); - - return (rmod_random_init__rs*) NULL; -} - - - diff --git a/lib/ic/examples/c-server/client.c b/lib/ic/examples/c-server/client.c deleted file mode 100644 index c1d7a1c5a7..0000000000 --- a/lib/ic/examples/c-server/client.c +++ /dev/null @@ -1,125 +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 the interface function, and ei_connect */ -#include "rmod_random.h" -#include "ei_connect.h" - -/* Assign your own node name here */ -#define SNODE "babbis@balin" -#define SERVER "rmod_random_impl" -#define COOKIE "flash" -#define CLNODE "c47@balin" -#define INBUFSZ 1024 -#define OUTBUFSZ 1024 - -/* Stopping node */ -void client_exit(CORBA_Environment *env) { - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - - close(env->_fd); - exit(1); -} - -int main() -{ - double result=0; - int i=0; - erlang_pid pid; - CORBA_Environment *env; - ei_cnode ec; - - /* Create and init CORBA_Environment */ - env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ); - - /* Initiating the connection */ - ei_connect_init(&ec, "c47", COOKIE, 0); - - /* Initiating pid*/ - strcpy(pid.node, CLNODE); - pid.num = 99; - pid.serial = 0; - pid.creation = 0; - - /* Fixing environment variable */ - env->_fd = ei_connect(&ec, SNODE); - strcpy(env->_regname,SERVER); - env->_to_pid = NULL; - env->_from_pid = &pid; - - if (env->_fd < 0) { - fprintf(stderr,"Error : Cannot connect to Server\n"); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - exit(1); - } - - /* Calling the init function */ - rmod_random_init(NULL, 1, 2, 3, env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - printf("Init complete !\n"); - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - client_exit(env); - default: /* Should not come here */ - client_exit(env); - } - - /* Calling the produce function */ - for(i=1; i<=10; i++) { - result = rmod_random_produce(NULL, env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - client_exit(env); - default: /* Should not come here */ - client_exit(env); - } - - printf("the random number nr%d is %f\n",i,result); - } - - /* Closing the connection */ - close(env->_fd); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); - - return 0; -} - diff --git a/lib/ic/examples/c-server/client.erl b/lib/ic/examples/c-server/client.erl deleted file mode 100644 index da28cd504b..0000000000 --- a/lib/ic/examples/c-server/client.erl +++ /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% -%% -%% -%%%---------------------------------------------------------------------- -%%% File : client.erl -%%% Author : Babbis Xagorarakis <babbis@balin> -%%% Purpose : -%%% Created : 22 Oct 1998 by Babbis Xagorarakis <babbis@balin> -%%%---------------------------------------------------------------------- - --module(client). --author('babbis@balin'). - --export([produce/0,init/3]). - --define(SERVER,{rmod_random_impl,'babbis@balin'}). --define(CLIENTMOD,'rmod_random'). - -produce() -> - ?CLIENTMOD:produce(?SERVER). - - -init(Seed1, Seed2, Seed3) -> - ?CLIENTMOD:init(?SERVER, Seed1, Seed2, Seed3). - - - - diff --git a/lib/ic/examples/c-server/random.idl b/lib/ic/examples/c-server/random.idl deleted file mode 100644 index 7ce302a2e7..0000000000 --- a/lib/ic/examples/c-server/random.idl +++ /dev/null @@ -1,50 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// - -#ifndef _RANDOM_IDL -#define _RANDOM_IDL - -module rmod { - - interface random { - - double produce(); - - oneway void init(in long seed1, in long seed2, in long seed3); - - }; - -}; - -#endif - - - - - - - - - - - - - - - diff --git a/lib/ic/examples/c-server/server.c b/lib/ic/examples/c-server/server.c deleted file mode 100644 index a04d60e9b1..0000000000 --- a/lib/ic/examples/c-server/server.c +++ /dev/null @@ -1,246 +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 <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <string.h> -#ifdef __WIN32__ -#include <winsock2.h> -#include <direct.h> -#include <windows.h> -#include <winbase.h> -#else /* not __WIN32__ */ -#include <errno.h> -#include <unistd.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#endif -#include "rmod_random__s.h" -#include "ei_connect.h" - -/* Used functions */ -extern int gethostname(char *buf, int buflen); -static int getport(int sockd); -static int getlisten(int port); -static int init(ei_cnode *ec, int *sd, int *portnr, int *epmd_fd); -void terminate(int *fd, int *sd, int *epmd_fd); -static void server_loop(ei_cnode *ec, int fd, int sd); - -/* change these, or even better, make command-line args to program... */ -#define COOKIE "flash" -#define SERVER "babbis" -#define NODENAMESZ 512 -#define HOSTNAMESZ 256 -#define INBUFSZ 1024 -#define OUTBUFSZ 1024 - - -int main(int argc, char **argv) -{ - int sd; - int portnr; - int epmd_fd; - ei_cnode ec; - - /* crate file descriptors */ - if (init(&ec, &sd, &portnr, &epmd_fd) < 0) - return -1; - - /* start server loop */ - server_loop(&ec, sd, epmd_fd); - - return 0; -} - - - -static void server_loop(ei_cnode *ec, int sd, int epmd_fd) -{ - ErlConnect conn; - erlang_msg msg; - int status=1; - CORBA_Environment *env; - - /* Create and init CORBA_Environment */ - env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ); - - while (status >= 0) { - status = 1; - - if ((env->_fd = ei_accept(ec, sd, &conn)) < 0) { - /* error */ - fprintf(stderr,"Accept failed: %s\n",strerror(errno)); - } else { - /* connection */ - fprintf(stderr,"Accepted connection from %s\n",conn.nodename); - - while (status >= 0) { - - /* write message to buffer */ - status = ei_receive_encoded(env->_fd, &env->_inbuf, &env->_inbufsz, &msg, &env->_iin); - switch(status) { - case ERL_SEND: - case ERL_REG_SEND : - /* do transaction with fd */ - rmod_random__switch(NULL,env); - - switch(env->_major) { - case CORBA_NO_EXCEPTION: /* Success */ - break; - case CORBA_SYSTEM_EXCEPTION: /* System exception */ - printf("Request failure, reason : %s\n",(char *) CORBA_exception_value(env)); - CORBA_exception_free(env); - break; - default: /* Should not come here */ - CORBA_exception_free(env); - break; - } - - /* send outdata */ - if (env->_iout > 0) - ei_send_encoded(env->_fd,&env->_caller,env->_outbuf,env->_iout); - break; - - case ERL_TICK : - break; - default : /* < 0 */ - printf("Connection terminated\n"); - break; - } - } - } - status=0; /* restart */ - } - - /* close file descriptors */ - terminate(&env->_fd, &sd, &epmd_fd); - - /* Free env & buffers */ - CORBA_free(env->_inbuf); - CORBA_free(env->_outbuf); - CORBA_free(env); -} - - - -static int init(int *sd, int *portnr, int *epmd_fd) -{ - char host[HOSTNAMESZ]; - char servernode[NODENAMESZ]; - struct hostent *h; - - /* get the host name */ - if ((gethostname(host,HOSTNAMESZ))) - fprintf(stderr,"can't find own hostname\n"); - else { - /* identify host */ - if (!(h = erl_gethostbyname(host))) - fprintf(stdout,"can't find own ip address\n"); - else { - - /* get a listen port. 0 means let system choose port number */ - *sd = getlisten(0); - - /* what port did we get? */ - /* this call not necessary if we specified port in call to getlisten() */ - *portnr = getport(*sd); - - /* make the nodename server@host */ - sprintf(servernode,"%s@%s",SERVER,host); - - /* initiate */ - /* cnode, host, alive, alive@host, addr, cookie, creation */ - if (ei_connect_xinit(ec, host, SERVER, servernode, - (Erl_IpAddr)(h->h_addr_list[0]), - COOKIE, 0) == 0) { - /* let epmd know we are here */ - *epmd_fd = ei_publish(ec, *portnr); - if (*epmd_fd >= 0) - return 0; - } - } - } - return -1; -} - - -void terminate(int *fd, int *sd, int *epmd_fd) { - - close(*fd); - - /* remove info from epnd */ - close(*epmd_fd); - - /* return socket */ - close(*sd); - -} - - - -/* tells you what port you are using on given socket */ -static int getport(int sockd) -{ - struct sockaddr_in addr; - int namelen = sizeof(addr); - int i; - - memset(&addr,0,sizeof(addr)); - - if ((i = getsockname(sockd,(struct sockaddr *)&addr,&namelen))<0) - return i; - - return ntohs(addr.sin_port); -} - - - -/* return a listen socket, bound to given port */ -/* specify port = 0 to let system assign port */ -static int getlisten(int port) -{ - int sockd; - struct sockaddr_in inaddr; - int opt = 1; - int i; - - /* get listen socket */ - if ((sockd = socket(AF_INET,SOCK_STREAM,0)) < 0) return sockd; - - if ((i=setsockopt(sockd,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)))<0) - return i; - - /* bind to requested port */ - memset(&inaddr,0,sizeof(inaddr)); - inaddr.sin_family = AF_INET; - inaddr.sin_addr.s_addr = htonl(INADDR_ANY); - inaddr.sin_port = htons(port); - - if ((i = bind(sockd,(struct sockaddr*) &inaddr, sizeof(inaddr))) < 0) - return i; - - listen(sockd,5); - - return sockd; -} diff --git a/lib/ic/examples/erl-genserv/ReadMe b/lib/ic/examples/erl-genserv/ReadMe deleted file mode 100644 index cde588e269..0000000000 --- a/lib/ic/examples/erl-genserv/ReadMe +++ /dev/null @@ -1,30 +0,0 @@ -This is a short description on the use of the c-client demo, -a client that initiates and uses a random number generator -that lies on an Erlang-genserver. - -Instructions. - - On the erlang shell type : - -------------------------- - - ic:gen(random,[{be,erl_genserv}]). ( generates the plain code ) - - make:all(). ( compiles the erlang code ) - - {ok,R} = rmod_random:oe_create(). ( initializes the server ) - - - Running the example : - --------------------- - - rmod_random:init(R,1,2,3). ( initializes the generator ) - - rmod_random:produce(R). ( generates a random number ) - - - - - - - - diff --git a/lib/ic/examples/erl-genserv/random.idl b/lib/ic/examples/erl-genserv/random.idl deleted file mode 100644 index 969b24b749..0000000000 --- a/lib/ic/examples/erl-genserv/random.idl +++ /dev/null @@ -1,51 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// - -#ifndef _RANDOM_IDL -#define _RANDOM_IDL - - -module rmod { - - interface random { - - double produce(); - - oneway void init(in long seed1, in long seed2, in long seed3); - - }; - -}; - -#endif - - - - - - - - - - - - - - - diff --git a/lib/ic/examples/erl-genserv/rmod_random_impl.erl b/lib/ic/examples/erl-genserv/rmod_random_impl.erl deleted file mode 100644 index 9d9ca8afd4..0000000000 --- a/lib/ic/examples/erl-genserv/rmod_random_impl.erl +++ /dev/null @@ -1,64 +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% -%% -%% --module('rmod_random_impl'). --export([init/1, terminate/2, start/0]). --export([produce/1,init/4]). - - -init(Env) -> - {ok, []}. - -terminate(From, Reason) -> - ok. - - -produce(_Random) -> - case catch random:uniform() of - {'EXIT',_} -> - true; - RUnif -> - {reply,RUnif,[]} - end. - - -init(_Random,S1,S2,S3) -> - case catch random:seed(S1,S2,S3) of - {'EXIT',_} -> - true; - _ -> - {noreply,[]} - end. - - -%% This starts up the random number server -start() -> - %% Start the gen server - {ok,Pid} = rmod_random:oe_create([],{local,'rmod_random_impl'}), - true. - - - - - - - - - diff --git a/lib/ic/examples/erl-plain/ReadMe b/lib/ic/examples/erl-plain/ReadMe deleted file mode 100644 index 26440b4d4f..0000000000 --- a/lib/ic/examples/erl-plain/ReadMe +++ /dev/null @@ -1,27 +0,0 @@ -This is a short description on the use of the erl-plain demo, -a client that initiates and uses a random number generator -that lies on an Erlang-genserver. - -Instructions. - - On the erlang shell type : - -------------------------- - - ic:gen(random,[{be,erl_plain}]). ( generates the plain code ) - - make:all(). ( compiles the erlang code ) - - - Running the example : - --------------------- - - rmod_random:init(1,2,3). ( initializes the generator ) - - rmod_random:produce(). ( generates a random number ) - - - - - - - diff --git a/lib/ic/examples/erl-plain/random.idl b/lib/ic/examples/erl-plain/random.idl deleted file mode 100644 index 606d91f6c5..0000000000 --- a/lib/ic/examples/erl-plain/random.idl +++ /dev/null @@ -1,53 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// -#pragma CODEOPT "[{be,c_genserv}]" - - -#ifndef _RANDOM_IDL -#define _RANDOM_IDL - - -module rmod { - - interface random { - - double produce(); - - oneway void init(in long seed1, in long seed2, in long seed3); - - }; - -}; - -#endif - - - - - - - - - - - - - - - diff --git a/lib/ic/examples/erl-plain/rmod_random_impl.erl b/lib/ic/examples/erl-plain/rmod_random_impl.erl deleted file mode 100644 index ee8623f82d..0000000000 --- a/lib/ic/examples/erl-plain/rmod_random_impl.erl +++ /dev/null @@ -1,33 +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% -%% -%% --module('rmod_random_impl'). - --export([produce/0,init/3]). - - -produce() -> - random:uniform(). - - -init(S1,S2,S3) -> - random:seed(S1,S2,S3), - ok. - diff --git a/lib/ic/examples/java-client-server/ReadMe b/lib/ic/examples/java-client-server/ReadMe deleted file mode 100644 index 9fde464e09..0000000000 --- a/lib/ic/examples/java-client-server/ReadMe +++ /dev/null @@ -1,69 +0,0 @@ -This is a short description on the use of the java demo, -a client that initiates and uses a random number generator -that lies on a java-server. You will be able to shift the -existing client/server with the ones refered to the other -examples. - -Instructions. - -1) Start erlang - - On the erlang shell type : - -------------------------- - - ic:gen(random,[{be,java}]). ( generates the java code ) - - -2) Modify the "SNode" string on file "server.java" to the server - node name thet suites for your machine. - - -3) Modify the "SNode" string on file "client.java" to the client - node for your machine and the "PNode" string for the server - node ( = the same as the SNode for the "server.java" file ). - - -4) Set and export the CLASSPATH variable to point to the - java classes located in java development kit, the - Otp's classes and the current directory. - Your classpath should look like this : - - .:<OTPROOT>/lib/ic-4.0/priv/ic.jar:<OTPROOT>/lib/jinterface_1.1/priv/OtpErlang.jar - - where : - - <OTPROOT> is the location there OTP is installed - - -5) Start the empd deamon by using the command : - - epmd -daemon - - -6) Compile the generated java code : - - javac rmod/*.java ( compiles all generated java code ) - - javac *.java ( compiles all manually writen java code ) - - -7) Start the java on an terminal window : - - java server ( starts the java-server ) - - -8) Start the client on an terminal window : - - java client ( calls the server ) - - - - - - - - - - - - diff --git a/lib/ic/examples/java-client-server/client.java b/lib/ic/examples/java-client-server/client.java deleted file mode 100644 index 48b5bc4f60..0000000000 --- a/lib/ic/examples/java-client-server/client.java +++ /dev/null @@ -1,61 +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% - * - */ -public class client { - - private static java.lang.String SNode = "client"; - private static java.lang.String PNode = "babbis"; - private static java.lang.String Cookie = "flash"; - private static java.lang.String Server = "rmod_random_impl"; - - private static rmod._randomStub stub; - - public static void main(String[] args) { - - try { - - stub = new rmod._randomStub(SNode,PNode,Cookie,Server); - int seed1 = 1; - int seed2 = 2; - int seed3 = 3; - double random = 0; - - System.out.print("\nClient initialization...."); - stub.init(seed1,seed2,seed3); - System.out.println("ok\n"); - - - for (int i = 0; i < 10; i++) { - random = stub.produce(); - System.out.println("Random" + i + " = " + random); - } - System.out.println("\nClient terminated.\n"); - - stub.__disconnect(); - - } catch( Exception e) { - System.out.println("Exception :"); - e.printStackTrace(); - } - - } - -} - diff --git a/lib/ic/examples/java-client-server/random.idl b/lib/ic/examples/java-client-server/random.idl deleted file mode 100644 index 7ce302a2e7..0000000000 --- a/lib/ic/examples/java-client-server/random.idl +++ /dev/null @@ -1,50 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// - -#ifndef _RANDOM_IDL -#define _RANDOM_IDL - -module rmod { - - interface random { - - double produce(); - - oneway void init(in long seed1, in long seed2, in long seed3); - - }; - -}; - -#endif - - - - - - - - - - - - - - - diff --git a/lib/ic/examples/java-client-server/server.java b/lib/ic/examples/java-client-server/server.java deleted file mode 100644 index 79618ba8be..0000000000 --- a/lib/ic/examples/java-client-server/server.java +++ /dev/null @@ -1,83 +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% - * - */ -public class server { - - private static java.lang.String SNode = "babbis"; - private static java.lang.String Cookie = "flash"; - private static java.lang.String RegName = "rmod_random_impl"; - - public static void main(String[] args) { - - - System.out.println("\nServer running.\n"); - boolean serverState = true; - boolean recState = true; - - try { - - com.ericsson.otp.erlang.OtpServer self = new com.ericsson.otp.erlang.OtpServer(SNode, Cookie); - self.publishPort(); - - /* Server loop */ - while(serverState == true) { - - com.ericsson.otp.erlang.OtpConnection connection = self.accept(); - serverImpl srv = new serverImpl(); - com.ericsson.otp.erlang.OtpInputStream request; - com.ericsson.otp.erlang.OtpOutputStream reply; - com.ericsson.otp.erlang.OtpErlangPid client; - - /* Server loop */ - while(recState == true) { - - if (connection.isConnected() == true) - try { - - request = connection.receiveBuf(); - - reply = srv.invoke(request); - - if (reply != null) { - client = srv.__getCallerPid(); - - connection.sendBuf(client,reply); - } - - } catch( Exception e) { - System.out.println("Server terminated.\n\n"); - recState = false; - serverState = false; - } - } - - connection.close(); - } - - } catch( Exception e) { - System.out.println("Initialization exception :"); - e.printStackTrace(); - } - } -} - - - - diff --git a/lib/ic/examples/java-client-server/serverImpl.java b/lib/ic/examples/java-client-server/serverImpl.java deleted file mode 100644 index 336bc7e327..0000000000 --- a/lib/ic/examples/java-client-server/serverImpl.java +++ /dev/null @@ -1,43 +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% - * - */ -public class serverImpl extends rmod._randomImplBase { - - java.util.Random random = null; - - - public void init(int seed1, int seed2, int seed3) throws java.lang.Exception { - - random = new java.util.Random(seed1+seed2+seed3); - }; - - - public double produce() throws java.lang.Exception { - - return random.nextDouble(); - } - -} - - - - - - diff --git a/lib/ic/examples/pre_post_condition/Makefile b/lib/ic/examples/pre_post_condition/Makefile deleted file mode 100644 index cd7e630724..0000000000 --- a/lib/ic/examples/pre_post_condition/Makefile +++ /dev/null @@ -1,135 +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% -# -# -# ``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. -# -# The Initial Developer of the Original Code is Ericsson Utvecklings AB. -# Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -# AB. All Rights Reserved.'' -# -# $Id$ -# -include $(ERL_TOP)/make/target.mk - -EBIN= ./ - -include $(ERL_TOP)/make/$(TARGET)/otp.mk - -# ---------------------------------------------------- -# Application version -# ---------------------------------------------------- -include ../../vsn.mk -VSN=$(IC_VSN) - -# ---------------------------------------------------- -# Release directory specification -# ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/ic-$(VSN) - -# ---------------------------------------------------- -# Target Specs -# ---------------------------------------------------- - -IDL_FILES = \ - ex.idl - -GEN_ERL_MODULES = \ - oe_ex \ - m_i \ - m_NotAnInteger - -MODULES= \ - m_i_impl \ - tracer - -GEN_HRL_FILES = \ - oe_ex.hrl \ - m.hrl \ - m_i.hrl - -HRL_FILES = -TXT_FILES = ReadMe.txt - -ERL_FILES= $(MODULES:%=%.erl) - - -TARGET_FILES = \ - $(GEN_ERL_MODULES:%=$(EBIN)/%.$(EMULATOR)) \ - $(MODULES:%=$(EBIN)/%.$(EMULATOR)) - -# ---------------------------------------------------- -# FLAGS -# ---------------------------------------------------- -ERL_LOCAL_FLAGS += -pa $(ERL_TOP)/lib/orber/ebin -pa $(ERL_TOP)/lib/ic/ebin -# The -pa option is just used temporary until erlc can handle -# includes from other directories than ../include . -ERL_COMPILE_FLAGS += \ - $(ERL_LOCAL_FLAGS) \ - -pa $(ERL_TOP)/lib/orber -I$(ERL_TOP)/lib/orber -YRL_FLAGS = - - -# ---------------------------------------------------- -# Targets -# ---------------------------------------------------- -debug opt: $(TARGET_FILES) - -clean: - rm -f $(TARGET_FILES) $(GEN_ERL_MODULES:%=%.erl) $(GEN_HRL_FILES) $(CLASS_FILES) IDL-GENERATED - rm -f errs core *~ - -docs: - -test: $(TEST_TARGET_FILES) - - -IDL-GENERATED: ex.idl - $(gen_verbose)erlc $(ERL_LOCAL_FLAGS) +'{precond,{tracer,pre}}' \ - +'{{postcond,"m::i::f"},{tracer,post}}' ex.idl - $(V_at)>IDL-GENERATED - -$(GEN_ERL_MODULES:%=%.erl) $(GEN_HRL_FILES): IDL-GENERATED - -$(TARGET_FILES): IDL-GENERATED - -# ---------------------------------------------------- -# Release Target -# ---------------------------------------------------- -include $(ERL_TOP)/make/otp_release_targets.mk - - -release_spec: opt - $(INSTALL_DIR) "$(RELSYSDIR)/examples/pre_post_condition" - $(INSTALL_DATA) $(ERL_FILES) $(IDL_FILES) $(TXT_FILES) "$(RELSYSDIR)/examples/pre_post_condition" - - -release_docs_spec: - - diff --git a/lib/ic/examples/pre_post_condition/ReadMe.txt b/lib/ic/examples/pre_post_condition/ReadMe.txt deleted file mode 100644 index 2fb3f0a04f..0000000000 --- a/lib/ic/examples/pre_post_condition/ReadMe.txt +++ /dev/null @@ -1,74 +0,0 @@ - ``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. - - The Initial Developer of the Original Code is Ericsson Utvecklings AB. - Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings - AB. All Rights Reserved.'' - - $Id$ - - -This example shows how pre and post condition can be used for a Corba server object. - - -The example consists of three files; - -ex.idl - the interface specification -m_i_impl.erl - the server implementation -tracer.erl - a module which contains a pre and a post condition - - -The IDL file can for example be compiled with the following options: - -ic:gen(ex, [{precond, {tracer, pre}},{{postcond, "m::i::f"}, {tracer, post}}]). - -The result is that the function m::i::f gets both a pre and post condition call while -the function m::i::g just get a pre condition call. - - -A pre/post condition function should always return the atom ok and if something is wrong -it should raise an exception ( ex: corba:raise(#userexception{}) ). - - - - -Compile all erlang files and test the application. - -First start an erlang node, then type the following commands in the erlang shell. - -1> mnesia:create_schema([]). -2> orber:install([]). -3> orber:start(). -3> -3> X = m_i:oe_create(). -4> catch m_i:f(X, 17). -Precond called in process <0.139.0>: m_i:f() [[],17] -f working .... -Postcond called in process <0.139.0>: m_i:f() [[],17] {reply,{17,17},[]} -17 -5> -5> catch m_i:f(X, q). -6> {'EXCEPTION',{m_NotAnInteger,"IDL:m/NotAnInteger:1.0"}} -7> -7>m_i:g(X, 17). -Precond called in process <0.139.0>: m_i:g() [[],17] -ok -g working .... -8> -8>corba_boa:dispose(X). -9> orber:stop(). -10> - - - - - diff --git a/lib/ic/examples/pre_post_condition/ex.idl b/lib/ic/examples/pre_post_condition/ex.idl deleted file mode 100644 index 29298c8efb..0000000000 --- a/lib/ic/examples/pre_post_condition/ex.idl +++ /dev/null @@ -1,30 +0,0 @@ -// ``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. -// -// The Initial Developer of the Original Code is Ericsson Utvecklings AB. -// Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -// AB. All Rights Reserved.'' -// -// $Id$ -// - -module m { - - exception NotAnInteger {}; - - interface i { - short f(in short i); - oneway void g(in long i); - }; - -}; - diff --git a/lib/ic/examples/pre_post_condition/m_i_impl.erl b/lib/ic/examples/pre_post_condition/m_i_impl.erl deleted file mode 100644 index fa6d9675a2..0000000000 --- a/lib/ic/examples/pre_post_condition/m_i_impl.erl +++ /dev/null @@ -1,50 +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% -%% -%% -%%------------------------------------------------------------ -%% -%% Example -%% -%%------------------------------------------------------------ --module(m_i_impl). - -%% Standard functions --export([init/1, terminate/2]). -%% Interface functions --export([f/2, g/2]). - -init(_Env) -> - {ok, []}. - -terminate(_From, _Reason) -> - ok. - -f(State, In) -> - io:format("f working ....\n", []), - {reply, In, State}. - -g(State, _In) -> - io:format("g working ....\n", []), - {noreply, State}. - - - - - diff --git a/lib/ic/examples/pre_post_condition/tracer.erl b/lib/ic/examples/pre_post_condition/tracer.erl deleted file mode 100644 index c64459f4fd..0000000000 --- a/lib/ic/examples/pre_post_condition/tracer.erl +++ /dev/null @@ -1,57 +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% -%% -%% -%%----------------------------------------------------------------- -%% File: tracer.erl -%% -%% Description: -%% This file contains an example of pre and post conditions for -%% the corba backend. -%% -%%----------------------------------------------------------------- --module(tracer). --include("m.hrl"). - -%%----------------------------------------------------------------- -%% External exports -%%----------------------------------------------------------------- --export([pre/3, post/4]). - -%%----------------------------------------------------------------- -%% Internal exports -%%----------------------------------------------------------------- --export([]). - -%%----------------------------------------------------------------- -%% External functions -%%----------------------------------------------------------------- -pre(M, F, [State, I]) when is_integer(I) -> - io:format("Precond called in process ~p: ~s:~s() ~p\n", [self(), M, F, [State, I]]), - ok; -pre(_M, _F, _A) -> %% Just an silly example to get an exception case - corba:raise(#'m_NotAnInteger'{}). - -post(M, F, A, R) -> - io:format("Postcond called in process ~p: ~s:~s() ~p ~p\n", [self(), M, F, A, R]), - ok. - -%%----------------------------------------------------------------- -%% Internal functions -%%----------------------------------------------------------------- |