The example in this section shows how to build the FileOnOff agent using your own VCSAgStartup
entry point and the C++ version of online
, offline
, and monitor
entry points. This example implements the VCSAgStartup
, online
, offline
, and monitor
entry points only.
Example: VCSAgStartup and C++ entry points
agent.C
and modify the VCSAgStartup()
function// Description: This functions registers the entry points //
VCSAG_LOG_INIT("VCSAgStartup");
VCSAgInitEntryPointStruct(V50);
VCSAgSetEntryPoint(VCSAgEPMonitor, res_monitor);
VCSAgSetEntryPoint(VCSAgEPOnline, res_online);
VCSAgSetEntryPoint(VCSAgEPOffline, res_offline);
VCSAgSetEntryPoint(VCSAgEPClean, res_clean);
// This is a C++ implementation of the online entry
// point for the FileOnOff resource type. This function
// brings online a FileOnOff resource by creating the
// corresponding file. It is assumed that the complete
// pathname of the file will be passed as the first
unsigned int res_online(const char *res_name, void **attr_val) {
VCSAG_RES_LOG_MSG(VCS_DBG1, VCS_DEFAULT_FLAGS, L"Inside
ret = VCSAgGetEncodedArgList(VCSAgUTF8, attr_val, VCSAgUCS2,
VCSAG_LOG_MSG(VCS_NOTICE, 1001, VCS_DEFAULT_FLAGS,
L"Unable to get the arguments");
ret = vcsag_get_attr_value((wchar_t**)new_args, L"PathName",
GENERIC_READ | GENERIC_WRITE,0, NULL,
res_ATTRIBUTE_NORMAL, (HANDLE)NULL);
if (!hFile || hFile == INVALID_HANDLE_VALUE)
VCSAG_LOG_MSG(VCS_ERROR, 1002, VCS_DEFAULT_FLAGS,
VCSAG_RES_LOG_MSG(VCS_DBG1, VCS_DEFAULT_FLAGS, L"Online
VCSAgDelEncodedArgList((void**)new_args);
// Description: This function deletes the file //
unsigned int res_offline(const char *res_name, void **attr_val)
VCSAG_LOG_INIT("res_offline");
VCSAG_RES_LOG_MSG(VCS_DBG1, VCS_DEFAULT_FLAGS, L"Inside
ret = VCSAgGetEncodedArgList(VCSAgUTF8, attr_val, VCSAgUCS2,
VCSAG_LOG_MSG(VCS_NOTICE, 1001, VCS_DEFAULT_FLAGS,
L"Unable to get the arguments");
ret = vcsag_get_attr_value((wchar_t**)new_args, L"PathName",
VCSAG_LOG_MSG(VCS_ERROR, 1003, VCS_DEFAULT_FLAGS,
L"Unable to delete the file");
VCSAG_RES_LOG_MSG(VCS_DBG1, VCS_DEFAULT_FLAGS, L"offline
VCSAgDelEncodedArgList((void**)new_args);
res_monitor()
, as shown on step 5.
agent.C
and build the agent by invoking make
. (Makefile
is provided.)