The onpload conversion process is identical for both import or export operations. The onpload utility:
For more information, see HPLAPIVERSION.
The custom-conversion function API uses ASCII strings as the canonical data type. The API functions present data as ASCII strings and expect data from the custom-conversion functions to be presented as ASCII strings. The API functions convert source data of different types to ASCII strings, and also convert ASCII string data from custom-conversion functions to destination data types.
Custom-conversion functions are loaded into the onpload executable through a shared library.
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, respectively. 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 */
/* * 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 */ int buflen; /* 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 */ int buflen; /* max size of buffer */ char *value; /* input value */ { /* your processing here */ } /* end of your_custom_conversion.c */
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.