Understanding the Sample Gateway Code


The sample gateway, vgwsamp, is a C-language program that implements all of the callback functions that define a gateway driver. In a K2 installation, the sample code is in the install/K2/platform/samples/vdk directory, where install is the directory in which K2 is installed and platform is the platform-specific directory, such as _nti40. In a VDK-only installation, the sample code is in the install/K2/platform/samples directory, where install is the directory in which VDK is installed and platform is the platform-specific directory, such as _nti40.

You should review this sample and consider using it as a model for your own gateway. The sample gateway also comes with its own style files that have already been configured to work with the sample.

The sample is divided into two sets of C source and associated header files:

The vgwsamp.c and vgwsamp.h files define the callback functions that you must implement for your driver.

 

The callback functions implemented in vgwsamp.c are structured to be used more or less “as is.” Comments in the code explain where to place your modifications and additions. Additional helper functions in vgwsamp.c that can be used without major modification start with vgw_.

The sampfunc.c. and sampfunc.h, files contain implementation-specific code for the sample gateway.

 

The functions defined in sampfunc.h typically start with vgwsamp_ and are called from functions in vgwsamp.c. The functions in sampfunc.c are designed to be completely replaced.

In addition to these two sets of files, the sample gateway also contains additional header files:

vgwmsg.h defines error and informational messages

 

sampdef.h defines helper macros

 

The sample ignores issues of how to access a repository because these issues are specific to each different kind of repository and are independent of gateway development. The sample starts from a point in which the documents in the gateway’s repository have already been parsed into tokens; these tokens are defined in vgwsamp.cfg.