SNMP Subagent Programmer's Guide
Static Directory Program
2-38 119728—SNMP Subagent Programmer’s Guide
Programming Tutorials
{
   struct directory    *dir;                    
<-- 2
   struct file_entry   *file;
   Void         *mgmt_env;
   Void         *group_handle;
   Void         *row_handle;
   short dummy = 0;
   /*  Check command line invocation: expect 1 parameter  */
   if (argc != 2)
   {
       (void) fprintf(stderr, "Usage: run %s $<agent>\n", argv[0]);
       exit(2);
   }
   /*
    *    initialize context structure. Start with the default
    *    directory name of "/tmp" ("zsnmpsdk" on Tandem).
    */
   dir = (struct directory *)safe_malloc(sizeof(*dir));           
<-- 3
   dir->dir_name.val = (ubyte *)safe_malloc(MAX_dirName + 1);
   (void) strcpy((char *) dir->dir_name.val, "zsnmpsdk");          
<-- 4
...
   dir->dir_name.len = strlen((char *)dir->dir_name.val);
   dir->files = NULL;
   /*
    *   Initialize the session with the SMUX agent.
    */
   mgmt_env = mgmt_init_env(argv[1],                  
<-- 5
             (ObjId_t *) &GI_staticdir,
             "Fixed LS Example",
             (Octets_t *) NULL,
             (void_function) NULL);
   if (mgmt_env == NULL)
   {
       (void) fprintf(stderr, "%s: failed to connect to agent\n",
             argv[0]);w
       exit(2);
   }
   /*
   *  Instantiate the group that contains the table.
    */
   group_handle = mgmt_new_instance(mgmt_env,         
<-- 6
                 &SMI_GROUP_staticdir,
                 (void *) dir);
Example 2-6. Static Directory Main Program (page 2 of 3)










