From f1fc35de3872c5e07b55df988d1c6f6bdf3b2fbd Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Sun, 14 Jan 2007 19:19:52 +0100 Subject: [PATCH] snmpapi: Implement SnmpUtilOidCpy, SnmpUtilOidFree and SnmpUtilVarBindFree. --- dlls/snmpapi/main.c | 60 +++++++++++++++++++++++++++++++++++++++ dlls/snmpapi/snmpapi.spec | 6 ++-- include/snmp.h | 3 ++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/dlls/snmpapi/main.c b/dlls/snmpapi/main.c index 114aa925798..71c793cb509 100644 --- a/dlls/snmpapi/main.c +++ b/dlls/snmpapi/main.c @@ -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); +} diff --git a/dlls/snmpapi/snmpapi.spec b/dlls/snmpapi/snmpapi.spec index 1452ad789ca..ec59e9cf193 100644 --- a/dlls/snmpapi/snmpapi.spec +++ b/dlls/snmpapi/snmpapi.spec @@ -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 diff --git a/include/snmp.h b/include/snmp.h index e453b723b8a..aaece6c1ef1 100644 --- a/include/snmp.h +++ b/include/snmp.h @@ -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