SNMP Subagent Programmer's Guide

Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-53
Dynamic Directory Program
/*****************************************************************************
* locate_file This routine returns the context <--
14
* pointer for a row specified in the indices
* parameter.
****************************************************************************/
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); <--
15
for (file = dir->files; file; file = file->next)
{
/*
* If we find an exact match, bail out.
*/
if (comp_files(name, &file->file_name) == 0) <--
16
{
break;
}
}
/*
* Will return NULL if no match was found.
*/
return((Void *) file);
#pragma nowarn (93)
}
Example 2-10. Dynamic Directory Main Program and Next and Locator
Functions (page 4 of 4)