kernel32: Show warning about too long host name (eterbug #7316).
authorAlexander Morozov <amorozov@etersoft.ru>
Thu, 18 Aug 2011 14:22:14 +0000 (18:22 +0400)
committerTest Robot <wine-patches-test@office.etersoft.ru>
Thu, 18 Aug 2011 15:02:41 +0000 (19:02 +0400)
dlls/kernel32/computername.c

index aa677744a85cd3fc70f330c0e29c98355f61016c..9710b432bb954ea1ffc805b4efa7e271aa7c0233 100644 (file)
@@ -43,6 +43,7 @@
 #include "winternl.h"
 #include "wine/unicode.h"
 #include "wine/exception.h"
+#include "wine/svcctl.h"
 #include "wine/debug.h"
 
 #include "kernel_private.h"
@@ -225,6 +226,34 @@ static BOOL get_use_dns_option(void)
     return ret;
 }
 
+/***********************************************************************
+ *           show_longhostname_warn
+ */
+static void show_longhostname_warn(void)
+{
+    static const WCHAR longhostnameMutexW[] = {'_','_','w','i','n','e','_',
+                                               'l','o','n','g','h','o','s','t','n','a','m','e',0};
+    static const WCHAR svcctl_started_event[] = SVCCTL_STARTED_EVENT;
+    HANDLE event = CreateEventW( NULL, TRUE, FALSE, svcctl_started_event );
+    DWORD ret;
+
+    if (!event)
+        return;
+    ret = WaitForSingleObject( event, 0 );
+    if (ret == WAIT_OBJECT_0)
+    {
+        HANDLE mutex = CreateMutexW( NULL, TRUE, longhostnameMutexW );
+        if (mutex)
+        {
+            if (GetLastError() != ERROR_ALREADY_EXISTS)
+                system( "eterx11msg -longhostname" );
+            else
+                CloseHandle( mutex );
+        }
+    }
+    CloseHandle(event);
+}
+
 
 /*********************************************************************** 
  *                      COMPUTERNAME_Init    (INTERNAL)
@@ -277,6 +306,8 @@ void COMPUTERNAME_Init (void)
                     strcat(hbuf,"-");
                     strcat(hbuf, user);
                 }
+                else
+                    show_longhostname_warn();
             }
         }