SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-34
Common Utility Functions
hexcheck()
The hexcheck() function accepts a pointer to an ASCII or hexadecimal string value and
returns the number of bytes in the string.
count
is the number of bytes in the string. In the case of ASCII strings, for which you use
a double colon (::) to encode a colon, only one of the colons is counted. In the case
of hexadecimal strings, for which you use a single colon to separate hexadecimal
characters (for example, 65:69), each pair is counted as one byte.
string-value
is a pointer to an all-ASCII or all-hexadecimal string value. The hexcheck()
function changes this value as follows. For ASCII strings, one of the colons in any
double-colon pair is eliminated:
Before: This is my colon :: as you can see
After: This is my colon : as you can see
For hexadecimal strings, their ASCII equivalents are written at the start of the
character buffer:
Before: 48:65:6C:6C:6F
After: Hello 6C 6C 6F
oid_to_namerec()
The oid_to_namerec() function accepts a pointer to a structure of type OBJ_ID_T
describing a MIB-II object OID and returns the name and type of the object to a
namerec structure, using an internal mapping table. If the OID is not for a MIB-II
object, this function returns 0.
p
is a pointer to the namerec structure, defined in print.h:
#include "printh"
count = hexcheck(string-value);
int
hexcheck(char *string-value);
#include "printh"
p = oid_to_namerec(oid);
struct namerec* oid_to_namerec (OBJ_ID_T *oid);