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
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
) );
52 return ERROR_OUTOFMEMORY
;
55 /* The real work here is to create an adns_state that will help us
56 * do what we want to later. */
57 adns_status
= adns_init( &Context
->State
,
62 if( adns_status
!= adns_s_ok
) {
64 RtlFreeHeap( RtlGetProcessHeap(), 0, Context
);
65 return DnsIntTranslateAdnsToDNS_STATUS( adns_status
);
67 *ContextHandle
= (HANDLE
)Context
;
71 return DnsAcquireContextHandle_UTF8( CredentialsFlags
,
77 DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8
78 ( DWORD CredentialsFlags
,
80 HANDLE
*ContextHandle
) {
81 if( CredentialsFlags
) {
82 return DnsAcquireContextHandle_W( CredentialsFlags
,
86 /* Convert to unicode, then call the _W version
87 * For now, there is no conversion */
90 Status
= DnsAcquireContextHandle_W( TRUE
,
91 Credentials
, /* XXX arty */
94 /* Free the unicode credentials when they exist. */
100 DNS_STATUS WINAPI DnsAcquireContextHandle_A
101 ( DWORD CredentialFlags
,
103 HANDLE
*ContextHandle
) {
104 if( CredentialFlags
) {
105 return DnsAcquireContextHandle_W( CredentialFlags
,
109 return DnsAcquireContextHandle_UTF8( CredentialFlags
,
114 /* DnsReleaseContextHandle *************
115 * Release a context handle, freeing all resources.
118 void WINAPI DnsReleaseContextHandle
119 ( HANDLE ContextHandle
) {
120 PWINDNS_CONTEXT Context
= (PWINDNS_CONTEXT
)ContextHandle
;
121 adns_finish( Context
->State
);
122 RtlFreeHeap( RtlGetProcessHeap(), 0, Context
);