#ifdef __MWERKS__
#define _CPP_PLUGINSESSION
#endif
#include <Security/pluginsession.h>
#include <Security/cssmplugin.h>
#include <Security/DLsession.h>
PluginSession::PluginSession(CSSM_MODULE_HANDLE theHandle,
CssmPlugin &plug,
const CSSM_VERSION &version,
uint32 subserviceId,
CSSM_SERVICE_TYPE subserviceType,
CSSM_ATTACH_FLAGS attachFlags,
const CSSM_UPCALLS &inUpcalls)
: HandledObject(theHandle), plugin(plug), upcalls(inUpcalls)
{
mVersion = version;
mSubserviceId = subserviceId;
mSubserviceType = subserviceType;
mAttachFlags = attachFlags;
}
PluginSession::~PluginSession()
{
}
void PluginSession::detach()
{
}
void *PluginSession::malloc(size_t size) throw(std::bad_alloc)
{
if (void *addr = upcalls.malloc_func(handle(), size))
return addr;
CssmError::throwMe(CSSM_ERRCODE_MEMORY_ERROR);
}
void *PluginSession::realloc(void *oldAddr, size_t size) throw(std::bad_alloc)
{
if (void *addr = upcalls.realloc_func(handle(), oldAddr, size))
return addr;
CssmError::throwMe(CSSM_ERRCODE_MEMORY_ERROR);
}
void PluginSession::sendCallback(CSSM_MODULE_EVENT event,
uint32 subId,
CSSM_SERVICE_TYPE serviceType) const
{
plugin.sendCallback(event,
(subId == uint32(-1)) ? mSubserviceId : subId,
serviceType ? serviceType : mSubserviceType);
}