Replace PROFILE_* functions by Reg* in wineps

Dmitry Timoshkov dmitry at baikal.ru
Mon Jul 2 04:57:05 CDT 2001


Hello.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Replace PROFILE_* functions by Reg* in wineps.

diff -u cvs/hq/wine/dlls/wineps/afm.c wine/dlls/wineps/afm.c
--- cvs/hq/wine/dlls/wineps/afm.c	Fri Jun 15 04:06:26 2001
+++ wine/dlls/wineps/afm.c	Mon Jul 02 04:56:30 2001
@@ -17,8 +17,8 @@
 # include <float.h>  	/* FLT_MAX */
 #endif
 #include "winnt.h"  	/* HEAP_ZERO_MEMORY */
+#include "winreg.h"
 #include "psdrv.h"
-#include "options.h"
 #include "debugtools.h"
 #include "heap.h"
 
@@ -977,15 +977,23 @@
 
 BOOL PSDRV_GetFontMetrics(void)
 {
-    int idx = 0;
+    int idx;
     char key[256];
     char value[256];
+    HKEY hkey;
+    DWORD type, key_len, value_len;
 
     if (PSDRV_GlyphListInit() != 0)
 	return FALSE;
 
-    while (PROFILE_EnumWineIniString( "afmfiles", idx++, key, sizeof(key),
-    	    value, sizeof(value)))
+    if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\afmfiles",
+		     0, KEY_READ, &hkey))
+	goto no_afmfiles;
+
+    idx = 0;
+    key_len = sizeof(key);
+    value_len = sizeof(value);
+    while(!RegEnumValueA(hkey, idx++, key, &key_len, NULL, &type, value, &value_len))
     {
         AFM* afm = PSDRV_AFMParse(value);
 	
@@ -995,18 +1003,44 @@
                 PSDRV_ReencodeCharWidths(afm);
             }
             if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
+		RegCloseKey(hkey);
 	    	return FALSE;
 	    }
         }
 	else {
 	    WARN("Error parsing %s\n", value);
 	}
-    }
 
-    for (idx = 0; PROFILE_EnumWineIniString ("afmdirs", idx, key, sizeof (key),
-	    value, sizeof (value)); ++idx)
+	/* initialize lengths for new iteration */
+	key_len = sizeof(key);
+	value_len = sizeof(value);
+    }
+    RegCloseKey(hkey);
+
+no_afmfiles:
+
+    if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\afmdirs",
+		     0, KEY_READ, &hkey))
+	goto no_afmdirs;
+
+    idx = 0;
+    key_len = sizeof(key);
+    value_len = sizeof(value);
+    while(!RegEnumValueA(hkey, idx++, key, &key_len, NULL, &type, value, &value_len))
+    {
 	if (PSDRV_ReadAFMDir (value) == FALSE)
+	{
+	    RegCloseKey(hkey);
 	    return FALSE;
+	}
+
+	/* initialize lengths for new iteration */
+	key_len = sizeof(key);
+	value_len = sizeof(value);
+    }
+    RegCloseKey(hkey);
+
+no_afmdirs:
 
     PSDRV_IndexGlyphList(); 	    	/* So SortFontMetrics will work */
     if (SortFontMetrics() == FALSE)
diff -u cvs/hq/wine/dlls/wineps/init.c wine/dlls/wineps/init.c
--- cvs/hq/wine/dlls/wineps/init.c	Fri Jun 15 04:06:26 2001
+++ wine/dlls/wineps/init.c	Mon Jul 02 05:11:50 2001
@@ -18,7 +18,6 @@
 #include "winreg.h"
 #include "winspool.h"
 #include "winerror.h"
-#include "options.h"
 
 #ifdef HAVE_CUPS
 # include <cups/cups.h>
@@ -468,6 +467,7 @@
     HANDLE hPrinter;
     const char *ppd = NULL;
     char ppdFileName[256];
+    HKEY hkey;
 
     TRACE("'%s'\n", name);
     
@@ -538,10 +538,16 @@
     /* Look for a ppd file for this printer in the config file.
      * First look for the names of the printer, then for 'generic'
      */
-    if ((res!=ERROR_SUCCESS) &&
-	!PROFILE_GetWineIniString("ppd",name,"",ppdFileName,sizeof(ppdFileName))	&&
-    	!PROFILE_GetWineIniString("ppd","generic","",ppdFileName,sizeof(ppdFileName))
-    )
+    if((res != ERROR_SUCCESS) && !RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\ppd", &hkey))
+    {
+	DWORD count = sizeof(ppdFileName);
+	ppdFileName[0] = 0;
+	if(RegQueryValueExA(hkey, name, 0, &type, ppdFileName, &count) != ERROR_SUCCESS)
+	    RegQueryValueExA(hkey, "generic", 0, &type, ppdFileName, &count);
+	RegCloseKey(hkey);
+    }
+
+    if(!ppdFileName[0])
 	res = ERROR_FILE_NOT_FOUND;
     else 
 	res = ERROR_SUCCESS;
diff -u cvs/hq/wine/dlls/wineps/truetype.c wine/dlls/wineps/truetype.c
--- cvs/hq/wine/dlls/wineps/truetype.c	Fri Jun 15 04:06:26 2001
+++ wine/dlls/wineps/truetype.c	Mon Jul 02 05:14:52 2001
@@ -39,7 +39,7 @@
 #include <stdio.h>
 
 #include "winnt.h"
-#include "options.h"
+#include "winreg.h"
 #include "psdrv.h"
 #include "debugtools.h"
 #include "heap.h"
@@ -558,11 +558,13 @@
  *  that event.
  *
  */
-BOOL PSDRV_GetTrueTypeMetrics()
+BOOL PSDRV_GetTrueTypeMetrics(void)
 {
     CHAR    	keybuf[256], namebuf[256];
     INT     	i = 0;
     FT_Error	error;
+    HKEY hkey;
+    DWORD type, key_len, name_len;
 
     error = FT_Init_FreeType(&library);
     if (error != FT_Err_Ok)
@@ -571,8 +573,13 @@
 	return FALSE;
     }
 
-    while (PROFILE_EnumWineIniString("TrueType Font Directories", i++, keybuf,
-    	    sizeof(keybuf), namebuf, sizeof(namebuf)))
+    if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\TrueType Font Directories",
+		     0, KEY_READ, &hkey))
+	goto no_metrics;
+
+    key_len = sizeof(keybuf);
+    name_len = sizeof(namebuf);
+    while(!RegEnumValueA(hkey, i++, keybuf, &key_len, NULL, &type, namebuf, &name_len))
     {
     	struct dirent	*dent;
     	DIR 	    	*dir;
@@ -614,14 +621,21 @@
 	    {
 	    	ERR("Error reading '%s'\n", namebuf);
 	    	closedir(dir);
+		RegCloseKey(hkey);
 		FT_Done_FreeType(library);
 		return FALSE;
 	    }
 	}
 	
 	closedir(dir);
+
+	/* initialize lengths for new iteration */
+	key_len = sizeof(keybuf);
+	name_len = sizeof(namebuf);
     }
-   
+    RegCloseKey(hkey);
+
+no_metrics:
     FT_Done_FreeType(library);
     return TRUE;
 }






More information about the wine-patches mailing list