Develop a Custom Function in C

Overview

Convert between DML registers and simple C types

Compile for an integration engine

Example C function

Overview

General steps:

  1. Develop a C function on the integration engine server that will execute the function.

The user-created function must conform to specific syntax rules and use API functions described in this topic.

After you create the function, you deposit the dynamic library for the function in the folder:

$CORE_LOCAL/config/runtime/mappingcomponent/running/Generated/Function.

  1. In Mapping Services, create a Custom Function object that references the C function on the integration engine server.
  2. In Mapping Services, in an Integration Process object, create a DML expression that references the Custom-Fuction.
  3. In Mapping Services, Execute a Send to Server command on the Integration Task that links the Integration Process object the execution server.

Convert between DML registers and simple C types

DML registers are an internal representation of each data class in Mapping Services. You use the DML registers to allocate memory for the Custom Function return values.

There are six different DML classes and corresponding registers:

  • Boolean
  • Integer
  • String
  • Real number
  • Date and time
  • VLO

Register conversion functions enable the conversion between the DML classes and the simple C types.

DML classes/registers correspond to simple C types as shown in the following table:

DML classes/registers Simple C types

B Boolean

int

I Integer

long

D Date

struct tm

S String

char*

R Real number

double

V Binary

char*

Note: The register date conversion functions do not take into account the following C struct tm fields:

  • tm_wday
  • tm_yday
  • tm_isdst

Functions: Convert DML registers to simple C types

The Register to simple C type conversion functions must not return references to internal objects.

These functions return Void types, because if an error occurs, the instance handling is stopped.

For the classes that are represented by a string, the API includes a size interrogation function.

The following functions map DML registers into simple C types:

For performance reasons, reference for the V (Binary) and S (String) classes are read-only.

Functions: Convert simple C types to DML registers

The following functions transform simple C types into DML registers:

Functions: Return value properties

In DML, the property value of a register can be:

  • Null
  • Absent
  • Valued

To manage the properties of a register, you can use the following functions:

Compile for an integration engine

You implement the functions you create for integration engine in dynamic libraries. The library filename extension depends on the operating system:

  • $CORE_ROOT/bin/libXIBcf.so (UNIX)
  • $CORE_ROOT\bin\libXIBcf.dll (Windows)
  • $CORE_ROOT/bin/libXIBcf.sl (HP-UX)

Before you compile a new version of the library, you must stop the Integration Task that uses the functions in that library.

Alternatively, you can use a new dynamic library.

Use the makefile script

To compile a function, use the example makefile script that is delivered with the product in the folder:

$CORE_LOCAL/config/runtime/mappingcomponent/running/Generated/Function/CF_Makefile

You need to adapt this script according to your particular requirements. For example you may need to export symbols or add directories for the includes or libraries.

The following is an example of the makefile script.

 

Makefile script example

To execute the script, enter the command make/nmake -f CF_Makefile.

The makefile script compiles and copies the C Custom Function to the target directory.

Example C function

Example C function

Related topics

Use Custom Functions

Related Links