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 #include <internal/windns.h>
16 /* DnsAcquireContextHandle *************
17 * Create a context handle that will allow us to open and retrieve queries.
19 * DWORD CredentialsFlags -- TRUE -- Unicode
20 * FALSE -- Ansi or UTF-8?
22 * PVOID Credentials -- Pointer to a SEC_WINNT_AUTH_IDENTITY
25 * PHANDLE ContextHandle -- Pointer to a HANDLE that will receive
26 * our context pointer.
29 * ERROR_SUCCESS or a failure code.
30 * TODO: Which ones area allowed?
33 extern DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8
34 ( DWORD CredentialsFlags
,
36 HANDLE
*ContextHandle
);
38 DNS_STATUS WINAPI DnsAcquireContextHandle_W
39 ( DWORD CredentialsFlags
,
41 HANDLE
*ContextHandle
) {
42 if( CredentialsFlags
) {
43 PWINDNS_CONTEXT Context
;
46 /* For now, don't worry about the user's identity. */
47 Context
= (PWINDNS_CONTEXT
)RtlAllocateHeap( RtlGetProcessHeap(), 0,
48 sizeof( WINDNS_CONTEXT
) );
49 /* The real work here is to create an adns_state that will help us
50 * do what we want to later. */
51 adns_status
= adns_init( &Context
->State
,
56 if( adns_status
!= adns_s_ok
) {
58 return DnsIntTranslateAdnsToDNS_STATUS( adns_status
);
60 *ContextHandle
= (HANDLE
)Context
;
64 return DnsAcquireContextHandle_UTF8( CredentialsFlags
,
70 DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8
71 ( DWORD CredentialsFlags
,
73 HANDLE
*ContextHandle
) {
74 if( CredentialsFlags
) {
75 return DnsAcquireContextHandle_W( CredentialsFlags
,
79 /* Convert to unicode, then call the _W version
80 * For now, there is no conversion */
83 Status
= DnsAcquireContextHandle_W( TRUE
,
84 Credentials
, /* XXX arty */
87 /* Free the unicode credentials when they exist. */
93 DNS_STATUS WINAPI DnsAcquireContextHandle_A
94 ( DWORD CredentialFlags
,
96 HANDLE
*ContextHandle
) {
97 if( CredentialFlags
) {
98 return DnsAcquireContextHandle_W( CredentialFlags
,
102 return DnsAcquireContextHandle_UTF8( CredentialFlags
,
107 /* DnsReleaseContextHandle *************
108 * Release a context handle, freeing all resources.
111 void WINAPI DnsReleaseContextHandle
112 ( HANDLE ContextHandle
) {
113 PWINDNS_CONTEXT Context
= (PWINDNS_CONTEXT
)ContextHandle
;
114 adns_finish( Context
->State
);
115 RtlFreeHeap( RtlGetProcessHeap(), 0, Context
);