SNMP Subagent Programmer's Guide
Hello World Program
2-16 119728—SNMP Subagent Programmer’s Guide
Programming Tutorials
Example 2-2. Hello World Source Code (page 1 of 2)
/*************************************************************************
 *  hello.c - demo hello world program to illustrate how an application
 *   which uses global data may be made manageable.
 ************************************************************************/
#include "tdmporth"  nolist                       
<-- 1
#include "machtyph" nolist
#include "syspubh"  nolist
#include "smitypeh" nolist
#include "mgmtpubh" nolist
#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};    
<-- 2
static INTEGER     helloPrintFreq = DEF_FREQUENCY;
static Counter   helloPrintCnt = 0;
#pragma nowarn (93)                           
<-- 3
#include "helloh"       /* SMI compiler output */            
<-- 4
#pragma warn (93)
static int       time_to_die = 0;                  
<-- 5
/*************************************************************************
 *  main - hello-world demo main program.
 ************************************************************************/
int
main(int argc,                             
<-- 6
    char *argv[])
...
{
   short dummy = 0;                         
<-- 7
   /*
    *   handles to the management environment and our group
    */
   void         *mgmt_env = NULL;
   void     *mgmt_hello_handle = NULL;
 /*
    *    detect configuration changes
    */
   INTEGER       last_freq = helloPrintFreq;
   /*
    *    Make sure we were properly invoked
    */
   if (argc != 2)                          
<-- 8
   {
     (void) fprintf(stderr, "Usage: run %s: $<agent>\n", argv[0]);
       return(1);
   }
   /*
    *    Set up the management environment.  We'll talk to the local
    *    agent, registering ourselves as 1.3.6.1.4.1.442.2.1
    *    with no password.
    */










