Replace PROFILE_ functions by RegQueryValueExA in x11drv

Dmitry Timoshkov dmitry at baikal.ru
Mon Jun 18 08:34:27 CDT 2001


Hello.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Replace PROFILE_ functions by RegQueryValueExA in x11drv.

diff -u cvs/hq/wine/dlls/x11drv/window.c wine/dlls/x11drv/window.c
--- cvs/hq/wine/dlls/x11drv/window.c	Tue Jun 12 21:28:19 2001
+++ wine/dlls/x11drv/window.c	Mon Jun 18 18:30:15 2001
@@ -8,11 +8,14 @@
 
 #include "config.h"
 
+#include <stdlib.h>
+
 #include "ts_xlib.h"
 #include "ts_xutil.h"
 
 #include "winbase.h"
 #include "wingdi.h"
+#include "winreg.h"
 #include "winuser.h"
 
 #include "debugtools.h"
@@ -740,7 +743,17 @@
     {
         if (text_cp == (UINT)-1)
         {
-            text_cp = PROFILE_GetWineIniInt("x11drv", "TextCP", CP_ACP);
+	    HKEY hkey;
+	    /* default value */
+	    text_cp = CP_ACP;
+	    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
+	    {
+		char buffer[20];
+		DWORD type, count = sizeof(buffer);
+		if(!RegQueryValueExA(hkey, "TextCP", 0, &type, buffer, &count))
+		    text_cp = atoi(buffer);
+		RegCloseKey(hkey);
+	    }
             TRACE("text_cp = %u\n", text_cp);
         }
 
diff -u cvs/hq/wine/graphics/x11drv/bitblt.c wine/graphics/x11drv/bitblt.c
--- cvs/hq/wine/graphics/x11drv/bitblt.c	Tue Jun 12 21:28:19 2001
+++ wine/graphics/x11drv/bitblt.c	Mon Jun 18 16:35:20 2001
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include "winbase.h"
 #include "wingdi.h"
+#include "winreg.h"
 #include "winuser.h"
 #include "bitmap.h"
 #include "color.h"
@@ -522,6 +523,12 @@
 
 #endif  /* BITBLT_TEST */
 
+static inline BOOL get_bool(const char *buffer, BOOL def_value)
+{
+    if(IS_OPTION_TRUE(buffer[0])) return TRUE;
+    if(IS_OPTION_FALSE(buffer[0])) return FALSE;
+    return def_value;
+}
 
 /***********************************************************************
  *           perfect_graphics
@@ -531,7 +538,20 @@
 static inline int perfect_graphics(void)
 {
     static int perfect = -1;
-    if (perfect == -1) perfect = PROFILE_GetWineIniBool( "x11drv", "PerfectGraphics", 0 );
+    if (perfect == -1)
+    {
+	HKEY hkey;
+	char buffer[20];
+	/* default value */
+	perfect = 0;
+	if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
+	{
+	    DWORD type, count = sizeof(buffer);
+	    if(!RegQueryValueExA(hkey, "PerfectGraphics", 0, &type, buffer, &count))
+		perfect = get_bool(buffer, 0);
+	    RegCloseKey(hkey);
+	}
+    }
     return perfect;
 }
 
diff -u cvs/hq/wine/graphics/x11drv/palette.c wine/graphics/x11drv/palette.c
--- cvs/hq/wine/graphics/x11drv/palette.c	Sat May 12 14:20:18 2001
+++ wine/graphics/x11drv/palette.c	Mon Jun 18 16:53:02 2001
@@ -18,6 +18,7 @@
 #include "options.h"
 #include "palette.h"
 #include "windef.h"
+#include "winreg.h"
 #include "x11drv.h"
 
 DEFAULT_DEBUG_CHANNEL(palette);
@@ -88,6 +89,13 @@
 static BOOL X11DRV_PALETTE_CheckSysColor(COLORREF c);
 static int X11DRV_PALETTE_LookupSystemXPixel(COLORREF col);
 
+static inline BOOL get_bool(const char *buffer, BOOL def_value)
+{
+    if(IS_OPTION_TRUE(buffer[0])) return TRUE;
+    if(IS_OPTION_FALSE(buffer[0])) return FALSE;
+    return def_value;
+}
+
 /***********************************************************************
  *           COLOR_Init
  *
@@ -114,7 +122,19 @@
 	X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_VIRTUAL;
     case GrayScale:
     case PseudoColor:
-	if (PROFILE_GetWineIniBool( "x11drv", "PrivateColorMap", 0 ))
+    {
+	HKEY hkey;
+	BOOL private_color_map = FALSE;
+	if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
+	{
+	    char buffer[20];
+	    DWORD type, count = sizeof(buffer);
+	    if(!RegQueryValueExA(hkey, "PrivateColorMap", 0, &type, buffer, &count))
+		private_color_map = get_bool(buffer, 0);
+	    RegCloseKey(hkey);
+	}
+
+	if (private_color_map)
 	{
 	    XSetWindowAttributes win_attr;
 
@@ -139,6 +159,7 @@
         X11DRV_PALETTE_PaletteXColormap = TSXCreateColormap(gdi_display, root_window,
                                                             visual, AllocNone);
         break;
+    }
 
     case StaticGray:
         X11DRV_PALETTE_PaletteXColormap = TSXCreateColormap(gdi_display, root_window,
@@ -316,21 +337,38 @@
    int			defaultCM_max_copy;
    Colormap		defaultCM;
    XColor		defaultColors[256];
+   HKEY hkey;
+
+   defaultCM_max_copy = 128;
+   COLOR_max = 256;
+
+   if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
+   {
+	char buffer[20];
+	DWORD type, count;
+
+	count = sizeof(buffer);
+	if(!RegQueryValueExA(hkey, "CopyDefaultColors", 0, &type, buffer, &count))
+	    defaultCM_max_copy = atoi(buffer);
+
+	count = sizeof(buffer);
+	if(!RegQueryValueExA(hkey, "AllocSystemColors", 0, &type, buffer, &count))
+	    COLOR_max = atoi(buffer);
+		
+	RegCloseKey(hkey);
+   }
 
    /* Copy the first bunch of colors out of the default colormap to prevent 
     * colormap flashing as much as possible.  We're likely to get the most
     * important Window Manager colors, etc in the first 128 colors */
    defaultCM = DefaultColormap( gdi_display, DefaultScreen(gdi_display) );
-   defaultCM_max_copy = PROFILE_GetWineIniInt( "x11drv", "CopyDefaultColors", 128);
+
    for (i = 0; i < defaultCM_max_copy; i++)
        defaultColors[i].pixel = (long) i;
    TSXQueryColors(gdi_display, defaultCM, &defaultColors[0], defaultCM_max_copy);
    for (i = 0; i < defaultCM_max_copy; i++)
        TSXAllocColor( gdi_display, X11DRV_PALETTE_PaletteXColormap, &defaultColors[i] );
               
-   /* read "AllocSystemColors" from wine.conf */
-
-   COLOR_max = PROFILE_GetWineIniInt( "x11drv", "AllocSystemColors", 256);
    if (COLOR_max > 256) COLOR_max = 256;
    else if (COLOR_max < 20) COLOR_max = 20;
    TRACE("%d colors configured.\n", COLOR_max);
diff -u cvs/hq/wine/graphics/x11drv/xfont.c wine/graphics/x11drv/xfont.c
--- cvs/hq/wine/graphics/x11drv/xfont.c	Tue May 22 21:00:34 2001
+++ wine/graphics/x11drv/xfont.c	Mon Jun 18 18:12:01 2001
@@ -25,8 +25,8 @@
 #include "windef.h"
 #include "wingdi.h"
 #include "winnls.h"
+#include "winreg.h"
 #include "heap.h"
-#include "options.h"
 #include "font.h"
 #include "debugtools.h"
 #include "user.h" /* for TWEAK_WineLook (FIXME) */
@@ -71,7 +71,7 @@
 			/* X11R6 adds TC_SF_X_YINDEP, maybe more... */
 
 static const char*	INIFontMetrics = "/cachedmetrics.";
-static const char*	INIFontSection = "fonts";
+static const char*	INIFontSection = "Software\\Wine\\Wine\\Config\\fonts";
 static const char*	INIAliasSection = "Alias";
 static const char*	INIIgnoreSection = "Ignore";
 static const char*	INIDefault = "Default";
@@ -1393,9 +1393,15 @@
 static void XFONT_LoadDefault(LPCSTR ini, LPCSTR fonttype)
 {
     char buffer[MAX_LFD_LENGTH];
+    HKEY hkey;
 
-    if( PROFILE_GetWineIniString( INIFontSection, ini, "", buffer, sizeof buffer ) )
+    buffer[0] = 0;
+    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
     {
+	DWORD type, count = sizeof(buffer);
+	RegQueryValueExA(hkey, ini, 0, &type, buffer, &count);
+	RegCloseKey(hkey);
+
 	if (*buffer)
 	{
 	    LFD* lfd;
@@ -1410,7 +1416,7 @@
 		WARN("Ini section [%s]%s is malformed\n", INIFontSection, ini);
 	    HeapFree(GetProcessHeap(), 0, lfd);
 	}
-    }   
+    }
 }
 
 /***********************************************************************
@@ -1533,6 +1539,33 @@
 } 
 
 /***********************************************************************
+ *  Just a copy of PROFILE_GetStringItem
+ *
+ *  Convenience function that turns a string 'xxx, yyy, zzz' into 
+ *  the 'xxx\0 yyy, zzz' and returns a pointer to the 'yyy, zzz'.
+ */
+static char *XFONT_GetStringItem( char *start )
+{
+#define XFONT_isspace(c) (isspace(c) || (c == '\r') || (c == 0x1a))
+    char *lpchX, *lpch;
+
+    for (lpchX = start, lpch = NULL; *lpchX != '\0'; lpchX++ )
+    {
+        if( *lpchX == ',' )
+        {
+            if( lpch ) *lpch = '\0'; else *lpchX = '\0';
+            while( *(++lpchX) )
+                if( !XFONT_isspace(*lpchX) ) return lpchX;
+        }
+	else if( XFONT_isspace( *lpchX ) && !lpch ) lpch = lpchX;
+	     else lpch = NULL;
+    }
+    if( lpch ) *lpch = '\0';
+    return NULL;
+#undef XFONT_isspace
+}
+
+/***********************************************************************
  *           XFONT_LoadAliases
  *
  * INIT ONLY 
@@ -1564,10 +1597,16 @@
     char buffer[MAX_LFD_LENGTH];
     int i = 0;
     LFD* lfd;
+    HKEY hkey;
 
     /* built-ins first */
-    PROFILE_GetWineIniString( INIFontSection, INIDefaultSerif,
-				"-bitstream-charter-", buffer, sizeof buffer );
+    strcpy(buffer, "-bitstream-charter-");
+    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
+    {
+	DWORD type, count = sizeof(buffer);
+	RegQueryValueExA(hkey, INIDefaultSerif, 0, &type, buffer, &count);
+	RegCloseKey(hkey);
+    }
     TRACE("Using '%s' as default serif font\n", buffer);
     lfd = LFD_Parse(buffer);
     /* NB XFONT_InitialCapitals should not change these standard aliases */
@@ -1581,8 +1620,13 @@
 	HeapFree(GetProcessHeap(), 0, lfd);
     }
 	
-    PROFILE_GetWineIniString( INIFontSection, INIDefaultSansSerif,
-				"-adobe-helvetica-", buffer, sizeof buffer);
+    strcpy(buffer, "-adobe-helvetica-");
+    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
+    {
+	DWORD type, count = sizeof(buffer);
+	RegQueryValueExA(hkey, INIDefaultSansSerif, 0, &type, buffer, &count);
+	RegCloseKey(hkey);
+    }
     TRACE("Using '%s' as default sans serif font\n", buffer);
     lfd = LFD_Parse(buffer);
     if (lfd)
@@ -1599,18 +1643,24 @@
     /* then user specified aliases */
     do
     {
-        BOOL bHaveAlias, bSubst;
+        BOOL bSubst;
 	char subsection[32];
         snprintf( subsection, sizeof subsection, "%s%i", INIAliasSection, i++ );
 
-	bHaveAlias = PROFILE_GetWineIniString( INIFontSection, 
-						subsection, "", buffer, sizeof buffer);
-	if (!bHaveAlias)
+	buffer[0] = 0;
+	if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
+	{
+	    DWORD type, count = sizeof(buffer);
+	    RegQueryValueExA(hkey, subsection, 0, &type, buffer, &count);
+	    RegCloseKey(hkey);
+	}
+
+	if (!buffer[0])
 	    break;
 
 	XFONT_InitialCapitals(buffer);
-	lpResource = PROFILE_GetStringItem( buffer );
-	bSubst = (PROFILE_GetStringItem( lpResource )) ? TRUE : FALSE;
+	lpResource = XFONT_GetStringItem( buffer );
+	bSubst = (XFONT_GetStringItem( lpResource )) ? TRUE : FALSE;
 	if( lpResource && *lpResource )
 	{
 	    lfd = LFD_Parse(lpResource);
@@ -1731,10 +1781,18 @@
     /* Others from INI file */
     do
     {
+	HKEY hkey;
 	sprintf( subsection, "%s%i", INIIgnoreSection, i++ );
 
-	if( PROFILE_GetWineIniString( INIFontSection,
-				      subsection, "", buffer, sizeof buffer) )
+	buffer[0] = 0;
+	if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
+	{
+	    DWORD type, count = sizeof(buffer);
+	    RegQueryValueExA(hkey, subsection, 0, &type, buffer, &count);
+	    RegCloseKey(hkey);
+	}
+
+	if( buffer[0] )
 	{
 	    char* pch = buffer;
 	    while( *pch && isspace(*pch) ) pch++;
@@ -2240,8 +2298,19 @@
     int i, j, point_resolution, num = 3; 
     int allowed_xfont_resolutions[3] = { 72, 75, 100 };
     int best = 0, best_diff = 65536;
+    HKEY hkey;
+
+    point_resolution = 0;
+
+    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
+    {
+	char buffer[20];
+	DWORD type, count = sizeof(buffer);
+	if(!RegQueryValueExA(hkey, INIResolution, 0, &type, buffer, &count))
+	    point_resolution = atoi(buffer);
+	RegCloseKey(hkey);
+    }
 
-    point_resolution = PROFILE_GetWineIniInt( INIFontSection, INIResolution, 0 );
     if( !point_resolution )
 	point_resolution = pDevCaps->logPixelsY;
     else
@@ -2714,6 +2783,7 @@
   unsigned  x_checksum;
   int       i,res, x_count, fd, buf_size;
   char      *buffer;
+  HKEY hkey;
 
   res = XFONT_GetPointResolution( pDevCaps );
       
@@ -2740,7 +2810,15 @@
 
   /* deal with systemwide font metrics cache */
 
-  if( PROFILE_GetWineIniString( INIFontSection, INIGlobalMetrics, "", buffer, buf_size ) )
+  buffer[0] = 0;
+  if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, INIFontSection, &hkey))
+  {
+	DWORD type, count = buf_size;
+	RegQueryValueExA(hkey, INIGlobalMetrics, 0, &type, buffer, &count);
+	RegCloseKey(hkey);
+  }
+
+  if( buffer[0] )
   {
       fd = open( buffer, O_RDONLY );
       XFONT_ReadCachedMetrics(fd, DefResolution, x_checksum, x_count);
diff -u cvs/hq/wine/objects/gdiobj.c wine/objects/gdiobj.c
--- cvs/hq/wine/objects/gdiobj.c	Wed May 23 18:53:32 2001
+++ wine/objects/gdiobj.c	Mon Jun 18 16:35:34 2001
@@ -21,6 +21,7 @@
 #include "font.h"
 #include "heap.h"
 #include "local.h"
+#include "options.h"
 #include "palette.h"
 #include "pen.h"
 #include "region.h"
@@ -173,27 +174,11 @@
 static SYSLEVEL GDI_level = { CRITICAL_SECTION_INIT, 3 };
 static WORD GDI_HeapSel;
 
-static BOOL get_bool(char *buffer, BOOL def_value)
+static BOOL get_bool(const char *buffer, BOOL def_value)
 {
-    switch(buffer[0])
-    {
-	case 'n':
-	case 'N':
-	case 'f':
-	case 'F':
-	case '0':
-	    return FALSE;
-
-	case 'y':
-	case 'Y':
-	case 't':
-	case 'T':
-	case '1':
-	    return TRUE;
-
-	default:
-	    return def_value;
-    }
+    if(IS_OPTION_TRUE(buffer[0])) return TRUE;
+    if(IS_OPTION_FALSE(buffer[0])) return FALSE;
+    return def_value;
 }
 
 /******************************************************************************
diff -u cvs/hq/wine/windows/x11drv/clipboard.c wine/windows/x11drv/clipboard.c
--- cvs/hq/wine/windows/x11drv/clipboard.c	Sat Jun  9 14:12:34 2001
+++ wine/windows/x11drv/clipboard.c	Mon Jun 18 18:43:38 2001
@@ -53,10 +53,10 @@
 #include <unistd.h>
 #include <fcntl.h>
 
+#include "winreg.h"
 #include "clipboard.h"
 #include "win.h"
 #include "x11drv.h"
-#include "options.h"
 #include "debugtools.h"
 
 DEFAULT_DEBUG_CHANNEL(clipboard);
@@ -217,17 +217,28 @@
 BOOL X11DRV_CLIPBOARD_LaunchServer()
 {
     int iWndsLocks;
-    char clearSelection[8];
+    char clearSelection[8] = "0";
+    int persistent_selection = 1;
+    HKEY hkey;
 
     /* If persistant selection has been disabled in the .winerc Clipboard section,
      * don't launch the server
      */
-    if ( !PROFILE_GetWineIniInt("Clipboard", "PersistentSelection", 1) )
+    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Clipboard", &hkey))
+    {
+	char buffer[20];
+	DWORD type, count = sizeof(buffer);
+	if(!RegQueryValueExA(hkey, "PersistentSelection", 0, &type, buffer, &count))
+	    persistent_selection = atoi(buffer);
+
+	/* Get the clear selection preference */
+	count = sizeof(clearSelection);
+	RegQueryValueExA(hkey, "ClearAllSelections", 0, &type, clearSelection, &count);
+	RegCloseKey(hkey);
+    }
+    if ( !persistent_selection )
         return FALSE;
 
-    /* Get the clear selection preference */
-    sprintf(clearSelection, "%d", PROFILE_GetWineIniInt("Clipboard", "ClearAllSelections", 0));
-
     /*  Start up persistant WINE X clipboard server process which will
      *  take ownership of the X selection and continue to service selection
      *  requests from other apps.
@@ -547,7 +558,19 @@
           }
 
 	  if(text_cp == (UINT)-1)
-	      text_cp = PROFILE_GetWineIniInt("x11drv", "TextCP", CP_ACP);
+	  {
+	      HKEY hkey;
+	      /* default value */
+	      text_cp = CP_ACP;
+	      if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
+	      {
+	          char buf[20];
+		  DWORD type, count = sizeof(buf);
+		  if(!RegQueryValueExA(hkey, "TextCP", 0, &type, buf, &count))
+		      text_cp = atoi(buf);
+		  RegCloseKey(hkey);
+	      }
+	  }
 
 	  count = MultiByteToWideChar(text_cp, 0, lpstr, -1, NULL, 0);
 	  hUnicodeText = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, count * sizeof(WCHAR));
@@ -677,7 +700,16 @@
 {
     Display *display = thread_display();
     Atom xaClipboard = TSXInternAtom(display, "CLIPBOARD", False);
-    int clearAllSelections = PROFILE_GetWineIniInt("Clipboard", "ClearAllSelections", 0);
+    int clearAllSelections = 0;
+    HKEY hkey;
+
+    if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Clipboard", &hkey))
+    {
+	char buffer[20];
+	DWORD type, count = sizeof(buffer);
+	if(!RegQueryValueExA(hkey, "ClearAllSelections", 0, &type, buffer, &count))
+	    clearAllSelections = atoi(buffer);
+    }
     
     /* w is the window that lost the selection
      * selectionPrevWindow is nonzero if CheckSelection() was called. 






More information about the wine-patches mailing list