Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygeneventsource.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS kernel 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/services/eventlog/eventsource.c 00005 * PURPOSE: Event logging service 00006 * COPYRIGHT: Copyright 2011 Eric Kohl 00007 */ 00008 00009 /* INCLUDES *****************************************************************/ 00010 00011 #include "eventlog.h" 00012 00013 static LIST_ENTRY EventSourceListHead; 00014 static CRITICAL_SECTION EventSourceListCs; 00015 00016 /* FUNCTIONS ****************************************************************/ 00017 00018 VOID 00019 InitEventSourceList(VOID) 00020 { 00021 InitializeCriticalSection(&EventSourceListCs); 00022 InitializeListHead(&EventSourceListHead); 00023 } 00024 00025 00026 static VOID 00027 DumpEventSourceList(VOID) 00028 { 00029 PLIST_ENTRY CurrentEntry; 00030 PEVENTSOURCE EventSource; 00031 00032 DPRINT("DumpEventSourceList()\n"); 00033 EnterCriticalSection(&EventSourceListCs); 00034 00035 CurrentEntry = EventSourceListHead.Flink; 00036 while (CurrentEntry != &EventSourceListHead) 00037 { 00038 EventSource = CONTAINING_RECORD(CurrentEntry, 00039 EVENTSOURCE, 00040 EventSourceListEntry); 00041 00042 DPRINT("EventSource->szName: %S\n", EventSource->szName); 00043 00044 CurrentEntry = CurrentEntry->Flink; 00045 } 00046 00047 LeaveCriticalSection(&EventSourceListCs); 00048 00049 DPRINT("Done\n"); 00050 } 00051 00052 00053 BOOL 00054 LoadEventSources(HKEY hKey, 00055 PLOGFILE pLogFile) 00056 { 00057 PEVENTSOURCE lpEventSource; 00058 DWORD dwMaxSubKeyLength; 00059 DWORD dwEventSourceNameLength; 00060 DWORD dwIndex; 00061 WCHAR *Buf = NULL; 00062 00063 DPRINT("LoadEventSources\n"); 00064 00065 RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, &dwMaxSubKeyLength, NULL, 00066 NULL, NULL, NULL, NULL, NULL); 00067 00068 DPRINT("dwMaxSubKeyLength: %lu\n", dwMaxSubKeyLength); 00069 00070 dwMaxSubKeyLength++; 00071 00072 Buf = HeapAlloc(MyHeap, 0, dwMaxSubKeyLength * sizeof(WCHAR)); 00073 if (!Buf) 00074 { 00075 DPRINT1("Error: can't allocate heap!\n"); 00076 return FALSE; 00077 } 00078 00079 dwEventSourceNameLength = dwMaxSubKeyLength; 00080 00081 dwIndex = 0; 00082 while (RegEnumKeyExW(hKey, 00083 dwIndex, 00084 Buf, 00085 &dwEventSourceNameLength, 00086 NULL, NULL, NULL, NULL) == ERROR_SUCCESS) 00087 { 00088 DPRINT("Event Source: %S\n", Buf); 00089 00090 lpEventSource = HeapAlloc(MyHeap, 0, sizeof(EVENTSOURCE) + wcslen(Buf) * sizeof(WCHAR)); 00091 if (lpEventSource != NULL) 00092 { 00093 wcscpy(lpEventSource->szName, Buf); 00094 lpEventSource->LogFile = pLogFile; 00095 00096 DPRINT("Insert event source: %S\n", lpEventSource->szName); 00097 00098 00099 EnterCriticalSection(&EventSourceListCs); 00100 InsertTailList(&EventSourceListHead, 00101 &lpEventSource->EventSourceListEntry); 00102 LeaveCriticalSection(&EventSourceListCs); 00103 } 00104 00105 dwEventSourceNameLength = dwMaxSubKeyLength; 00106 dwIndex++; 00107 } 00108 00109 HeapFree(MyHeap, 0, Buf); 00110 00111 DumpEventSourceList(); 00112 00113 return TRUE; 00114 } 00115 00116 00117 PEVENTSOURCE 00118 GetEventSourceByName(LPCWSTR Name) 00119 { 00120 PLIST_ENTRY CurrentEntry; 00121 PEVENTSOURCE Result = NULL; 00122 00123 DPRINT("GetEventSourceByName(%S)\n", Name); 00124 EnterCriticalSection(&EventSourceListCs); 00125 00126 CurrentEntry = EventSourceListHead.Flink; 00127 while (CurrentEntry != &EventSourceListHead) 00128 { 00129 PEVENTSOURCE Item = CONTAINING_RECORD(CurrentEntry, 00130 EVENTSOURCE, 00131 EventSourceListEntry); 00132 00133 DPRINT("Item->szName: %S\n", Item->szName); 00134 // if ((*(Item->szName) != 0) && !_wcsicmp(Item->szName, Name)) 00135 if (_wcsicmp(Item->szName, Name) == 0) 00136 { 00137 DPRINT("Found it\n"); 00138 Result = Item; 00139 break; 00140 } 00141 00142 CurrentEntry = CurrentEntry->Flink; 00143 } 00144 00145 LeaveCriticalSection(&EventSourceListCs); 00146 00147 DPRINT("Done (Result: %p)\n", Result); 00148 00149 return Result; 00150 } Generated on Fri May 25 2012 04:15:59 for ReactOS by
1.7.6.1
|