eSNMP API Routines
mem2oct
mem2oct
Converts a string (a buffer and length) to an
oct
structure with the new buffer’s
address and length.
Format
oct *mem2oct ( oct *new,
char *buffer,
int *len );
Arguments
new
A pointer to the
oct
structure receiving the data.
buffer
Pointer to the buffer to be converted.
len
Length of buffer to be converted.
Description
The
mem2oct
routine dynamically allocates the buffer and inserts its pointer into
the
oct
structure. The caller must explicitly free this buffer.
This routine does not allocate an
oct
structure and does not free data previously
pointed to in the
oct
structure before making the assignment.
Return Values
Null
An error occurred. Otherwise, the pointer to the
oct
structure (the first argument) is returned.
Example
#include <esnmp.h>
char buffer;
int len;
OCT abc;
...buffer and len are initialized to something...
memset(&abc, 0, sizeof(OCT));
if (mem2oct(&abc, buffer, len) == NULL)
DPRINTF((WARNING,"It did not work...\n"));
5–52 eSNMP API Routines