SNMP Subagent Programmer's Guide

Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-25
Nowaited Hello World Program
/* If the print frequency has been modified output the
* helloFreqChange trap.
*/
if (last_freq != helloPrintFreq)
{
last_freq = helloPrintFreq;
(void) mgmt_trap(mgmt_env, &TRAP_helloFreqChange);
}
/*
* print whatever the message currently is,
* keeping a count, of course.
*/
helloText.val[helloText.len] = '\0';
(void) fputs((char *) helloText.val, stderr);
(void) fputs("\n", stderr);
helloPrintCnt++;
} /* end if agent filenumber */
else {
/* handle AWAITIO completion on other files... */
(void) fprintf(stderr, "%s:AWAITIO completed on file number %i\n", <--
11
argv[0], event_fileno);
} /* end if .. else .. */
} /* end while */
/*
* We encountered an unrecoverable condition. Clean
* up and go away.
*/
if (mgmt_env)
{
if (mgmt_hello_handle)
{
mgmt_del_instance(mgmt_env, mgmt_hello_handle);
mgmt_hello_handle = NULL;
}
mgmt_term_env(mgmt_env);
mgmt_env = NULL;
}
return(0);
}
Example 2-3. Nowaited Hello World Source Code (page 3 of 3)