19982013 Ericsson AB. 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. The C Client Back-end 2004-01-14 C ch_c_client.xml
Introduction

With the option {be, c_client} the IDL Compiler generates C client stubs according to the IDL to C mapping, on top of the Erlang distribution and gen_server protocols.

The developer has to write additional code, that together with the generated C client stubs, form a hidden Erlang node. That additional code uses erl_interface functions for defining the hidden node, and for establishing connections to other Erlang nodes.

Generated Stub Files

The generated stub files are:

For each IDL interface, a C source file, the name of which is .c]]>. Each operation of the IDL interface is mapped to a C function (with scoped name) in that file;

C source files that contain functions for type conversion, memory allocation, and data encoding/decoding;

C header files that contain function prototypes and type definitions.

All C functions are exported (i.e. not declared static).

C Interface Functions

For each IDL operation a C interface function is generated, the prototype of which is:

( oe_obj, , CORBA_Environment *oe_env);]]>

where

]]> is the value to be returned as defined by the IDL specification;

oe_obj]]> is the client interface object;

]]> is a list of parameters of the operation, defined in the same order as defined by the IDL specification;

CORBA_Environment *oe_env is a pointer to the current client environment. It contains the current file descriptor, the current input and output buffers, etc. For details see CORBA_Environment C Structure.

Generating, Compiling and Linking

To generate the C client stubs type the following in an appropriate shell:

,

where ICROOT is the root of the IC application. The -I ICROOT/include is only needed if File.idl refers to erlang.idl.

When compiling a generated C stub file, the directories ICROOT/include and EICROOT/include, have to be specified as include directories, where EIROOT is the root directory of the Erl_interface application.

When linking object files the EIROOT/lib and ICROOT/priv/lib directories have to be specified.

An Example

In this example the IDL specification file "random.idl" is used for generating C client stubs (the file is contained in the IC /examples/c-client directory):

Generate the C client stubs:

Six files are generated.

Compile the C client stubs:

Please read the ReadMe file att the examples/c-client directory

In the same directory you can find all the code for this example.

In particular you will find the client.c file that contains all the additional code that must be written to obtain a complete client.

In the examples/c-client directory you will also find source code for an Erlang server, which can be used for testing the C client.