Home | Previous Page | Next Page   Appendix E. Custom-Conversion Functions >

The onpload Conversion Process

The onpload conversion process is identical for both import or export operations. The onpload utility:

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.

To integrate your custom-conversion functions into the onpload executable
  1. 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, 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 */
  2. 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 */
        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 */
  3. Rebuild the onpload shared-library file ipldd09a.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.

  4. 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.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]