Reactos

[dnsapi][dnsrslvr] Implement DnsFlushResolverCacheEntry_A/_UTF8/_W

+177 -27
+45
base/services/dnsrslvr/cache.c
··· 101 101 return ERROR_SUCCESS; 102 102 } 103 103 104 + 105 + DNS_STATUS 106 + DnsIntFlushCacheEntry( 107 + _In_ LPCWSTR pszName, 108 + _In_ WORD wType) 109 + { 110 + PLIST_ENTRY Entry, NextEntry; 111 + PRESOLVER_CACHE_ENTRY CacheEntry; 112 + 113 + DPRINT("DnsIntFlushCacheEntry(%S %x)\n", pszName, wType); 114 + 115 + /* Lock the cache */ 116 + DnsCacheLock(); 117 + 118 + /* Loop every entry */ 119 + Entry = DnsCache.RecordList.Flink; 120 + while (Entry != &DnsCache.RecordList) 121 + { 122 + NextEntry = Entry->Flink; 123 + 124 + /* Get this entry */ 125 + CacheEntry = CONTAINING_RECORD(Entry, RESOLVER_CACHE_ENTRY, CacheLink); 126 + 127 + /* Remove it from the list */ 128 + if ((_wcsicmp(CacheEntry->Record->pName, pszName) == 0) && 129 + (CacheEntry->bHostsFileEntry == FALSE)) 130 + { 131 + if ((wType == DNS_TYPE_ANY) || 132 + (CacheEntry->Record->wType == wType)) 133 + { 134 + DnsIntCacheRemoveEntryItem(CacheEntry); 135 + } 136 + } 137 + 138 + /* Move to the next entry */ 139 + Entry = NextEntry; 140 + } 141 + 142 + /* Unlock the cache */ 143 + DnsCacheUnlock(); 144 + 145 + return ERROR_SUCCESS; 146 + } 147 + 148 + 104 149 DNS_STATUS 105 150 DnsIntCacheGetEntryByName( 106 151 LPCWSTR Name,
+5
base/services/dnsrslvr/precomp.h
··· 53 53 _In_ ULONG ulFlags); 54 54 55 55 DNS_STATUS 56 + DnsIntFlushCacheEntry( 57 + _In_ LPCWSTR pszName, 58 + _In_ WORD wType); 59 + 60 + DNS_STATUS 56 61 DnsIntCacheGetEntryByName( 57 62 LPCWSTR Name, 58 63 WORD wType,
+20 -2
base/services/dnsrslvr/rpcserver.c
··· 60 60 DWORD 61 61 __stdcall 62 62 R_ResolverFlushCache( 63 - _In_ DNSRSLVR_HANDLE pwszServerName) 63 + _In_ DNSRSLVR_HANDLE pszServerName) 64 64 { 65 65 DPRINT("R_ResolverFlushCache(%S)\n", 66 - pwszServerName); 66 + pszServerName); 67 67 68 68 return DnsIntCacheFlush(CACHE_FLUSH_NON_HOSTS_FILE_ENTRIES); 69 + } 70 + 71 + 72 + /* Function: 0x05 */ 73 + DWORD 74 + __stdcall 75 + R_ResolverFlushCacheEntry( 76 + _In_ DNSRSLVR_HANDLE pszServerName, 77 + _In_ LPCWSTR pszName, 78 + _In_ WORD wType) 79 + { 80 + DPRINT("R_ResolverFlushCacheEntry(%S %S %x)\n", 81 + pszServerName, pszName, wType); 82 + 83 + if (pszName == NULL) 84 + return ERROR_INVALID_PARAMETER; 85 + 86 + return DnsIntFlushCacheEntry(pszName, wType); 69 87 } 70 88 71 89
+2 -2
dll/win32/dnsapi/dnsapi.spec
··· 39 39 @ stdcall DnsFindAuthoritativeZone() 40 40 @ stdcall DnsFlushResolverCache() 41 41 @ stdcall DnsFlushResolverCacheEntry_A(str) 42 - @ stdcall DnsFlushResolverCacheEntry_UTF8() 43 - @ stdcall DnsFlushResolverCacheEntry_W() 42 + @ stdcall DnsFlushResolverCacheEntry_UTF8(str) 43 + @ stdcall DnsFlushResolverCacheEntry_W(wstr) 44 44 @ stdcall DnsFree(ptr long) 45 45 @ stdcall DnsFreeAdapterInformation() 46 46 @ stub DnsFreeConfigStructure
+99
dll/win32/dnsapi/query.c
··· 951 951 return (Status == ERROR_SUCCESS); 952 952 } 953 953 954 + 955 + BOOL 956 + WINAPI 957 + DnsFlushResolverCacheEntry_A( 958 + _In_ LPCSTR pszEntry) 959 + { 960 + DNS_STATUS Status = ERROR_SUCCESS; 961 + LPWSTR pszUnicodeEntry; 962 + 963 + DPRINT1("DnsFlushResolverCacheEntry_A(%s)\n", pszEntry); 964 + 965 + if (pszEntry == NULL) 966 + return FALSE; 967 + 968 + pszUnicodeEntry = DnsCToW(pszEntry); 969 + if (pszUnicodeEntry == NULL) 970 + return FALSE; 971 + 972 + RpcTryExcept 973 + { 974 + Status = R_ResolverFlushCacheEntry(NULL, pszUnicodeEntry, DNS_TYPE_ANY); 975 + DPRINT("R_ResolverFlushCacheEntry() returned %lu\n", Status); 976 + } 977 + RpcExcept(EXCEPTION_EXECUTE_HANDLER) 978 + { 979 + Status = RpcExceptionCode(); 980 + DPRINT("Exception returned %lu\n", Status); 981 + } 982 + RpcEndExcept; 983 + 984 + RtlFreeHeap(RtlGetProcessHeap(), 0, pszUnicodeEntry); 985 + 986 + return (Status == ERROR_SUCCESS); 987 + } 988 + 989 + 990 + BOOL 991 + WINAPI 992 + DnsFlushResolverCacheEntry_UTF8( 993 + _In_ LPCSTR pszEntry) 994 + { 995 + DNS_STATUS Status = ERROR_SUCCESS; 996 + LPWSTR pszUnicodeEntry; 997 + 998 + DPRINT1("DnsFlushResolverCacheEntry_UTF8(%s)\n", pszEntry); 999 + 1000 + if (pszEntry == NULL) 1001 + return FALSE; 1002 + 1003 + pszUnicodeEntry = DnsCToW(pszEntry); 1004 + if (pszUnicodeEntry == NULL) 1005 + return FALSE; 1006 + 1007 + RpcTryExcept 1008 + { 1009 + Status = R_ResolverFlushCacheEntry(NULL, pszUnicodeEntry, DNS_TYPE_ANY); 1010 + DPRINT("R_ResolverFlushCacheEntry() returned %lu\n", Status); 1011 + } 1012 + RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1013 + { 1014 + Status = RpcExceptionCode(); 1015 + DPRINT("Exception returned %lu\n", Status); 1016 + } 1017 + RpcEndExcept; 1018 + 1019 + RtlFreeHeap(RtlGetProcessHeap(), 0, pszUnicodeEntry); 1020 + 1021 + return (Status == ERROR_SUCCESS); 1022 + } 1023 + 1024 + 1025 + BOOL 1026 + WINAPI 1027 + DnsFlushResolverCacheEntry_W( 1028 + _In_ LPCWSTR pszEntry) 1029 + { 1030 + DNS_STATUS Status = ERROR_SUCCESS; 1031 + 1032 + DPRINT1("DnsFlushResolverCacheEntry_W(%S)\n", pszEntry); 1033 + 1034 + if (pszEntry == NULL) 1035 + return FALSE; 1036 + 1037 + RpcTryExcept 1038 + { 1039 + Status = R_ResolverFlushCacheEntry(NULL, pszEntry, DNS_TYPE_ANY); 1040 + DPRINT("R_ResolverFlushCacheEntry() returned %lu\n", Status); 1041 + } 1042 + RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1043 + { 1044 + Status = RpcExceptionCode(); 1045 + DPRINT("Exception returned %lu\n", Status); 1046 + } 1047 + RpcEndExcept; 1048 + 1049 + return (Status == ERROR_SUCCESS); 1050 + } 1051 + 1052 + 954 1053 BOOL 955 1054 WINAPI 956 1055 DnsGetCacheDataTable(
-22
dll/win32/dnsapi/stubs.c
··· 216 216 return ERROR_OUTOFMEMORY; 217 217 } 218 218 219 - BOOL WINAPI 220 - DnsFlushResolverCacheEntry_A(PCSTR entry) 221 - { 222 - DPRINT1("DnsFlushResolverCacheEntry_A(%s) is stubplemented.\n", entry); 223 - if (!entry) return FALSE; 224 - return TRUE; 225 - } 226 - 227 - DNS_STATUS WINAPI 228 - DnsFlushResolverCacheEntry_UTF8() 229 - { 230 - UNIMPLEMENTED; 231 - return ERROR_OUTOFMEMORY; 232 - } 233 - 234 - DNS_STATUS WINAPI 235 - DnsFlushResolverCacheEntry_W() 236 - { 237 - UNIMPLEMENTED; 238 - return ERROR_OUTOFMEMORY; 239 - } 240 - 241 219 DNS_STATUS WINAPI 242 220 DnsFreeAdapterInformation() 243 221 {
+6 -1
sdk/include/reactos/idl/dnsrslvr.idl
··· 50 50 [in, unique, string] DNSRSLVR_HANDLE pwszServerName); 51 51 52 52 /* Function: 0x05 */ 53 - /* R_ResolverFlushCacheEntry */ 53 + DWORD 54 + __stdcall 55 + R_ResolverFlushCacheEntry( 56 + [in, unique, string] DNSRSLVR_HANDLE pwszServerName, 57 + [in, string] LPCWSTR pszName, 58 + [in] WORD wType); 54 59 55 60 /* Function: 0x06 */ 56 61 /* R_ResolverRegisterCluster */