Replace PROFILE_* functions by Reg*.

This commit is contained in:
Dmitry Timoshkov 2001-07-02 18:00:33 +00:00 committed by Alexandre Julliard
parent 6ae29d6ac0
commit 043f64021d
3 changed files with 71 additions and 17 deletions

View File

@ -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 @@ static BOOL PSDRV_ReadAFMDir(const char* afmdir) {
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 @@ BOOL PSDRV_GetFontMetrics(void)
PSDRV_ReencodeCharWidths(afm);
}
if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
RegCloseKey(hkey);
return FALSE;
}
}
else {
WARN("Error parsing %s\n", value);
}
/* 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;
}
for (idx = 0; PROFILE_EnumWineIniString ("afmdirs", idx, key, sizeof (key),
value, sizeof (value)); ++idx)
if (PSDRV_ReadAFMDir (value) == FALSE)
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)

View File

@ -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 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
HANDLE hPrinter;
const char *ppd = NULL;
char ppdFileName[256];
HKEY hkey;
TRACE("'%s'\n", name);
@ -538,10 +538,16 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
/* 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;

View File

@ -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 @@ static BOOL ReadTrueTypeFile(LPCSTR filename)
* 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 @@ BOOL PSDRV_GetTrueTypeMetrics()
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 @@ BOOL PSDRV_GetTrueTypeMetrics()
{
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;
}