Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygennscatent.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS WinSock 2 API 00004 * FILE: nscatent.c 00005 * PURPOSE: Namespace Catalog Entry Object 00006 * PROGRAMMER: Alex Ionescu (alex@relsoft.net) 00007 */ 00008 00009 /* INCLUDES ******************************************************************/ 00010 #include "ws2_32.h" 00011 00012 /* DATA **********************************************************************/ 00013 00014 /* FUNCTIONS *****************************************************************/ 00015 00016 PNSCATALOG_ENTRY 00017 WSAAPI 00018 WsNcEntryAllocate(VOID) 00019 { 00020 PNSCATALOG_ENTRY CatalogEntry; 00021 00022 /* Allocate the catalog */ 00023 CatalogEntry = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*CatalogEntry)); 00024 00025 /* Set the default non-null members */ 00026 CatalogEntry->RefCount = 1; 00027 CatalogEntry->Enabled = TRUE; 00028 CatalogEntry->AddressFamily = -1; 00029 00030 /* Return it */ 00031 return CatalogEntry; 00032 } 00033 00034 VOID 00035 WSAAPI 00036 WsNcEntryDelete(IN PNSCATALOG_ENTRY CatalogEntry) 00037 { 00038 /* Check if a provider is loaded */ 00039 if (CatalogEntry->Provider) 00040 { 00041 /* Dereference it too */ 00042 WsNpDereference(CatalogEntry->Provider); 00043 CatalogEntry->Provider = NULL; 00044 } 00045 00046 /* Delete us */ 00047 HeapFree(WsSockHeap, 0, CatalogEntry); 00048 } 00049 00050 VOID 00051 WSAAPI 00052 WsNcEntryDereference(IN PNSCATALOG_ENTRY CatalogEntry) 00053 { 00054 /* Dereference and check if it's now 0 */ 00055 if (!(InterlockedDecrement(&CatalogEntry->RefCount))) 00056 { 00057 /* We can delete the Provider now */ 00058 WsNcEntryDelete(CatalogEntry); 00059 } 00060 } 00061 00062 INT 00063 WSAAPI 00064 WsNcEntryInitializeFromRegistry(IN PNSCATALOG_ENTRY CatalogEntry, 00065 IN HKEY ParentKey, 00066 IN ULONG UniqueId) 00067 { 00068 CHAR CatalogEntryName[13]; 00069 HKEY EntryKey; 00070 ULONG RegType = REG_SZ; 00071 ULONG RegSize = MAX_PATH; 00072 00073 /* Convert to a 00000xxx string */ 00074 sprintf(CatalogEntryName, "%0""12""i", (int)UniqueId); 00075 00076 /* Open the Entry */ 00077 RegOpenKeyEx(ParentKey, 00078 CatalogEntryName, 00079 0, 00080 KEY_READ, 00081 &EntryKey); 00082 00083 /* Read the Library Path */ 00084 RegQueryValueExW(EntryKey, 00085 L"LibraryPath", 00086 0, 00087 &RegType, 00088 (LPBYTE)&CatalogEntry->DllPath, 00089 &RegSize); 00090 00091 /* Query Display String Size*/ 00092 RegQueryValueExW(EntryKey, 00093 L"DisplayString", 00094 0, 00095 NULL, 00096 NULL, 00097 &RegSize); 00098 00099 /* Allocate it */ 00100 CatalogEntry->ProviderName = (LPWSTR)HeapAlloc(WsSockHeap, 0, RegSize); 00101 00102 /* Read it */ 00103 RegQueryValueExW(EntryKey, 00104 L"DisplayString", 00105 0, 00106 &RegType, 00107 (LPBYTE)CatalogEntry->ProviderName, 00108 &RegSize); 00109 00110 /* Read the Provider Id */ 00111 RegType = REG_BINARY; 00112 RegSize = sizeof(GUID); 00113 RegQueryValueEx(EntryKey, 00114 "ProviderId", 00115 0, 00116 &RegType, 00117 (LPBYTE)&CatalogEntry->ProviderId, 00118 &RegSize); 00119 00120 /* Read the Address Family */ 00121 RegType = REG_DWORD; 00122 RegSize = sizeof(DWORD); 00123 RegQueryValueEx(EntryKey, 00124 "AddressFamily", 00125 0, 00126 &RegType, 00127 (LPBYTE)&CatalogEntry->AddressFamily, 00128 &RegSize); 00129 00130 /* Read the Namespace Id */ 00131 RegQueryValueEx(EntryKey, 00132 "SupportedNamespace", 00133 0, 00134 &RegType, 00135 (LPBYTE)&CatalogEntry->NamespaceId, 00136 &RegSize); 00137 00138 /* Read the Enabled Flag */ 00139 RegQueryValueEx(EntryKey, 00140 "Enabled", 00141 0, 00142 &RegType, 00143 (LPBYTE)&CatalogEntry->Enabled, 00144 &RegSize); 00145 00146 /* Read the Version */ 00147 RegQueryValueEx(EntryKey, 00148 "Version", 00149 0, 00150 &RegType, 00151 (LPBYTE)&CatalogEntry->Version, 00152 &RegSize); 00153 00154 /* Read the Support Service Class Info Flag */ 00155 RegQueryValueEx(EntryKey, 00156 "Version", 00157 0, 00158 &RegType, 00159 (LPBYTE)&CatalogEntry->StoresServiceClassInfo, 00160 &RegSize); 00161 00162 /* Done */ 00163 RegCloseKey(EntryKey); 00164 return ERROR_SUCCESS; 00165 } 00166 00167 VOID 00168 WSAAPI 00169 WsNcEntrySetProvider(IN PNSCATALOG_ENTRY Entry, 00170 IN PNS_PROVIDER Provider) 00171 { 00172 /* Reference the provider */ 00173 InterlockedIncrement(&Provider->RefCount); 00174 00175 /* Set it */ 00176 Entry->Provider = Provider; 00177 } Generated on Sun May 27 2012 04:27:10 for ReactOS by
1.7.6.1
|