snmpapi: Implement SnmpUtilOidCpy, SnmpUtilOidFree and SnmpUtilVarBindFree.

This commit is contained in:
Hans Leidekker 2007-01-14 19:19:52 +01:00 committed by Alexandre Julliard
parent d62b5c6cd9
commit f1fc35de38
3 changed files with 66 additions and 3 deletions

View File

@ -24,6 +24,8 @@
#include "windef.h"
#include "winbase.h"
#include "snmp.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(snmpapi);
@ -50,3 +52,61 @@ BOOL WINAPI DllMain(
return TRUE;
}
INT WINAPI SnmpUtilOidCpy(AsnObjectIdentifier *dst, AsnObjectIdentifier *src)
{
unsigned int i, size;
TRACE("(%p, %p)\n", dst, src);
size = sizeof(AsnObjectIdentifier);
if ((dst = HeapAlloc(GetProcessHeap(), 0, size)))
{
size = src->idLength * sizeof(UINT);
if (!(dst->ids = HeapAlloc(GetProcessHeap(), 0, size)))
{
HeapFree(GetProcessHeap(), 0, dst);
return SNMPAPI_ERROR;
}
dst->idLength = src->idLength;
for (i = 0; i < dst->idLength; i++) dst->ids[i] = src->ids[i];
return SNMPAPI_NOERROR;
}
return SNMPAPI_ERROR;
}
void WINAPI SnmpUtilOidFree(AsnObjectIdentifier *oid)
{
TRACE("(%p)\n", oid);
HeapFree(GetProcessHeap(), 0, oid->ids);
HeapFree(GetProcessHeap(), 0, oid);
}
void WINAPI SnmpUtilVarBindFree(SnmpVarBind *vb)
{
TRACE("(%p)\n", vb);
switch (vb->value.asnType)
{
case ASN_OCTETSTRING:
case ASN_BITS:
case ASN_SEQUENCE:
case ASN_IPADDRESS:
case ASN_OPAQUE:
{
if (vb->value.asnValue.string.dynamic)
HeapFree(GetProcessHeap(), 0, vb->value.asnValue.string.stream);
break;
}
case ASN_OBJECTIDENTIFIER:
{
HeapFree(GetProcessHeap(), 0, vb->value.asnValue.object.ids);
break;
}
default: break;
}
HeapFree(GetProcessHeap(), 0, vb->name.ids);
HeapFree(GetProcessHeap(), 0, vb);
}

View File

@ -25,8 +25,8 @@
@ stub SnmpUtilMemReAlloc
@ stub SnmpUtilOidAppend
@ stub SnmpUtilOidCmp
@ stub SnmpUtilOidCpy
@ stub SnmpUtilOidFree
@ stdcall SnmpUtilOidCpy(ptr ptr)
@ stdcall SnmpUtilOidFree(ptr)
@ stub SnmpUtilOidNCmp
@ stub SnmpUtilOidToA
@ stub SnmpUtilPrintAsnAny
@ -34,6 +34,6 @@
@ stub SnmpUtilStrlenW
@ stub SnmpUtilUnicodeToAnsi
@ stub SnmpUtilVarBindCpy
@ stub SnmpUtilVarBindFree
@ stdcall SnmpUtilVarBindFree(ptr)
@ stub SnmpUtilVarBindListCpy
@ stub SnmpUtilVarBindListFree

View File

@ -201,6 +201,9 @@ typedef struct {
#define SNMP_AUTHAPI_INVALID_MSG_TYPE 31
#define SNMP_AUTHAPI_TRIV_AUTH_FAILED 32
#define SNMPAPI_NOERROR TRUE
#define SNMPAPI_ERROR FALSE
#ifdef __cplusplus
extern "C" {
#endif