[Erlang Systems]

6 Using the C Client Back-end

6.1 Introduction

The mapping of OMG IDL to the C programming language when C Server switch is the back-end of choice is identical to the one used in C IDL mapping. The only difference is on the generated code, and that the idl functions are translated to C functions for the C client.

6.2 When to Use the C-Client?

A C-client uses the same communication protocol as an Erlang client to genservers, as it is actually a C-genserver client. Therefore, the C-client can be used for:

6.3 What Kind of Code is Produced?

The code produced is a collection of:

All functions found in the code are exported. The user is free to define his own client if there is a need for this. The basic client generated is a synchronous client, but an asynchronous client can be implemented by proper use of exported functions.

6.4 What Does This Code Do when Used?

The main functionality of a C client is to:

6.5 What Is the Interface of the Functions Produced?

The C source defines the following functions:

The interface for the client function is:

< Return Value > < Scoped Function Name > ( < Interface Object > oe_obj, < Parameters > CORBA_Environment *oe_env );

Where:

The interface for the message encoding functions is:

int < Scoped Function Name >__client_enc(< Interface Object > oe_obj, < Input Parameters > CORBA_Environment *oe_env );

Where:

The interface for the specific result value decoder is:

int < Scoped Function Name >__client_dec(< Interface Object > oe_obj, < Return/Out Values > CORBA_Environment *oe_env);

Where:

The interface for the generic decoding function is:

int < Scoped Interface Name >__receive_info(< Interface Object > oe_obj, CORBA_Environment *oe_env );

Where:

6.6 Functions Used for Internal Purposes

Depending on the data defined and used in the IDL code, C-source files may be generated that hold functions used internally. This is the case when other types than the elementary IDL types are used by the IDL file definitions. All these files must be compiled and linked to the other code.

6.7 Which Header Files to Include?

The only header files that must be included are :

6.8 Which Directories/Libraries/Options must Be Included under C-compiling?

Under compilation you will have to include :

Under linking you will have to link with :

6.9 Compiling the Code

In the Erlang shell type:

ic:gen(< filename >, [{be, c_client}]).

6.10 An Example

In this example, a file "random.idl" is generates code for the plain erlang back-end:

Compile the file:

      Erlang (BEAM) emulator version 4.9
      
      Eshell V4.9  (abort with ^G)
      1> ic:gen(random,[{be, c_client}]).
      Erlang IDL compiler version 3.2
      ok
      2> 
    

When the file "random.idl" is compiled it produces five files, two for the top scope, two for the interface scope, and one for the module scope. The header files for top scope and interface are empty and not shown here. In this case only the file for the interface rmod_random.erl is important:.

Compiling the code:

Note!

Due to changes to allow buffer expansion, a new receiving function some changes in CORBA_Environment initialization are applied. The example in the ic-3.2/examples/c-client directory demonstrates these changes.

Running the example:


Copyright © 1991-2001 Ericsson Utvecklings AB