diff options
author | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
---|---|---|
committer | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
commit | a9b7bf3fb3e1334d8defd05ca4cfae870b4912e5 (patch) | |
tree | 2dab453d94d5e003379a6cc895eceb84c80e23ec /src/filters/BaseClasses/perflog.cpp | |
parent | aafd49a91f7c2fa9c7103971c16fa6e1b29e8bfd (diff) |
astyle formatting cleanup to make the sourcecode more accessible
switch used: astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren
http://astyle.sourceforge.net/
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1783 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/BaseClasses/perflog.cpp')
-rw-r--r-- | src/filters/BaseClasses/perflog.cpp | 182 |
1 files changed, 97 insertions, 85 deletions
diff --git a/src/filters/BaseClasses/perflog.cpp b/src/filters/BaseClasses/perflog.cpp index e64253870..60e40e47a 100644 --- a/src/filters/BaseClasses/perflog.cpp +++ b/src/filters/BaseClasses/perflog.cpp @@ -23,12 +23,12 @@ ULONG
WINAPI
-PerflogCallback (
+PerflogCallback(
WMIDPREQUESTCODE RequestCode,
__in PVOID Context,
__out ULONG* BufferSize,
__in PVOID Buffer
- );
+);
//
// Event tracing function pointers.
@@ -38,7 +38,7 @@ PerflogCallback ( #ifdef UNICODE
ULONG
-(__stdcall * _RegisterTraceGuids) (
+(__stdcall * _RegisterTraceGuids)(
__in IN WMIDPREQUEST RequestAddress,
__in IN PVOID RequestContext,
IN LPCGUID ControlGuid,
@@ -47,14 +47,14 @@ ULONG IN LPCWSTR MofImagePath,
IN LPCWSTR MofResourceName,
OUT PTRACEHANDLE RegistrationHandle
- );
+);
#define REGISTERTRACEGUIDS_NAME "RegisterTraceGuidsW"
#else
ULONG
-(__stdcall * _RegisterTraceGuids) (
+(__stdcall * _RegisterTraceGuids)(
__in IN WMIDPREQUEST RequestAddress,
__in IN PVOID RequestContext,
IN LPCGUID ControlGuid,
@@ -63,37 +63,37 @@ ULONG IN LPCSTR MofImagePath,
IN LPCSTR MofResourceName,
__out OUT PTRACEHANDLE RegistrationHandle
- );
+);
#define REGISTERTRACEGUIDS_NAME "RegisterTraceGuidsA"
#endif
ULONG
-(__stdcall * _UnregisterTraceGuids) (
+(__stdcall * _UnregisterTraceGuids)(
TRACEHANDLE RegistrationHandle
- );
+);
TRACEHANDLE
-(__stdcall * _GetTraceLoggerHandle) (
+(__stdcall * _GetTraceLoggerHandle)(
__in PVOID Buffer
- );
+);
UCHAR
-(__stdcall * _GetTraceEnableLevel) (
+(__stdcall * _GetTraceEnableLevel)(
TRACEHANDLE TraceHandle
- );
+);
ULONG
-(__stdcall * _GetTraceEnableFlags) (
+(__stdcall * _GetTraceEnableFlags)(
TRACEHANDLE TraceHandle
- );
+);
ULONG
-(__stdcall * _TraceEvent) (
+(__stdcall * _TraceEvent)(
TRACEHANDLE TraceHandle,
__in PEVENT_TRACE_HEADER EventTrace
- );
+);
HINSTANCE _Advapi32;
@@ -101,12 +101,12 @@ HINSTANCE _Advapi32; // Global variables.
//
-BOOL EventTracingAvailable=FALSE;
+BOOL EventTracingAvailable = FALSE;
ULONG PerflogEnableFlags;
UCHAR PerflogEnableLevel;
ULONG PerflogModuleLevel = 0;
void (*OnStateChanged)(void);
-TRACEHANDLE PerflogTraceHandle=NULL;
+TRACEHANDLE PerflogTraceHandle = NULL;
TRACEHANDLE PerflogRegHandle;
// The Win32 wsprintf() function writes a maximum of 1024 characters to it's output buffer.
@@ -122,7 +122,7 @@ const INT iDEBUGINFO = 1024; // Used to format strings VOID
PerflogReadModuleLevel(
HINSTANCE hInstance
- )
+)
{
LONG lReturn; // Create key return value
TCHAR szInfo[iDEBUGINFO]; // Constructs key names
@@ -132,23 +132,27 @@ PerflogReadModuleLevel( DWORD dwKeySize, dwKeyType, dwKeyValue;
DWORD dwSize = GetModuleFileName(
- (hInstance ? hInstance : GetModuleHandle( NULL )),
- szFullName,
- iDEBUGINFO );
+ (hInstance ? hInstance : GetModuleHandle(NULL)),
+ szFullName,
+ iDEBUGINFO);
- if (0 == dwSize || iDEBUGINFO == dwSize) {
+ if(0 == dwSize || iDEBUGINFO == dwSize)
+ {
return;
}
- pName = _tcsrchr(szFullName,'\\');
- if (pName == NULL) {
+ pName = _tcsrchr(szFullName, '\\');
+ if(pName == NULL)
+ {
pName = szFullName;
- } else {
+ }
+ else
+ {
pName++;
}
/* Construct the base key name */
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("SOFTWARE\\Debug\\%s"),pName);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("SOFTWARE\\Debug\\%s"), pName);
/* Open the key for this module */
lReturn =
@@ -157,22 +161,23 @@ PerflogReadModuleLevel( szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
KEY_QUERY_VALUE, // Desired security access
- &hModuleKey ); // Opened handle buffer
+ &hModuleKey); // Opened handle buffer
- if (lReturn != ERROR_SUCCESS) {
+ if(lReturn != ERROR_SUCCESS)
+ {
return;
}
dwKeySize = sizeof(DWORD);
lReturn = RegQueryValueEx(
- hModuleKey, // Handle to an open key
- TEXT("PERFLOG"),
- NULL, // Reserved field
- &dwKeyType, // Returns the field type
- (LPBYTE) &dwKeyValue, // Returns the field's value
- &dwKeySize ); // Number of bytes transferred
-
- if ((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))
+ hModuleKey, // Handle to an open key
+ TEXT("PERFLOG"),
+ NULL, // Reserved field
+ &dwKeyType, // Returns the field type
+ (LPBYTE) &dwKeyValue, // Returns the field's value
+ &dwKeySize); // Number of bytes transferred
+
+ if((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))
{
PerflogModuleLevel = dwKeyValue;
}
@@ -183,12 +188,12 @@ PerflogReadModuleLevel( BOOL PerflogInitIfEnabled(
IN HINSTANCE hInstance,
__in IN PPERFLOG_LOGGING_PARAMS LogParams
- )
+)
{
- PerflogReadModuleLevel( hInstance );
- if (PerflogModuleLevel)
+ PerflogReadModuleLevel(hInstance);
+ if(PerflogModuleLevel)
{
- return PerflogInitialize( LogParams );
+ return PerflogInitialize(LogParams);
}
else
{
@@ -197,9 +202,9 @@ BOOL PerflogInitIfEnabled( }
BOOL
-PerflogInitialize (
+PerflogInitialize(
__in IN PPERFLOG_LOGGING_PARAMS LogParams
- )
+)
{
ULONG status;
@@ -208,23 +213,25 @@ PerflogInitialize ( // pointers to the event tracing routines.
//
- _Advapi32 = GetModuleHandle (_T("ADVAPI32.DLL"));
- if (_Advapi32 == NULL) {
+ _Advapi32 = GetModuleHandle(_T("ADVAPI32.DLL"));
+ if(_Advapi32 == NULL)
+ {
return FALSE;
}
- *((FARPROC*) &_RegisterTraceGuids) = GetProcAddress (_Advapi32, REGISTERTRACEGUIDS_NAME);
- *((FARPROC*) &_UnregisterTraceGuids) = GetProcAddress (_Advapi32, "UnregisterTraceGuids");
- *((FARPROC*) &_GetTraceLoggerHandle) = GetProcAddress (_Advapi32, "GetTraceLoggerHandle");
- *((FARPROC*) &_GetTraceEnableLevel) = GetProcAddress (_Advapi32, "GetTraceEnableLevel");
- *((FARPROC*) &_GetTraceEnableFlags) = GetProcAddress (_Advapi32, "GetTraceEnableFlags");
- *((FARPROC*) &_TraceEvent) = GetProcAddress (_Advapi32, "TraceEvent");
-
- if (_RegisterTraceGuids == NULL ||
- _UnregisterTraceGuids == NULL ||
- _GetTraceEnableLevel == NULL ||
- _GetTraceEnableFlags == NULL ||
- _TraceEvent == NULL) {
+ *((FARPROC*) &_RegisterTraceGuids) = GetProcAddress(_Advapi32, REGISTERTRACEGUIDS_NAME);
+ *((FARPROC*) &_UnregisterTraceGuids) = GetProcAddress(_Advapi32, "UnregisterTraceGuids");
+ *((FARPROC*) &_GetTraceLoggerHandle) = GetProcAddress(_Advapi32, "GetTraceLoggerHandle");
+ *((FARPROC*) &_GetTraceEnableLevel) = GetProcAddress(_Advapi32, "GetTraceEnableLevel");
+ *((FARPROC*) &_GetTraceEnableFlags) = GetProcAddress(_Advapi32, "GetTraceEnableFlags");
+ *((FARPROC*) &_TraceEvent) = GetProcAddress(_Advapi32, "TraceEvent");
+
+ if(_RegisterTraceGuids == NULL ||
+ _UnregisterTraceGuids == NULL ||
+ _GetTraceEnableLevel == NULL ||
+ _GetTraceEnableFlags == NULL ||
+ _TraceEvent == NULL)
+ {
return FALSE;
}
@@ -237,14 +244,14 @@ PerflogInitialize ( // Register our GUIDs.
//
- status = _RegisterTraceGuids (PerflogCallback,
- LogParams,
- &LogParams->ControlGuid,
- LogParams->NumberOfTraceGuids,
- LogParams->TraceGuids,
- NULL,
- NULL,
- &PerflogRegHandle);
+ status = _RegisterTraceGuids(PerflogCallback,
+ LogParams,
+ &LogParams->ControlGuid,
+ LogParams->NumberOfTraceGuids,
+ LogParams->TraceGuids,
+ NULL,
+ NULL,
+ &PerflogRegHandle);
return (status == ERROR_SUCCESS);
}
@@ -254,15 +261,16 @@ PerflogInitialize ( //
VOID
-PerflogShutdown (
+PerflogShutdown(
VOID
- )
+)
{
- if (!EventTracingAvailable) {
+ if(!EventTracingAvailable)
+ {
return;
}
- _UnregisterTraceGuids (PerflogRegHandle);
+ _UnregisterTraceGuids(PerflogRegHandle);
PerflogRegHandle = NULL;
PerflogTraceHandle = NULL;
}
@@ -274,27 +282,28 @@ PerflogShutdown ( ULONG
WINAPI
-PerflogCallback (
+PerflogCallback(
WMIDPREQUESTCODE RequestCode,
__in PVOID Context,
__out ULONG* BufferSize,
__in PVOID Buffer
- )
+)
{
ULONG status;
- UNREFERENCED_PARAMETER (Context);
+ UNREFERENCED_PARAMETER(Context);
- ASSERT (EventTracingAvailable);
+ ASSERT(EventTracingAvailable);
status = ERROR_SUCCESS;
- switch (RequestCode) {
+ switch(RequestCode)
+ {
case WMI_ENABLE_EVENTS:
- PerflogTraceHandle = _GetTraceLoggerHandle (Buffer);
- PerflogEnableFlags = _GetTraceEnableFlags (PerflogTraceHandle);
- PerflogEnableLevel = _GetTraceEnableLevel (PerflogTraceHandle);
+ PerflogTraceHandle = _GetTraceLoggerHandle(Buffer);
+ PerflogEnableFlags = _GetTraceEnableFlags(PerflogTraceHandle);
+ PerflogEnableLevel = _GetTraceEnableLevel(PerflogTraceHandle);
break;
case WMI_DISABLE_EVENTS:
@@ -307,7 +316,8 @@ PerflogCallback ( status = ERROR_INVALID_PARAMETER;
}
- if (OnStateChanged != NULL) {
+ if(OnStateChanged != NULL)
+ {
OnStateChanged();
}
@@ -320,28 +330,30 @@ PerflogCallback ( //
VOID
-PerflogTraceEvent (
+PerflogTraceEvent(
__in PEVENT_TRACE_HEADER Event
- )
+)
{
- if (!EventTracingAvailable) {
+ if(!EventTracingAvailable)
+ {
return;
}
- _TraceEvent (PerflogTraceHandle, Event);
+ _TraceEvent(PerflogTraceHandle, Event);
}
VOID
PerflogTraceEventLevel(
ULONG Level,
__in PEVENT_TRACE_HEADER Event
- )
+)
{
- if ((!EventTracingAvailable) || (Level <= PerflogModuleLevel)) {
+ if((!EventTracingAvailable) || (Level <= PerflogModuleLevel))
+ {
return;
}
- _TraceEvent (PerflogTraceHandle, Event);
+ _TraceEvent(PerflogTraceHandle, Event);
}
|