Windows: NPAddConnection3 debugging
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 24 Jul 2012 17:56:02 +0000 (13:56 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Wed, 25 Jul 2012 04:10:05 +0000 (21:10 -0700)
Define Add3FlagsToString() and use it when generating debug
output from NPAddConnection3().

Change-Id: I73251890659ea5a833b5f67d26129053c625b58a
Reviewed-on: http://gerrit.openafs.org/7860
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/npdll/AFS_Npdll.c

index d1a4886..066918d 100644 (file)
@@ -610,6 +610,93 @@ NPAddConnection( LPNETRESOURCE   lpNetResource,
     return NPAddConnection3( NULL, lpNetResource, lpPassword, lpUserName, 0 );
 }
 
+static void
+Add3FlagsToString( DWORD dwFlags, WCHAR *wszBuffer, size_t wch)
+{
+    HRESULT  hr;
+    int first = 1;
+
+    *wszBuffer = L'\0';
+
+    if (dwFlags & CONNECT_TEMPORARY) {
+
+        hr = StringCbCat( wszBuffer, wch, L"TEMPORARY");
+
+        if ( FAILED(hr)) {
+
+            return;
+        }
+
+        first = 0;
+    }
+
+    if (dwFlags & CONNECT_INTERACTIVE) {
+
+        if (!first) {
+
+            hr = StringCbCat( wszBuffer, wch, L"|");
+
+            if ( FAILED(hr)) {
+
+                return;
+            }
+        }
+
+        hr = StringCbCat( wszBuffer, wch, L"INTERACTIVE");
+
+        if ( FAILED(hr)) {
+
+            return;
+        }
+
+        first = 0;
+    }
+
+    if (dwFlags & CONNECT_PROMPT) {
+
+        if (!first) {
+
+            hr = StringCbCat( wszBuffer, wch, L"|");
+
+            if ( FAILED(hr)) {
+
+                return;
+            }
+        }
+
+        hr = StringCbCat( wszBuffer, wch, L"PROMPT");
+
+        if ( FAILED(hr)) {
+
+            return;
+        }
+
+        first = 0;
+    }
+
+    if (dwFlags & CONNECT_INTERACTIVE) {
+
+        if (!first) {
+
+            hr = StringCbCat( wszBuffer, wch, L"|");
+
+            if ( FAILED(hr)) {
+
+                return;
+            }
+        }
+
+        hr = StringCbCat( wszBuffer, wch, L"DEFERRED");
+
+        if ( FAILED(hr)) {
+
+            return;
+        }
+
+        first = 0;
+    }
+}
+
 DWORD
 APIENTRY
 NPAddConnection3( HWND            hwndOwner,
@@ -630,6 +717,7 @@ NPAddConnection3( HWND            hwndOwner,
     HANDLE   hToken = NULL;
     LARGE_INTEGER liAuthId = {0,0};
     HRESULT  hr;
+    WCHAR    wszFlagsString[1024]=L"";
 
     __Enter
     {
@@ -657,7 +745,13 @@ NPAddConnection3( HWND            hwndOwner,
         }
 
 #ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPAddConnection3 processing\n");
+        Add3FlagsToString( dwFlags, wszFlagsString, 1024);
+
+        AFSDbgPrint( L"NPAddConnection3 processing Remote %s User %s Pass %s Flags %s\n",
+                     lpNetResource->lpRemoteName,
+                     lpUserName == NULL? L"use-default": lpUserName[0] ? lpUserName : L"no-username",
+                     lpPassword == NULL? L"use-default": lpPassword[0] ? L"provided" : L"no-password",
+                     wszFlagsString);
 #endif
         if( lpNetResource->lpLocalName != NULL)
         {