[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    resolve DISPLAY variable
From:       Andreas Mohr <mohr () elektron ! ikp ! physik ! tu-darmstadt ! de>
Date:       1999-10-28 13:49:02
[Download RAW message or body]

Hi,

this patch adds hostname resolving capability to the XFONT_UserMetricsCache()
function.

That will avoid duplicate font metrics cache files when both IP addr and
hostname might be specified in the DISPLAY variable.

Andreas Mohr

["diff.xfont" (text/plain)]

Index: graphics/x11drv/xfont.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/xfont.c,v
retrieving revision 1.26
diff -u -w -r1.26 xfont.c
--- graphics/x11drv/xfont.c	1999/10/24 17:26:45	1.26
+++ graphics/x11drv/xfont.c	1999/10/28 13:44:17
@@ -19,9 +19,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <netdb.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #include <fcntl.h>
 #include <math.h>
 #include <assert.h>
@@ -1669,25 +1673,53 @@
  *           XFONT_UserMetricsCache
  * 
  * Returns expanded name for the cachedmetrics file.
- * Now it also appends the current value of the $DISPLAY varaible.
+ * Now it also appends the current value of the $DISPLAY variable,
+ * the host part getting transformed to its IP address.
  */
 static char* XFONT_UserMetricsCache( char* buffer, int* buf_size )
 {
     char* pchDisplay, *home;
+	char *disp_host = NULL;
+	char *disp_number = NULL;
 
     pchDisplay = getenv( "DISPLAY" );
-    if( !pchDisplay ) pchDisplay = "0";
+    if( !pchDisplay )
+       disp_host = "0";
+    else /* convert host name -> IP addr */
+	{
+		struct hostent *he;
+		char *dispcopy = HEAP_strdupA(SystemHeap, 0, pchDisplay);
+		char *p;
+
+		if ((p = strchr(dispcopy, ':')))
+			*p = '\0';
+
+		disp_number = strchr(pchDisplay, ':');
+
+		he = gethostbyname(dispcopy);
+		HeapFree( SystemHeap, 0, dispcopy );
+
+		disp_host = HEAP_strdupA(SystemHeap, 0,
+						inet_ntoa(*(struct in_addr *)(he->h_addr_list[0])));
 
+    }
+
     if ((home = getenv( "HOME" )) != NULL)
     {
 	int i = strlen( home ) + strlen( INIWinePrefix ) + 
-		strlen( INIFontMetrics ) + strlen( pchDisplay ) + 2;
+			strlen( INIFontMetrics ) +
+			strlen( disp_host ) + strlen( disp_number ) + 2;
 	if( i > *buf_size ) 
 	    buffer = (char*) HeapReAlloc( SystemHeap, 0, buffer, *buf_size = i );
 	strcpy( buffer, home );
 	strcat( buffer, INIWinePrefix );
 	strcat( buffer, INIFontMetrics );
-	strcat( buffer, pchDisplay );
+
+	strcat( buffer, disp_host );
+	strcat( buffer, disp_number );
+
+	if (pchDisplay)
+		HeapFree(SystemHeap, 0, disp_host);
     } else buffer[0] = '\0';
     return buffer;
 }

=========================================================================


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic