pdh: Implement PdhValidatePath{, Ex}{A, W}.

oldstable
Hans Leidekker 2007-09-29 21:05:53 +02:00 committed by Alexandre Julliard
parent 9ad3807c15
commit 504e7c2ff7
4 changed files with 86 additions and 4 deletions

View File

@ -137,10 +137,10 @@
@ stub PdhUpdateLogA
@ stub PdhUpdateLogFileCatalog
@ stub PdhUpdateLogW
@ stub PdhValidatePathA
@ stub PdhValidatePathExA
@ stub PdhValidatePathExW
@ stub PdhValidatePathW
@ stdcall PdhValidatePathA(str)
@ stdcall PdhValidatePathExA(ptr str)
@ stdcall PdhValidatePathExW(ptr wstr)
@ stdcall PdhValidatePathW(wstr)
@ stub PdhVbAddCounter
@ stub PdhVbCreateCounterPathList
@ stub PdhVbGetCounterPathElements

View File

@ -700,3 +700,77 @@ PDH_STATUS WINAPI PdhSetCounterScaleFactor( PDH_HCOUNTER handle, LONG factor )
counter->scale = factor;
return ERROR_SUCCESS;
}
/***********************************************************************
* PdhValidatePathA (PDH.@)
*/
PDH_STATUS WINAPI PdhValidatePathA( LPCSTR path )
{
PDH_STATUS ret;
WCHAR *pathW;
TRACE("%s\n", debugstr_a(path));
if (!path) return PDH_INVALID_ARGUMENT;
if (!(pathW = pdh_strdup_aw( path ))) return PDH_MEMORY_ALLOCATION_FAILURE;
ret = PdhValidatePathW( pathW );
pdh_free( pathW );
return ret;
}
static PDH_STATUS validate_path( LPCWSTR path )
{
if (!path || !*path) return PDH_INVALID_ARGUMENT;
if (*path++ != '\\' || !strchrW( path, '\\' )) return PDH_CSTATUS_BAD_COUNTERNAME;
return ERROR_SUCCESS;
}
/***********************************************************************
* PdhValidatePathW (PDH.@)
*/
PDH_STATUS WINAPI PdhValidatePathW( LPCWSTR path )
{
PDH_STATUS ret;
unsigned int i;
TRACE("%s\n", debugstr_w(path));
if ((ret = validate_path( path ))) return ret;
for (i = 0; i < sizeof(counter_sources) / sizeof(counter_sources[0]); i++)
if (pdh_match_path( counter_sources[i].path, path )) return ERROR_SUCCESS;
return PDH_CSTATUS_NO_COUNTER;
}
/***********************************************************************
* PdhValidatePathExA (PDH.@)
*/
PDH_STATUS WINAPI PdhValidatePathExA( PDH_HLOG source, LPCSTR path )
{
TRACE("%p %s\n", source, debugstr_a(path));
if (source)
{
FIXME("log file data source not supported\n");
return ERROR_SUCCESS;
}
return PdhValidatePathA( path );
}
/***********************************************************************
* PdhValidatePathExW (PDH.@)
*/
PDH_STATUS WINAPI PdhValidatePathExW( PDH_HLOG source, LPCWSTR path )
{
TRACE("%p %s\n", source, debugstr_w(path));
if (source)
{
FIXME("log file data source not supported\n");
return ERROR_SUCCESS;
}
return PdhValidatePathW( path );
}

View File

@ -35,6 +35,7 @@ extern "C" {
typedef LONG PDH_STATUS;
typedef HANDLE PDH_HQUERY;
typedef HANDLE PDH_HCOUNTER;
typedef HANDLE PDH_HLOG;
#define PDH_MAX_SCALE 7
#define PDH_MIN_SCALE (-7)
@ -190,6 +191,12 @@ PDH_STATUS WINAPI PdhOpenQueryW(LPCWSTR, DWORD_PTR, PDH_HQUERY *);
#define PdhOpenQuery WINELIB_NAME_AW(PdhOpenQuery)
PDH_STATUS WINAPI PdhRemoveCounter(PDH_HCOUNTER);
PDH_STATUS WINAPI PdhSetCounterScaleFactor(PDH_HCOUNTER, LONG);
PDH_STATUS WINAPI PdhValidatePathA(LPCSTR);
PDH_STATUS WINAPI PdhValidatePathW(LPCWSTR);
#define PdhValidatePath WINELIB_NAME_AW(PdhValidatePath)
PDH_STATUS WINAPI PdhValidatePathExA(PDH_HLOG, LPCSTR);
PDH_STATUS WINAPI PdhValidatePathExW(PDH_HLOG, LPCWSTR);
#define PdhValidatePathEx WINELIB_NAME_AW(PdhValidatePathEx)
#ifdef __cplusplus
}

View File

@ -30,6 +30,7 @@
#define PDH_MEMORY_ALLOCATION_FAILURE 0xc0000bbb
#define PDH_INVALID_HANDLE 0xc0000bbc
#define PDH_INVALID_ARGUMENT 0xc0000bbd
#define PDH_CSTATUS_BAD_COUNTERNAME 0xc0000bc0
#define PDH_INSUFFICIENT_BUFFER 0xc0000bc2
#define PDH_INVALID_DATA 0xc0000bc6
#define PDH_STRING_NOT_FOUND 0xc0000bd4