---
name: "ic_clib"
section: "3erl"
platform: "linux"
package: "erlang-manpages"
version: "1:19.2.1+dfsg-2+deb9u3"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/ic_clib"
---

# ic\_clib(3erl)

IC C Library Functions

## NAME

ic\_clib - IC C Library Functions

## DESCRIPTION

This manual page lists some of the functions in the IC C runtime library.

## ALLOCATION AND DEALLOCATION FUNCTIONS

The following functions are used for allocating and deallocating a *CORBA\_Environment* structure.

## EXPORTS

**CORBA\_Environment \*CORBA\_Environment\_alloc(int inbufsz, int outbufsz)**\

This function is used to allocate and initiate the *CORBA\_Environment* structure. In particular, it is used to dynamically allocate a CORBA\_Environment structure and set the default values for the structure's fields.

*inbufsize* is the initial size of the input buffer.

*outbufsize* is the initial size of the output buffer.

*CORBA\_Environment* is the CORBA 2.0 state structure used by the generated stub.

This function will set all needed default values and allocate buffers the lengths of which are equal to the values passed, but will not allocate space for the \_to\_pid and \_from\_pid fields.

To free the space allocated by CORBA\_Environment\_alloc() do as follows.

- \*

  First call CORBA\_free for the input and output buffers.

- \*

  After freeing the buffer space, call CORBA\_free for the CORBA\_Environment space.

**void CORBA\_free(void \*p)**\

Frees allocated space pointed to by *p*.

**CORBA\_char \*CORBA\_string\_alloc(CORBA\_unsigned\_long len)**\

Allocates a (simple) CORBA character string of length *len + 1*.

**CORBA\_wchar \*CORBA\_wstring\_alloc(CORBA\_unsigned\_long len)**\

Allocates a CORBA wide string of length *len + 1*.

## EXCEPTION FUNCTIONS

Functions for retrieving exception ids and values, and for setting exceptions.

## EXPORTS

**CORBA\_char \*CORBA\_exception\_id(CORBA\_Environment \*env)**\

Returns the exception identity if an exception is set, otherwise it returns *NULL*.

**void \*CORBA\_exception\_value(CORBA\_Environment \*env)**\

Returns the exception value, if an exception is set, otherwise it returns *NULL*.

**void CORBA\_exc\_set(CORBA\_Environment \*env, CORBA\_exception\_type Major, CORBA\_char \*Id, CORBA\_char \*Value)**\

Sets the exception type, exception identity, and exception value in the environment pointed to by *env*.

## SERVER RECEPTION

The following function is provided for convenience.

## EXPORTS

**int oe\_server\_receive(CORBA\_Environment \*env, oe\_map\_t \*map)**\
 **int oe\_server\_receive\_tmo(CORBA\_Environment \*env, oe\_map\_t \*map,  unsigned int send\_ms, unsigned int recv\_ms)**\

Provides a loop that receives one message, executes the operation in question, and in case of a two-way operation sends a reply.

*send\_ms* and *recv\_ms* specify timeout values in milliseconds for send and receive, respectively.

## GENERIC EXECUTION SWITCH AND MAP MERGING

Function for searching for server operation function, and for calling it if found. Function for merging maps (see the include file *ic.h* for definitions).

## EXPORTS

**int oe\_exec\_switch(CORBA\_Object obj, CORBA\_Environment \*env, oe\_map\_t \*map)**\

Search for server operation and execute it.

**oe\_map\_t \*oe\_merge\_maps(oe\_map\_t \*maps, int size)**\

Merge an array of server maps to one single map.

## THE CORBA\_ENVIRONMENT STRUCTURE

Here is the complete definition of the CORBA\_Environment structure, defined in file *ic.h*:

```
      /* Environment definition */
      typedef struct {
      /*----- CORBA compatibility part ------------------------*/
      /* Exception tag, initially set to CORBA_NO_EXCEPTION ---*/
      CORBA_exception_type   _major;
      /*----- External Implementation part - initiated by the user ---*/
      /* File descriptor                                              */
      int                    _fd;
      /* Size of input buffer                                         */
      int                    _inbufsz;
      /* Pointer to always dynamically allocated buffer for input     */
      char                  *_inbuf;
      /* Size of output buffer                                        */
      int                    _outbufsz;
      /* Pointer to always dynamically allocated buffer for output    */
      char                  *_outbuf;
      /* Size of memory chunks in bytes, used for increasing the output
      buffer, set to >= 32, should be around >= 1024 for performance
      reasons                                                       */
      int                    _memchunk;
      /* Pointer for registered name                                   */
      char                   _regname[256];
      /* Process identity for caller                                   */
      erlang_pid            *_to_pid;
      /* Process identity for callee                                  */
      erlang_pid            *_from_pid;
      /*- Internal Implementation part - used by the server/client ---*/
      /* Index for input buffer                                       */
      int                    _iin;
      /* Index for output buffer                                      */
      int                    _iout;
      /* Pointer for operation name                                   */
      char                   _operation[256];
      /* Used to count parameters                                    */
      int                    _received;
      /* Used to identify the caller                                  */
      erlang_pid             _caller;
      /* Used to identify the call                                     */
      erlang_ref             _unique;
      /* Exception id field                                           */
      CORBA_char            *_exc_id;
      /* Exception value field                                        */
      void                  *_exc_value;
      } CORBA_Environment;
```

**Note:**

Always set the field values *\_fd*, *\_regname*, *\_to\_pid* and/or *\*\_from\_pid* to appropriate application values. These are not automatically set by the stubs.

**Warning:**

Never assign static buffers to the buffer pointers, and never set the *\_memchunk* field to a value less than *32*.

## SEE ALSO

[ic(3erl)](/ic/3erl.md), [ic\_c\_protocol(3erl)](/ic_c_protocol/3erl.md)
