5.1.1.4.4 vtable Setting Function
vtable
is a particular C structure that stores the necessary function pointers for the actual businesss logic of a plug-in interface. In other words, a valid plug-in interface must implement all the functions defined by the corresponding vtable.
The vtable setting function uses the following syntax:
int _ws_pi_set_vtbl_@ID@_@Name@(void * priv);
@ID@
indicates the actual plug-in ID value. @Name@
indicates the actual plug-in name value. For example, the vtable
setting function of a plug-in with P_CUSTOM_TYPE
as a plug-in ID and MyType
as a plug-in name is:
_ws_pi_set_vtbl_P_CUSTOM_TYPE_MyType(void * priv)
The vtabl
e structures may be different for different plug-in ID categories. For this SALT release, P_CUSTOM_TYPE
and P_CREDENMA
P are the only valid plug-in IDs.
The vtable
structures for available plug-in interfaces are shown in in the example below:
Example 5-1 VTable Structure
struct credmap_vtable {
int (* gwws_pi_map_http_basic) (char * domain, char * realm, char * t_userid, char * t_grpid, Cred_UserPass * credential); /* used for HTTP Basic Authentication */
/* for future use */
void * unused_1;
void * unused_2;
void * unused_3;
};
struct
credmap_vtable indicates that one function must be implemented for a P_CREDENMAP
plug-in interface. For more information, see How Outbound Authentication Plug-Ins Work
The function input parameter void * priv
points to a concrete vtable
instance. You should set the vtable
structure with the actual functions in the vtable
setting function.
An example of setting the vtable
structure with actual functions in the vtable
setting function is shown in the example below:
Example 5-2 Setting the vtable Structure with Actual Functions in the vtable Setting Function
int _DLLEXPORT_ _ws_pi_set_vtbl_P_CREDENMAP_TEST (void * vtbl)
{
struct credmap_vtable * vtable;
if ( ! vtbl )
return -1;
vtable = (struct credmap_vtable *) vtbl;
vtable->gwws_pi_map_http_basic = Credmap_HTTP_Basic;
return 0;
}
Parent topic: Plug-In Register Functions