SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-129
SNMPHOST Source Code
/* Compare two object identifiers with different lengths.
 * Returns -1, 0, or +1 depending whether o1 < o2, o1 == o2, or o1 > o2
 */
short
oidcmp2(short n1, OIDC_T *idp1, short n2, OIDC_T *idp2) <--8
{
 while ((n1 > 0) && (n2 > 0)) {
  if (*idp1 != *idp2)
  return (short) (*idp1 < *idp2) ? -1 : 1;
  idp1++; idp2++; n1--; n2--;
 }
 if (n1 == n2)
  return 0; /* OIDs are the same */
 else if (n1 > n2)
  return 1;
 else
  return -1;
} /* oidcmp2 */
DEV_ENTRY_T**
InitDevTable (short nNumEntries) <--9
{
 DEV_ENTRY_T **ppTable;
 short  i;
 ppTable = (DEV_ENTRY_T**) malloc (sizeof(DEV_ENTRY_T*) * nNumEntries);
 for (i = 0; i < nNumEntries; i++) {
  ppTable[i] = AllocateDevEntry ();
 }
 return ppTable;
} /* InitDevTable */
DEV_ENTRY_T*
AllocateDevEntry (void) <--10
{
 DEV_ENTRY_T* pEntry = (DEV_ENTRY_T*) malloc (sizeof(DEV_ENTRY_T));
 return pEntry;
Example 2-18. Contents of snmphosc (page 4 of 23)










