A driver is implemented as a set of functions, referred to as methods. The methods enable onpload to open, close, read, and write data files. You can create a custom driver that adds more complex functionality to data-file handling of onpload.
A custom driver consists of one or more functions that replace the capability of an existing driver method. The custom driver needs to provide all of the methods for a driver, such as OPEN, READ, WRITE, and CLOSE.
To add to the capability of an existing driver method, the custom driver function calls the existing driver method from the custom function before or after any custom processing, as appropriate.
To replace an existing driver method, the custom function provides all processing that is necessary for that function. The custom driver function does not call the existing standard driver functions.
To prepare the custom-driver code, you must prepare the following two files. You can store the files in any convenient directory.
This appendix includes an example of driver files, Driver Example. Use this example as a template for building your driver code.
The driver methods and API functions that you can use are described in Available Driver Methods and Available API Support Functions.
/******************************************************* * Start of plcstdrv.c */ /* plcstdrv.h is in $INFORMIXDIR/incl/hpl */ #include "plcstdrv.h" /* Your driver configuration function */ int your_driver_config_function(); (*pl_get_user_method(driver, method)) () char *driver; int method; { /* * your_driver_name is the name of your driver */ if (strcmp(driver, "your_driver_name") == 0) { /* * If onpload is trying to configure the driver, * return the function that will handle the * initialization. */ if (method == PL_MTH_CONFIGURE) return(your_driver_config_function); } /* * YYYY is the name of another driver * This is how additional custom drivers are configured */ if (strcmp(driver, "YYYY") == 0) { if (method == PL_MTH_CONFIGURE) return(YYYY_driver_config_function); } } /***************** end of plcstdrv.c *******************/