SNMP Subagent Programmer's Guide

Callback Functions
4-34 119728SNMP Subagent Programmer’s Guide
Writing Subagent Logic
To process a Get or Set request, the run-time library uses locate_file(), the locate
function. This function builds the table, creating an entry for each file currently
associated with the most recently defined subvolume name. To build the table, the
locate function calls build_files(), and to identify whether an input file name matches a
name in the table, the locate function calls comp_files().
Void *
locate_file(Void *ctxt,
Void **indices,
int op)
...
{
struct directory *dir = (struct directory *) ctxt;
DisplayString *name = (DisplayString *)indices[0];
struct file_entry *file;
/*
* Build the cache of names.
*/
build_files(dir);
for (file = dir->files; file; file = file->next)
{
/*
* If we find an exact match, bail out.
*/
if (comp_files(name, &file->file_name) == 0)
{
break;
}
}
/*
* Will return NULL if no match was found.
*/
return((Void *) file);
}
To process a GetNext request, the run-time library uses next_file() before using
locate_file(). The next_file() function is a next function; refer to the example under
“Next Functions,” the following subsection, for information on next_file().