diff options
Diffstat (limited to 'lib/ic/examples/c-client')
-rw-r--r-- | lib/ic/examples/c-client/Makefile | 87 | ||||
-rw-r--r-- | lib/ic/examples/c-client/ReadMe | 46 | ||||
-rw-r--r-- | lib/ic/examples/c-client/client.c | 131 | ||||
-rw-r--r-- | lib/ic/examples/c-client/random.idl | 52 | ||||
-rw-r--r-- | lib/ic/examples/c-client/rmod_random_impl.erl | 53 | ||||
-rw-r--r-- | lib/ic/examples/c-client/test.erl | 44 |
6 files changed, 0 insertions, 413 deletions
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]). - - - - - - - - - |