SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-89
SNMPWALK
  default:
   fprintf(stdout, usage, whoami);
   exit(0); 
  } /* switch */
 } /* while */
 if (argc > 2 || argc == 0)
 {
  fprintf(stdout, usage, whoami);
  exit(0); 
 }
 if (argc >= 1)
 {
  hostname = *argv;
  argv++,argc--;
 }
 if (argc == 1)
  oidstr = *argv;
 /* Init the output file */
 outfile = stdout;
 /* Read the MIB tree file (and init the mibt global) */
 read_mib ("mibrt"); <--3
 /* convert string to OID using the just loaded MIB tree */
 base_oid.num_components = string2oid (oidstr, <--4
     base_oid.component_list, MAX_OID_COUNT);
 if (base_oid.num_components == 0)
 {
  fprintf(stdout, "Bad object identifier: %s\n", oidstr);
  exit(0); 
 }
 opt2 = SNMP_Init_(&host_int, sizeof(host_int), hostname); <--5
 switch (opt2)
 {
  case 0: case 1:
  break;
  default:
  exit(0);
 } /* switch */
 /* Now I can override any default. This must be done before the */
 /* call to SNMP_Open_.           */
Example 2-11. Contents of snmpwlkc (page 4 of 7)










