GdkHandleNew


Call the GdkHandleNew function to create a handle with which to reference the gateway driver’s security module.


Syntax

VdkError GdkHandleNew(
   GdkHandleNewArg     gdkHandleNewArg,
   GdkHandle*          pgdkHandle)


Arguments

 


gdkHandleNewArg

GdkHandleNewArg   A pointer to a GdkHandleNewArgRec structure.

pgdkHandle

GdkHandle*   A pointer to the GDK library’s handle.


Member Descriptions

 

Table 9-1    GdkHandleNewArgRec Members


Member

Type/Description

name

VdkCString   The short name of the gateway driver.

gwAttrs

VdkVoidp*   A pointer to the gateway’s methods attributes table.

vdkAttrs

VdkVoidp*   A pointer to the VDK attributes table. This is an input parameter to VdkDrvNewCBFnc driver method.

flags

VdkUint4   GDK library behavior flags. The following flag is ORed together to specify the behavior: GDK_NOSECURITY Do not use security.

appData

VdkVoidp   Reserved for future use.



Returns

This function returns one of the following error codes:

VdkSuccess for success

 

VdkError_* for a standard Verity Developer Kit API error as described in the Verity Developer’s Kit Programming Reference

 

VdkFail for a non-specific error

 


Discussion

Your GDK library handle must reside in global static memory to ensure that the security module is available to all of your gateway driver’s callback functions. Typically, you call the GdkHandleNew function from your gateway driver’s VdkDrvNewCBFnc call back function.

You must create a GdkHandleNewArgRec structure and pass it to the GdkStructInit function to initialize the structure. You then must populate the members in the GdkHandleNewArgRec structure and pass it as the gdkHandleNewArg argument to the GdkHandleNew function.

Upon successful execution of the GdkHandleNew function, the pgdkHandle argument points to the GDK library handle that you use to reference the gateway’s security module.


Example

#define VGW_NAME "Verity GDK Sample Gateway"
/*Global Objects*/
static VdkInt4 nDrvCnt = 0;
static GdkHandle pGdkHandle = NULL;

static VdkError
VDK_CALLBACK VdkDrvNew(VdkCBArg* pdrvHandle, VdkInt2 argc,
VdkCString* argv, VdkVoidp* vdkAttrs)
{
VdkError error = VdkSuccess;
  VdkDrvObjs pDrvObjs;
  if( !(pDrvObjs = HeapObject(VdkDrvObjsRec)) ){
error = VdkError_OutOfMemory;
goto abort;
}
  ... /* See vgwsamp.c for complete sample. */
if (!nDrvCnt++) {
GdkHandleNewArgRec arg;

/*********************************************************
* create global gdk library handle needed to implement
* security and access gdk library support functions here
*********************************************************/

    GdkStructInit(&arg);
arg.name = (VdkCString)VGW_NAME;
arg.vdkAttrs = vdkAttrs;
    if (VdkSuccess != (error = vgwsamp((VdkVoidp*)&arg.gwAttrs))){
VdkDrvFree(pDrvObjs);
return error;
    }
    if (VdkSuccess != (error = GdkHandleNew(&arg, &pGdkHandle))) {
VdkDrvFree(pDrvObjs);
return error;
}
}
  *pdrvHandle = pDrvObjs;
return error;
}