CK_DECLARE_FUNCTION_POINTER
CK_DECLARE_FUNCTION_POINTER(returnType, name), when followed by a parentheses-enclosed list of arguments and a semicolon, declares a variable or type which is a pointer to a Cryptoki API function in a Cryptoki library. returnType is the return type of the function, and name is its name. It can be used in either of the following fashions to define a function pointer variable, myC_Initialize, which can point to a C_Initialize function in a Cryptoki library (note that neither of the following code snippets actually assigns a value to myC_Initialize):
CK_DECLARE_FUNCTION_POINTER(CK_RV, myC_Initialize)(
CK_VOID_PTR pReserved
);
or:
typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, myC_InitializeType)(
CK_VOID_PTR pReserved
);
myC_InitializeType myC_Initialize;
CK_CALLBACK_FUNCTION(returnType, name), when followed by a parentheses-enclosed list of arguments and a semicolon, declares a variable or type which is a pointer to an application callback function that can be used by a Cryptoki API function in a Cryptoki library. returnType is the return type of the function, and name is its name. It can be used in either of the following fashions to define a function pointer variable, myCallback, which can point to an application callback which takes arguments args and returns a CK_RV (note that neither of the following code snippets actually assigns a value to myCallback):
CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
or:
typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
myCallbackType myCallback;
NULL_PTR is the value of a NULL pointer. In any ANSI C environment—and in many others as well—NULL_PTR should be defined simply as 0.
7.3.1. Win32
Developers using Microsoft Developer Studio 5.0 to produce C or C++ code which implements or makes use of a Win32 Cryptoki .dll might issue the following directives before including any Cryptoki header files:
#pragma pack(push, cryptoki, 1)
#define CK_PTR *
#define CK_DEFINE_FUNCTION(returnType, name) \
returnType __declspec(dllexport) name
#define CK_DECLARE_FUNCTION(returnType, name) \
returnType __declspec(dllimport) name
#define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
returnType __declspec(dllimport) (* name)
#define CK_CALLBACK_FUNCTION(returnType, name) \
returnType (* name)
#ifndef NULL_PTR
#define NULL_PTR 0
#endif
After including any Cryptoki header files, they might issue the following directives to reset the structure packing to its earlier value:
#pragma pack(pop, cryptoki)
Share with your friends: |