Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1928c7c4
Commit
1928c7c4
authored
Jan 22, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 22, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
snmpapi: Implement SnmpUtilAsnAny{Cpy,Free}.
parent
71a2f4d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
76 deletions
+115
-76
main.c
dlls/snmpapi/main.c
+113
-74
snmpapi.spec
dlls/snmpapi/snmpapi.spec
+2
-2
No files found.
dlls/snmpapi/main.c
View file @
1928c7c4
/*
/*
*
Stub i
mplementation of SNMPAPI.DLL
*
I
mplementation of SNMPAPI.DLL
*
*
* Copyright 2002 Patrik Stridvall
* Copyright 2002 Patrik Stridvall
* Copyright 2007 Hans Leidekker
* Copyright 2007 Hans Leidekker
...
@@ -31,6 +31,85 @@
...
@@ -31,6 +31,85 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
snmpapi
);
WINE_DEFAULT_DEBUG_CHANNEL
(
snmpapi
);
static
INT
asn_any_copy
(
AsnAny
*
dst
,
AsnAny
*
src
)
{
memset
(
dst
,
0
,
sizeof
(
AsnAny
));
switch
(
src
->
asnType
)
{
case
ASN_INTEGER32
:
dst
->
asnValue
.
number
=
src
->
asnValue
.
number
;
break
;
case
ASN_UNSIGNED32
:
dst
->
asnValue
.
unsigned32
=
src
->
asnValue
.
unsigned32
;
break
;
case
ASN_COUNTER64
:
dst
->
asnValue
.
counter64
=
src
->
asnValue
.
counter64
;
break
;
case
ASN_COUNTER32
:
dst
->
asnValue
.
counter
=
src
->
asnValue
.
counter
;
break
;
case
ASN_GAUGE32
:
dst
->
asnValue
.
gauge
=
src
->
asnValue
.
gauge
;
break
;
case
ASN_TIMETICKS
:
dst
->
asnValue
.
ticks
=
src
->
asnValue
.
ticks
;
break
;
case
ASN_OCTETSTRING
:
case
ASN_BITS
:
case
ASN_SEQUENCE
:
case
ASN_IPADDRESS
:
case
ASN_OPAQUE
:
{
BYTE
*
stream
;
UINT
length
=
src
->
asnValue
.
string
.
length
;
if
(
!
(
stream
=
HeapAlloc
(
GetProcessHeap
(),
0
,
length
)))
return
SNMPAPI_ERROR
;
dst
->
asnValue
.
string
.
stream
=
stream
;
dst
->
asnValue
.
string
.
length
=
length
;
dst
->
asnValue
.
string
.
dynamic
=
TRUE
;
break
;
}
case
ASN_OBJECTIDENTIFIER
:
{
UINT
*
ids
,
i
,
size
=
src
->
asnValue
.
object
.
idLength
*
sizeof
(
UINT
);
if
(
!
(
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
return
SNMPAPI_ERROR
;
dst
->
asnValue
.
object
.
ids
=
ids
;
dst
->
asnValue
.
object
.
idLength
=
src
->
asnValue
.
object
.
idLength
;
for
(
i
=
0
;
i
<
dst
->
asnValue
.
object
.
idLength
;
i
++
)
dst
->
asnValue
.
object
.
ids
[
i
]
=
src
->
asnValue
.
object
.
ids
[
i
];
break
;
}
default:
{
WARN
(
"unknown ASN type: %d
\n
"
,
src
->
asnType
);
return
SNMPAPI_ERROR
;
}
}
dst
->
asnType
=
src
->
asnType
;
return
SNMPAPI_NOERROR
;
}
static
void
asn_any_free
(
AsnAny
*
any
)
{
switch
(
any
->
asnType
)
{
case
ASN_OCTETSTRING
:
case
ASN_BITS
:
case
ASN_SEQUENCE
:
case
ASN_IPADDRESS
:
case
ASN_OPAQUE
:
{
if
(
any
->
asnValue
.
string
.
dynamic
)
{
HeapFree
(
GetProcessHeap
(),
0
,
any
->
asnValue
.
string
.
stream
);
any
->
asnValue
.
string
.
stream
=
NULL
;
}
break
;
}
case
ASN_OBJECTIDENTIFIER
:
{
HeapFree
(
GetProcessHeap
(),
0
,
any
->
asnValue
.
object
.
ids
);
any
->
asnValue
.
object
.
ids
=
NULL
;
break
;
}
default:
break
;
}
any
->
asnType
=
ASN_NULL
;
}
/***********************************************************************
/***********************************************************************
* DllMain for SNMPAPI
* DllMain for SNMPAPI
*/
*/
...
@@ -82,6 +161,24 @@ void WINAPI SnmpUtilMemFree(LPVOID mem)
...
@@ -82,6 +161,24 @@ void WINAPI SnmpUtilMemFree(LPVOID mem)
}
}
/***********************************************************************
/***********************************************************************
* SnmpUtilAsnAnyCpy (SNMPAPI.@)
*/
INT
WINAPI
SnmpUtilAsnAnyCpy
(
AsnAny
*
dst
,
AsnAny
*
src
)
{
TRACE
(
"(%p, %p)
\n
"
,
dst
,
src
);
return
asn_any_copy
(
dst
,
src
);
}
/***********************************************************************
* SnmpUtilAsnAnyFree (SNMPAPI.@)
*/
void
WINAPI
SnmpUtilAsnAnyFree
(
AsnAny
*
any
)
{
TRACE
(
"(%p)
\n
"
,
any
);
asn_any_free
(
any
);
}
/***********************************************************************
* SnmpUtilOidCpy (SNMPAPI.@)
* SnmpUtilOidCpy (SNMPAPI.@)
*/
*/
INT
WINAPI
SnmpUtilOidCpy
(
AsnObjectIdentifier
*
dst
,
AsnObjectIdentifier
*
src
)
INT
WINAPI
SnmpUtilOidCpy
(
AsnObjectIdentifier
*
dst
,
AsnObjectIdentifier
*
src
)
...
@@ -126,67 +223,25 @@ INT WINAPI SnmpUtilVarBindCpy(SnmpVarBind *dst, SnmpVarBind *src)
...
@@ -126,67 +223,25 @@ INT WINAPI SnmpUtilVarBindCpy(SnmpVarBind *dst, SnmpVarBind *src)
TRACE
(
"(%p, %p)
\n
"
,
dst
,
src
);
TRACE
(
"(%p, %p)
\n
"
,
dst
,
src
);
if
(
!
(
dst
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
SnmpVarBind
))))
if
(
!
dst
)
return
SNMPAPI_ERROR
;
return
SNMPAPI_ERROR
;
if
(
!
src
)
size
=
src
->
name
.
idLength
*
sizeof
(
UINT
);
if
(
!
(
dst
->
name
.
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
goto
error
;
for
(
i
=
0
;
i
<
src
->
name
.
idLength
;
i
++
)
dst
->
name
.
ids
[
i
]
=
src
->
name
.
ids
[
i
];
dst
->
name
.
idLength
=
src
->
name
.
idLength
;
dst
->
value
.
asnType
=
src
->
value
.
asnType
;
switch
(
dst
->
value
.
asnType
)
{
{
case
ASN_INTEGER32
:
dst
->
value
.
asnValue
.
number
=
src
->
value
.
asnValue
.
number
;
break
;
dst
->
value
.
asnType
=
ASN_NULL
;
case
ASN_UNSIGNED32
:
dst
->
value
.
asnValue
.
unsigned32
=
src
->
value
.
asnValue
.
unsigned32
;
break
;
return
SNMPAPI_NOERROR
;
case
ASN_COUNTER64
:
dst
->
value
.
asnValue
.
counter64
=
src
->
value
.
asnValue
.
counter64
;
break
;
case
ASN_COUNTER32
:
dst
->
value
.
asnValue
.
counter
=
src
->
value
.
asnValue
.
counter
;
break
;
case
ASN_GAUGE32
:
dst
->
value
.
asnValue
.
gauge
=
src
->
value
.
asnValue
.
gauge
;
break
;
case
ASN_TIMETICKS
:
dst
->
value
.
asnValue
.
ticks
=
src
->
value
.
asnValue
.
ticks
;
break
;
case
ASN_OCTETSTRING
:
case
ASN_BITS
:
case
ASN_SEQUENCE
:
case
ASN_IPADDRESS
:
case
ASN_OPAQUE
:
{
BYTE
*
stream
;
UINT
length
=
src
->
value
.
asnValue
.
string
.
length
;
if
(
!
(
stream
=
HeapAlloc
(
GetProcessHeap
(),
0
,
length
)))
goto
error
;
dst
->
value
.
asnValue
.
string
.
stream
=
stream
;
dst
->
value
.
asnValue
.
string
.
length
=
length
;
dst
->
value
.
asnValue
.
string
.
dynamic
=
TRUE
;
break
;
}
}
case
ASN_OBJECTIDENTIFIER
:
{
UINT
*
ids
,
size
=
src
->
name
.
idLength
*
sizeof
(
UINT
);
if
(
!
(
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
size
=
src
->
name
.
idLength
*
sizeof
(
UINT
);
goto
error
;
if
(
!
(
dst
->
name
.
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
return
SNMPAPI_ERROR
;
dst
->
value
.
asnValue
.
object
.
ids
=
ids
;
for
(
i
=
0
;
i
<
src
->
name
.
idLength
;
i
++
)
dst
->
name
.
ids
[
i
]
=
src
->
name
.
ids
[
i
]
;
dst
->
value
.
asnValue
.
object
.
idLength
=
src
->
value
.
asnValue
.
object
.
idLength
;
dst
->
name
.
idLength
=
src
->
name
.
idLength
;
for
(
i
=
0
;
i
<
dst
->
value
.
asnValue
.
object
.
idLength
;
i
++
)
if
(
!
asn_any_copy
(
&
dst
->
value
,
&
src
->
value
))
dst
->
value
.
asnValue
.
object
.
ids
[
i
]
=
src
->
value
.
asnValue
.
object
.
ids
[
i
];
break
;
}
default:
{
{
WARN
(
"unknown ASN type: %d
\n
"
,
src
->
value
.
asnType
);
HeapFree
(
GetProcessHeap
(),
0
,
dst
->
name
.
ids
);
break
;
return
SNMPAPI_ERROR
;
}
}
}
return
SNMPAPI_NOERROR
;
return
SNMPAPI_NOERROR
;
error:
HeapFree
(
GetProcessHeap
(),
0
,
dst
->
name
.
ids
);
HeapFree
(
GetProcessHeap
(),
0
,
dst
);
return
SNMPAPI_ERROR
;
}
}
/***********************************************************************
/***********************************************************************
...
@@ -196,28 +251,12 @@ void WINAPI SnmpUtilVarBindFree(SnmpVarBind *vb)
...
@@ -196,28 +251,12 @@ void WINAPI SnmpUtilVarBindFree(SnmpVarBind *vb)
{
{
TRACE
(
"(%p)
\n
"
,
vb
);
TRACE
(
"(%p)
\n
"
,
vb
);
switch
(
vb
->
value
.
asnType
)
if
(
!
vb
)
return
;
{
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
;
}
asn_any_free
(
&
vb
->
value
);
HeapFree
(
GetProcessHeap
(),
0
,
vb
->
name
.
ids
);
HeapFree
(
GetProcessHeap
(),
0
,
vb
->
name
.
ids
);
HeapFree
(
GetProcessHeap
(),
0
,
vb
);
vb
->
name
.
idLength
=
0
;
vb
->
name
.
ids
=
NULL
;
}
}
/***********************************************************************
/***********************************************************************
...
...
dlls/snmpapi/snmpapi.spec
View file @
1928c7c4
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
@ stub SnmpSvcSetLogLevel
@ stub SnmpSvcSetLogLevel
@ stub SnmpSvcSetLogType
@ stub SnmpSvcSetLogType
@ stub SnmpUtilAnsiToUnicode
@ stub SnmpUtilAnsiToUnicode
@ st
ub SnmpUtilAsnAnyCpy
@ st
dcall SnmpUtilAsnAnyCpy(ptr ptr)
@ st
ub SnmpUtilAsnAnyFree
@ st
dcall SnmpUtilAsnAnyFree(ptr)
@ stub SnmpUtilDbgPrint
@ stub SnmpUtilDbgPrint
@ stub SnmpUtilIdsToA
@ stub SnmpUtilIdsToA
@ stdcall SnmpUtilMemAlloc(long)
@ stdcall SnmpUtilMemAlloc(long)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment