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

Alexandre Julliard julliard at winehq.org
Mon Oct 1 07:55:00 CDT 2007


Module: wine
Branch: master
Commit: 504e7c2ff7ec1c4e2ec648aa675460856c30ce7b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=504e7c2ff7ec1c4e2ec648aa675460856c30ce7b

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Sat Sep 29 21:05:53 2007 +0200

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

---

 dlls/pdh/pdh.spec   |    8 +++---
 dlls/pdh/pdh_main.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/pdh.h       |    7 +++++
 include/pdhmsg.h    |    1 +
 4 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/dlls/pdh/pdh.spec b/dlls/pdh/pdh.spec
index c28d2a8..795a45e 100644
--- a/dlls/pdh/pdh.spec
+++ b/dlls/pdh/pdh.spec
@@ -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
diff --git a/dlls/pdh/pdh_main.c b/dlls/pdh/pdh_main.c
index 5253620..e49e64e 100644
--- a/dlls/pdh/pdh_main.c
+++ b/dlls/pdh/pdh_main.c
@@ -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 );
+}
diff --git a/include/pdh.h b/include/pdh.h
index a392096..3aff6db 100644
--- a/include/pdh.h
+++ b/include/pdh.h
@@ -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
 }
diff --git a/include/pdhmsg.h b/include/pdhmsg.h
index 00563a0..bee466e 100644
--- a/include/pdhmsg.h
+++ b/include/pdhmsg.h
@@ -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




More information about the wine-cvs mailing list