ReactOS 0.4.15-dev-8058-ga7cbb60
context.c
Go to the documentation of this file.
1/*
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
7 * UPDATE HISTORY:
8 * 12/15/03 -- Created
9 */
10
11#include "precomp.h"
12
13#define NDEBUG
14#include <debug.h>
15
16/* DnsAcquireContextHandle *************
17 * Create a context handle that will allow us to open and retrieve queries.
18 *
19 * DWORD CredentialsFlags -- TRUE -- Unicode
20 * FALSE -- Ansi or UTF-8?
21 *
22 * PVOID Credentials -- Pointer to a SEC_WINNT_AUTH_IDENTITY
23 * TODO: Use it.
24 *
25 * PHANDLE ContextHandle -- Pointer to a HANDLE that will receive
26 * our context pointer.
27 *
28 * RETURNS:
29 * ERROR_SUCCESS or a failure code.
30 * TODO: Which ones area allowed?
31 */
32
33extern DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8(DWORD CredentialsFlags, PVOID Credentials, HANDLE *ContextHandle);
34
35DNS_STATUS WINAPI
37 PVOID Credentials,
38 HANDLE *ContextHandle)
39{
40 if(CredentialsFlags)
41 {
43 int adns_status;
44
45 /* For now, don't worry about the user's identity. */
46 Context = (PWINDNS_CONTEXT)RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(WINDNS_CONTEXT));
47
48 if(!Context)
49 {
50 *ContextHandle = 0;
51 return ERROR_OUTOFMEMORY;
52 }
53
54 /* The real work here is to create an adns_state that will help us
55 * do what we want to later. */
57
59 {
60 *ContextHandle = 0;
61 RtlFreeHeap(RtlGetProcessHeap(), 0, Context);
63 }
64 else
65 {
66 *ContextHandle = (HANDLE)Context;
67 return ERROR_SUCCESS;
68 }
69 }
70 else
71 {
72 return DnsAcquireContextHandle_UTF8(CredentialsFlags, Credentials, ContextHandle);
73 }
74}
75
76DNS_STATUS WINAPI
78 PVOID Credentials,
79 HANDLE *ContextHandle)
80{
81 if( CredentialsFlags )
82 {
83 return DnsAcquireContextHandle_W(CredentialsFlags, Credentials, ContextHandle);
84 }
85 else
86 {
87 /* Convert to unicode, then call the _W version
88 * For now, there is no conversion */
89 DNS_STATUS Status;
90
91 Status = DnsAcquireContextHandle_W(TRUE, Credentials, /* XXX arty */ ContextHandle);
92
93 /* Free the unicode credentials when they exist. */
94
95 return Status;
96 }
97}
98
99DNS_STATUS WINAPI
101 PVOID Credentials,
102 HANDLE *ContextHandle)
103{
104 if(CredentialFlags)
105 {
106 return DnsAcquireContextHandle_W(CredentialFlags, Credentials, ContextHandle);
107 }
108 else
109 {
110 return DnsAcquireContextHandle_UTF8(CredentialFlags, Credentials, ContextHandle);
111 }
112}
113
114/* DnsReleaseContextHandle *************
115 * Release a context handle, freeing all resources.
116 */
117void WINAPI
119{
120 PWINDNS_CONTEXT Context = (PWINDNS_CONTEXT)ContextHandle;
121
122 adns_finish(Context->State);
123 RtlFreeHeap(RtlGetProcessHeap(), 0, Context);
124}
DNS_STATUS DnsIntTranslateAdnsToDNS_STATUS(int Status)
Definition: adns.c:17
ADNS_API void adns_finish(adns_state ads)
Definition: setup.c:650
ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:568
@ adns_if_noerrprint
Definition: adns.h:89
@ adns_if_noenv
Definition: adns.h:88
@ adns_if_noserverwarn
Definition: adns.h:90
adns_status
Definition: adns.h:215
@ adns_s_ok
Definition: adns.h:216
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
DNS_STATUS WINAPI DnsAcquireContextHandle_A(DWORD CredentialFlags, PVOID Credentials, HANDLE *ContextHandle)
Definition: context.c:100
void WINAPI DnsReleaseContextHandle(HANDLE ContextHandle)
Definition: context.c:118
DNS_STATUS WINAPI DnsAcquireContextHandle_W(DWORD CredentialsFlags, PVOID Credentials, HANDLE *ContextHandle)
Definition: context.c:36
DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8(DWORD CredentialsFlags, PVOID Credentials, HANDLE *ContextHandle)
Definition: context.c:77
struct WINDNS_CONTEXT * PWINDNS_CONTEXT
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
PVOID HANDLE
Definition: typedefs.h:73
#define WINAPI
Definition: msvc.h:6