Integrating custom conversion functions
Custom-conversion functions are loaded into the onpload executable command through a shared library.
To integrate your custom-conversion functions into the onpload executable command:
- Prepare the custom-conversion function table.
The onpload utility uses the entries in a function table to translate custom-function string names that are specified in the load or unload map. You must supply the function table and the custom-conversion functions.
To code the function table, use the following template for the file plcstcnv.c. You can copy this template from the $INFORMIXDIR/incl/hpl directory. Add as many entries into the functiontable array as needed.
The onpload utility searches the functiontable array for the string name of the custom-conversion function that the map specifies. The function pointer that is associated with the string name is retrieved and used as the custom-conversion function. In the following template for the file plcstcnv.c, ycf1 and ycf2 are the strings that ipload uses to find the custom functions your_conversion_func1 and your_conversion_func2. To add custom function string names to the onpload database, see Mapping options./* * plcstcnv.c */ #include "pldriver.h" extern int your_conversion_func1(); extern int your_conversion_func2(); struct functable functiontable[] = { {"ycf1", your_conversion_func1}, {"ycf2", your_conversion_func2}, {0, 0} }; /* end of plcstcnv.c */
- Prepare your conversion functions. Use the template in
the following example to code your conversion functions:
/* * your_custom_conversion.c */ /* * The argument list must be adhered to. */ int your_conversion_func1(outbuffer, buflen, value) char *outbuffer; /* where to put your output */ intbuflen;/* max size of buffer in bytes*/ char *value; /* input value */ { /* your processing here */ } int your_conversion_func2(outbuffer, buflen, value) char *outbuffer; /* where to put your output */ intbuflen;/* max size of buffer */ char *value; /* input value */ { /* your processing here */ } /* end of your_custom_conversion.c */
- Rebuild the onpload shared-library file ipldd11a.SOLIBSUFFIX,
(where SOLIBSUFFIX is the shared-library suffix
for your platform). Follow the instructions in Rebuilding the shared-library file.
The onpload utility uses the same library for both custom-conversion functions and custom drivers. When you rebuild the library, if there are custom drivers, you must link the custom-driver code as well as the custom-conversion functions.
- Install the shared library in the appropriate path for your platform. For example, on Solaris the shared library should be installed in $INFORMIXDIR/lib or any configurable path that is specified by the HPL_DYNAMIC_LIB_PATH configuration parameter.