2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/dnsapi/dnsapi/context.c
5 * PURPOSE: DNSAPI functions built on the ADNS library.
6 * PROGRAMER: Art Yerkes
14 #define NTOS_MODE_USER
16 #include <internal/windns.h>
18 /* DnsAcquireContextHandle *************
19 * Create a context handle that will allow us to open and retrieve queries.
21 * DWORD CredentialsFlags -- TRUE -- Unicode
22 * FALSE -- Ansi or UTF-8?
24 * PVOID Credentials -- Pointer to a SEC_WINNT_AUTH_IDENTITY
27 * PHANDLE ContextHandle -- Pointer to a HANDLE that will receive
28 * our context pointer.
31 * ERROR_SUCCESS or a failure code.
32 * TODO: Which ones area allowed?
35 extern DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8
36 ( DWORD CredentialsFlags
,
38 HANDLE
*ContextHandle
);
40 DNS_STATUS WINAPI DnsAcquireContextHandle_W
41 ( DWORD CredentialsFlags
,
43 HANDLE
*ContextHandle
) {
44 if( CredentialsFlags
) {
45 PWINDNS_CONTEXT Context
;
48 /* For now, don't worry about the user's identity. */
49 Context
= (PWINDNS_CONTEXT
)RtlAllocateHeap( RtlGetProcessHeap(), 0,
50 sizeof( WINDNS_CONTEXT
) );
51 /* The real work here is to create an adns_state that will help us
52 * do what we want to later. */
53 adns_status
= adns_init( &Context
->State
,
58 if( adns_status
!= adns_s_ok
) {
60 return DnsIntTranslateAdnsToDNS_STATUS( adns_status
);
62 *ContextHandle
= (HANDLE
)Context
;
66 return DnsAcquireContextHandle_UTF8( CredentialsFlags
,
72 DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8
73 ( DWORD CredentialsFlags
,
75 HANDLE
*ContextHandle
) {
76 if( CredentialsFlags
) {
77 return DnsAcquireContextHandle_W( CredentialsFlags
,
81 /* Convert to unicode, then call the _W version
82 * For now, there is no conversion */
85 Status
= DnsAcquireContextHandle_W( TRUE
,
86 Credentials
, /* XXX arty */
89 /* Free the unicode credentials when they exist. */
95 DNS_STATUS WINAPI DnsAcquireContextHandle_A
96 ( DWORD CredentialFlags
,
98 HANDLE
*ContextHandle
) {
99 if( CredentialFlags
) {
100 return DnsAcquireContextHandle_W( CredentialFlags
,
104 return DnsAcquireContextHandle_UTF8( CredentialFlags
,
109 /* DnsReleaseContextHandle *************
110 * Release a context handle, freeing all resources.
113 void WINAPI DnsReleaseContextHandle
114 ( HANDLE ContextHandle
) {
115 PWINDNS_CONTEXT Context
= (PWINDNS_CONTEXT
)ContextHandle
;
116 adns_finish( Context
->State
);
117 RtlFreeHeap( RtlGetProcessHeap(), 0, Context
);