SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-128
SNMPHOST Source Code
static numprnstatus = sizeof(prn_status)/sizeof(char *);
/* Return the printer status string */
static char*
prn_status_to_str (long status) <--6
{
static char default_str[40];
if (status >= numprnstatus)
{
sprintf(default_str, "%ld (%lX)", status, status);
return (default_str);
}
return (prn_status[status]);
} /* prn_status_to_str */
/* Provide name to OID translation. Fills in the passed OID buffer
* and returns the number of components needed for the OID, 0 if not
* found. */
short
oidstring2oid (const char *name, /* name to search for */ <--7
OIDC_T *oid, /* OID buffer to fill */
short oidlen) /* length of OID buffer */
{
short count;
count = 0;
while (*name) {
if (count < oidlen)
oid[count] = atol(name);
while (isdigit(*name))
name++;
if (*name == '.')
name++;
count++;
}
return count;
} /* oidstring2oid */
Example 2-18. Contents of snmphosc (page 3 of 23)