unsigned int (*info) (const char *res_name,
VCSAgResInfoOp resinfo_op, void **attr_val, char
**info_output, char ***opt_update_args, char
You may select any name for the function.
The resinfo_op
parameter indicates whether to initialize or update the data in the ResourceInfo
attribute. The values of this field and their significance are described in the following table:
The parameter info_output
is a character string that stores the output of the info
entry point. The output value could be any summarized data for the resource. The Msg
key in the ResourceInfo
attribute is updated with info_output
. If the info
entry point exits with success (0), the output stored in info_output
is dumped into the Msg
key of the ResourceInfo
attribute.
The info
entry point is responsible for allocating memory for info_output
. The agent framework handles the deletion of any memory allocated to this argument. Since memory is allocated in the entry point and deleted in the agent framework, the entry point needs to pass the address of the allocated memory to the agent framework.
The opt_update_args
parameter is an array of character strings that represents the various name-value pairs in the ResourceInfo
attribute. This argument is allocated memory in the info
entry point, but the memory allocated for it will be freed in the agent framework. The ResourceInfo
attribute is updated with these name-value pairs. The names in this array must already be present in the ResourceInfo
attribute.
ResourceInfo = { State = Valid, Msg = "Info entry point output",
TS = "Wed May 28 10:34:11 2003", FileOwner = root,
FileGroup = root, FileSize = 100 }
A valid opt_update_args
array for this ResourceInfo
attribute would be:
opt_update_args = { "FileSize", "102" }
This array of name-value pairs updates the dynamic data stored in the ResourceInfo
attribute.
An invalid opt_update_args
array would be one that specifies a key not already present in the ResourceInfo
attribute or one that specifies any of the keys: State
, Msg
, or TS
. These three keys can only be updated by the agent framework and not by the entry point.
opt_add_args
is an array of character strings that represent the various name-value pairs to be added to the ResourceInfo
attribute. The names in this array represent keys that are not already present in the ResourceInfo
association list and have to be added to the attribute. This argument is allocated memory in the info
entry point, but this memory is freed in the agent framework. The ResourceInfo
attribute is populated with these name-value pairs.
ResourceInfo = { State = Valid, Msg = "Info entry point output",
TS = "Wed May 28 10:34:11 2003" }
A valid opt_add_args
array for this would be:
opt_add_args = { "FileOwner", "root", "FileGroup", "root",
This array of name-value pairs adds to and initializes the static and dynamic data stored in the ResourceInfo
attribute.
An invalid opt_add_args
array would be one that specifies a key that is already present in the ResourceInfo
attribute, or one that specifies any of the keys State
, Msg
, or TS
; these are keys that can be updated only by the agent framework, not by the entry point.
Set the VCSAgValidateAndSetEntryPoint()
parameter to the name of the entry point's function (res_info
).
Allocate the info
output buffer in the entry point as shown in the example below. The buffer can be any size (the example uses 80), but the agent framework truncates it to 2048 bytes. For the optional name-value pairs, name and value each have a limit of 4096 bytes (the example uses 15).
extern "C" unsigned int res_info(const char *res_name, VCSAgResInfoOp resinfo_op, void **attr_val, char **info_output, char ***opt_update_args, char ***opt_add_args)
VCSAgSnprintf(out, 80,"Output of info entry point - updates
the \"Msg\" key in ResourceInfo attribute");
// Use the stat system call on the file to get its
// information The attr_val array will look like "PathName"
// "1" "<pathname value>" ... Assuming that PathName is the
// first attribute in the attr_val array, the value
// of this attribute will be in index 2 of this attr_val
if ((strlen((CHAR *)(attr_val[2])) != 0) &&
(stat((CHAR *)(attr_val[2]), &stat_buf) == 0)) {
if (resinfo_op == VCSAgResInfoAdd) {
// Add and initialize all the static and
// dynamic keys in the ResourceInfo attribute
// All the static information - file owner
VCSAgSnprintf(args[0], 15, "%s", "Owner");
VCSAgSnprintf(args[1], 15, "%d",
VCSAgSnprintf(args[2], 15, "%s", "Group");
VCSAgSnprintf(args[3], 15, "%d", stat_buf.st_gid);
// Initialize the dynamic information for the file
VCSAgSnprintf(args[4], 15, "%s", "FileSize");
VCSAgSnprintf(args[5], 15, "%d",
// Simply update the dynamic keys in the
// ResourceInfo attribute. In this case, the
VCSAgSnprintf(args[0], 15, "%s", "FileSize");
VCSAgSnprintf(args[1], 15, "%d",
// Set the output to indicate the error
VCSAgSnprintf(out, 80, "Stat on the file %s failed",
// Set the output to indicate the error
VCSAgSnprintf(out, 80, "Error in arglist values passed to
// Successful completion of the info entry point
} // End of entry point definition
The following example is for a V40 entry point:
res_info(const char *res_name, VCSAgResInfoOp resinfo_op,
void **attr_val, char **info_output, char
***opt_update_args, char ***opt_add_args) {
"Output of info entry point...updates the "Msg" key in ResourceInfo attribute");
// Use the stat system call on the file to get its information
if ((attr_val) && (*attr_val)) {
if ((stat((CHAR *)(*attr_val), &stat_buf) == 0) &&
(strlen((CHAR *)(*attr_val)) != 0)) {
if (resinfo_op == VCSAgResInfoAdd) {
// Add and initialize all the static and
// dynamic keys in the ResourceInfo attribute
// All the static information - file owner and group
VCSAgSnprintf(args[0], 15, "%s", "Owner");
VCSAgSnprintf(args[1], 15, "%d", stat_buf.st_uid);
VCSAgSnprintf(args[2], 15, "%s", "Group");
VCSAgSnprintf(args[3], 15, "%d", stat_buf.st_gid);
// Initialize the dynamic information for the file
VCSAgSnprintf(args[4], 15, "%s", "FileSize");
VCSAgSnprintf(args[5], 15, "%d", stat_buf.st_size);
// Simply update the dynamic keys in the ResourceInfo
// attribute. In this case, the dynamic info on the file
VCSAgSnprintf(args[0], 15, "%s", "FileSize");
VCSAgSnprintf(args[1], 15, "%d", stat_buf.st_size);
// Set the output to indicate the error
VCSAgSnprintf(out, 80, "Stat on the file %s failed",
// Set the output to indicate the error
"Error in arglist values passed to the info entry