Oninit® SQLMorph — C to UDR
c2udr turns the functions of an existing C library into Informix® C UDRs. It reads the
function prototypes in the library's headers and writes the DataBlade API wrappers that make each function callable from
SQL, the CREATE FUNCTION statements that register them, and a Makefile that links the wrappers and the library's own
C sources into one shared object. The library itself is not changed.
Nothing is parsed inside the function bodies, so the converted functions are the original C code running in the engine. c2udr's job is the boundary: how SQL types become C types and back, how NULL is handled, and how a function that returns its result through a pointer or a caller-supplied buffer becomes a function that returns a value.
c2udr is a work in progress. These pages show real output of the current version, run against an Informix 15.0 test engine; they are examples, not a released product.
What you give it, what you get
| In | Out |
|---|---|
| C header files with the function prototypes | LIB_udr.c: one wrapper function per converted C function |
The library's .c files (optional) | LIB_install.sql and LIB_remove.sql: CREATE FUNCTION / CREATE PROCEDURE and the matching DROPs |
| A map file for the library's own types (optional) | LIB.mk: builds LIB.bld |
LIB_report.md: what was converted, and for every function that was not, the reason |
c2udr.py -m mydates.map -s mydates.c -s getdateandtime.tab.c mydates.h getdateandtime.h make -f mydates.mk INFORMIXDIR=/opt/informix cp mydates.bld $INFORMIXDIR/extend/mydates/ dbaccess mydb mydates_install.sql
A SQL NULL in any argument gives a NULL result without calling the C function. A function that the headers declare but the sources do not define is skipped, because it would stop the library from loading.
In this section
| Page | What it covers |
|---|---|
| A small library | Scalars, double, strings, an output buffer and an output parameter, from header to SQL call. |
| A real date library | The mydates library: all 27 functions converted, the map file that teaches c2udr its date types, and the calls run in the engine. |
| Type mapping | How C types become SQL types, what is refused, and the map file format. |