SNMP Subagent Programmer's Guide

Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-23
Nowaited Hello World Program
Example 2-3. Nowaited Hello World Source Code (page 1 of 3)
#include "tdmporth" nolist
#include "machtyph" nolist
#include "syspubh" nolist
#include "smitypeh" nolist
#include "mgmtpubh" nolist
#include "mgmtenvh" nolist /* needed for mgmt_env buffer manipulations */
<-- 1
#include "snmpvblh" nolist /* to get SNMP_MSG_MAX (also sourced by hello.h)*/
#define DEF_TEXT "Hello World"
#define DEF_FREQUENCY 15
/*
* global attributes that will be referenced by SMI
* compiler generated code. These global variables must be
* defined before the file "hello.h" is included because this
* file will make reference to these variables. These are the names
* that appear in the C_VARIABLE clauses.
*/
static char text[256] = {DEF_TEXT};
static DisplayString helloText = {sizeof(DEF_TEXT)-1, (ubyte *) text};
static INTEGER helloPrintFreq = DEF_FREQUENCY;
static Counter helloPrintCnt = 0;
#pragma nowarn (93)
#include "helloh" nolist /* SMI compiler output */
#pragma warn (93)
#include <talh> nolist
<-- 2
#include <cextdecs (FILE_GETINFO_,AWAITIOX)> nolist
static int time_to_die = 0;
/*************************************************************************
* main - nowaited hello-world demo main program.
************************************************************************/
int main(int argc, char *argv[])
{w
short count_xferd = 0;
/*
* handles to the management environment and our group
*/
struct mgmt_env *mgmt_env = NULL;
void *mgmt_hello_handle = NULL;
/* detect configuration changes */
INTEGER last_freq = helloPrintFreq;
/*
* mgmt_read_nowait stuff
*/
short agent_fileno, event_fileno,
<-- 3
status, error;
/*
* Make sure we were properly invoked
*/
if (argc != 2)
{
(void) fprintf(stderr, "Usage: run %s $<agent>\n", argv[0]);
return(2);
}