SNMP Subagent Programmer's Guide

Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-39
Static Directory Program
if (group_handle == NULL)
{
(void) fprintf(stderr, "%s: group instantiation failure\n",
argv[0]);
exit(2);
}
/* Build the cache of file names. */
build_files(dir);
<-- 7
...
/* Register each file name as a row of the fileEntry table. */
for (file = dir->files; file; file = file->next)
{
/* the row_handle is not saved since each
* row of the table is never deleted. */
row_handle = mgmt_new_instance(mgmt_env,
<-- 8
&SMI_GROUP_fileEntry, (Void *) file);
if (row_handle == NULL)
{
(void) fprintf(stderr,
"%s: row instantiation failure\n",
argv[0]);
exit(2);
}
}
/* Do nothing but process SNMP requests as they come in.
* The program will only be terminated by a signal or death
* of the agent. */
while (1)
{
if (mgmt_poll(mgmt_env, (struct timeval *)NULL,&dummy)
<-- 9
< 0)
{
(void) fprintf(stderr, "%s: agent unavailable\n",
argv[0]);
exit(2);
}
}
}
Example 2-6. Static Directory Main Program (page 3 of 3)