Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencontext.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS system libraries 00004 * FILE: lib/dnsapi/dnsapi/context.c 00005 * PURPOSE: DNSAPI functions built on the ADNS library. 00006 * PROGRAMER: Art Yerkes 00007 * UPDATE HISTORY: 00008 * 12/15/03 -- Created 00009 */ 00010 00011 #include "precomp.h" 00012 00013 #define NDEBUG 00014 #include <debug.h> 00015 00016 /* DnsAcquireContextHandle ************* 00017 * Create a context handle that will allow us to open and retrieve queries. 00018 * 00019 * DWORD CredentialsFlags -- TRUE -- Unicode 00020 * FALSE -- Ansi or UTF-8? 00021 * 00022 * PVOID Credentials -- Pointer to a SEC_WINNT_AUTH_IDENTITY 00023 * TODO: Use it. 00024 * 00025 * PHANDLE ContextHandle -- Pointer to a HANDLE that will receive 00026 * our context pointer. 00027 * 00028 * RETURNS: 00029 * ERROR_SUCCESS or a failure code. 00030 * TODO: Which ones area allowed? 00031 */ 00032 00033 extern DNS_STATUS WINAPI DnsAcquireContextHandle_UTF8(DWORD CredentialsFlags, PVOID Credentials, HANDLE *ContextHandle); 00034 00035 DNS_STATUS WINAPI 00036 DnsAcquireContextHandle_W(DWORD CredentialsFlags, 00037 PVOID Credentials, 00038 HANDLE *ContextHandle) 00039 { 00040 if(CredentialsFlags) 00041 { 00042 PWINDNS_CONTEXT Context; 00043 int adns_status; 00044 00045 /* For now, don't worry about the user's identity. */ 00046 Context = (PWINDNS_CONTEXT)RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(WINDNS_CONTEXT)); 00047 00048 if(!Context) 00049 { 00050 *ContextHandle = 0; 00051 return ERROR_OUTOFMEMORY; 00052 } 00053 00054 /* The real work here is to create an adns_state that will help us 00055 * do what we want to later. */ 00056 adns_status = adns_init(&Context->State, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn, 0); 00057 00058 if(adns_status != adns_s_ok) 00059 { 00060 *ContextHandle = 0; 00061 RtlFreeHeap(RtlGetProcessHeap(), 0, Context); 00062 return DnsIntTranslateAdnsToDNS_STATUS(adns_status); 00063 } 00064 else 00065 { 00066 *ContextHandle = (HANDLE)Context; 00067 return ERROR_SUCCESS; 00068 } 00069 } 00070 else 00071 { 00072 return DnsAcquireContextHandle_UTF8(CredentialsFlags, Credentials, ContextHandle); 00073 } 00074 } 00075 00076 DNS_STATUS WINAPI 00077 DnsAcquireContextHandle_UTF8(DWORD CredentialsFlags, 00078 PVOID Credentials, 00079 HANDLE *ContextHandle) 00080 { 00081 if( CredentialsFlags ) 00082 { 00083 return DnsAcquireContextHandle_W(CredentialsFlags, Credentials, ContextHandle); 00084 } 00085 else 00086 { 00087 /* Convert to unicode, then call the _W version 00088 * For now, there is no conversion */ 00089 DNS_STATUS Status; 00090 00091 Status = DnsAcquireContextHandle_W(TRUE, Credentials, /* XXX arty */ ContextHandle); 00092 00093 /* Free the unicode credentials when they exist. */ 00094 00095 return Status; 00096 } 00097 } 00098 00099 DNS_STATUS WINAPI 00100 DnsAcquireContextHandle_A(DWORD CredentialFlags, 00101 PVOID Credentials, 00102 HANDLE *ContextHandle) 00103 { 00104 if(CredentialFlags) 00105 { 00106 return DnsAcquireContextHandle_W(CredentialFlags, Credentials, ContextHandle); 00107 } 00108 else 00109 { 00110 return DnsAcquireContextHandle_UTF8(CredentialFlags, Credentials, ContextHandle); 00111 } 00112 } 00113 00114 /* DnsReleaseContextHandle ************* 00115 * Release a context handle, freeing all resources. 00116 */ 00117 void WINAPI 00118 DnsReleaseContextHandle(HANDLE ContextHandle) 00119 { 00120 PWINDNS_CONTEXT Context = (PWINDNS_CONTEXT)ContextHandle; 00121 00122 adns_finish(Context->State); 00123 RtlFreeHeap(RtlGetProcessHeap(), 0, Context); 00124 } Generated on Sat May 26 2012 04:18:58 for ReactOS by
1.7.6.1
|