win32: Remove unused StdConfig class and associated Registry APIs

It has long since been replaced by the StdCompilerConfig* classes. A few
of the Registry functions are still used in other code, and a few are now
implementation details.
Günther Brammer 2011-04-02 17:49:55 +02:00
parent bd051a972d
commit 6e30f2b7e8
9 changed files with 6 additions and 328 deletions

View File

@ -462,8 +462,6 @@ set(OC_CLONK_SOURCES
src/platform/PlatformAbstraction.h
src/platform/StdApp.h
src/platform/StdAppCommon.cpp
src/platform/StdConfig.cpp
src/platform/StdConfig.h
src/platform/StdD3D.cpp
src/platform/StdD3D.h
src/platform/StdD3DShader.cpp
@ -896,8 +894,6 @@ add_executable(c4script EXCLUDE_FROM_ALL
src/lib/StdResStr2.cpp
src/lib/StdResStr2.h
src/platform/GetTime.cpp
src/platform/StdConfig.cpp
src/platform/StdConfig.h
src/platform/StdFile.cpp
src/platform/StdFile.h
src/lib/C4Real.cpp

View File

@ -133,8 +133,6 @@ src/lib/StdResStr2.cpp \
src/lib/StdResStr2.h \
src/network/C4NetIO.cpp \
src/platform/GetTime.cpp \
src/platform/StdConfig.cpp \
src/platform/StdConfig.h \
src/platform/StdFile.cpp \
src/platform/StdFile.h \
src/platform/StdRegistry.cpp \

View File

@ -25,12 +25,12 @@
#ifndef INC_C4Config
#define INC_C4Config
#include "StdConfig.h"
#include "C4Constants.h"
#include "C4InputValidation.h"
#include <list>
#define C4DEFAULT_FONT_NAME "Endeavour"
enum { CFG_MaxString = 1024 };
class C4ConfigGeneral
{
@ -247,7 +247,7 @@ public:
void CompileFunc(StdCompiler *pComp);
};
class C4Config: protected CStdConfig
class C4Config
{
public:
C4Config();

View File

@ -481,7 +481,7 @@ const char* C4ConfigShareware::GetRegistrationData(const char *strField)
size_t iValueLen = 256;
const char *pFieldEnd = strstr(pKeyField, "\x0d");
if (pFieldEnd) iValueLen = pFieldEnd - pKeyField;
iValueLen = Min(iValueLen, CFG_MaxString);
iValueLen = Min<size_t>(iValueLen, CFG_MaxString);
strncpy(strReturnValue, pKeyField, iValueLen); strReturnValue[iValueLen] = 0;
return strReturnValue;
}

View File

@ -1,139 +0,0 @@
/*
* OpenClonk, http://www.openclonk.org
*
* Copyright (c) 1998-2000 Matthes Bender
* Copyright (c) 2009 Günther Brammer
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
*
* Portions might be copyrighted by other authors who have contributed
* to OpenClonk.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* See isc_license.txt for full license and disclaimer.
*
* "Clonk" is a registered trademark of Matthes Bender.
* See clonk_trademark_license.txt for full license.
*/
/* Auto-registering data structures */
#include "C4Include.h"
#include <StdRegistry.h>
#include <StdConfig.h>
#include <stdio.h>
CStdConfig::CStdConfig()
{
}
CStdConfig::~CStdConfig()
{
}
bool CStdConfig::Load(CStdConfigValue *pCfgMap, void *vpData)
{
#ifdef _WIN32
if (!pCfgMap || !vpData) return false;
char szCompany[100+1]="Company";
char szProduct[100+1]="Product";
char szSection[100+1]="Section";
char szSubkey[1024+1];
DWORD dwValue;
char szValue[CFG_MaxString+1];
for (; pCfgMap && (pCfgMap->Type!=CFG_End); pCfgMap++)
switch (pCfgMap->Type)
{
case CFG_Company: SCopy(pCfgMap->Name,szCompany,100); break;
case CFG_Section: SCopy(pCfgMap->Name,szSection,100); break;
case CFG_Product: SCopy(pCfgMap->Name,szProduct,100); break;
case CFG_Integer:
sprintf(szSubkey,"Software\\%s\\%s\\%s",szCompany,szProduct,szSection);
if (!pCfgMap->Name || !GetRegistryDWord(szSubkey,pCfgMap->Name,&dwValue))
dwValue=pCfgMap->Default;
*((int*)(((BYTE*)vpData)+pCfgMap->Offset)) = dwValue;
break;
case CFG_String:
sprintf(szSubkey,"Software\\%s\\%s\\%s",szCompany,szProduct,szSection);
if (!pCfgMap->Name || !GetRegistryString(szSubkey,pCfgMap->Name,szValue,CFG_MaxString))
SCopy((char*)pCfgMap->Default,szValue,CFG_MaxString);
SCopy(szValue,((char*)vpData)+pCfgMap->Offset);
break;
}
#endif
return true;
}
bool CStdConfig::Save(CStdConfigValue *pCfgMap, void *vpData)
{
#ifdef _WIN32
if (!pCfgMap || !vpData) return false;
char szCompany[100+1]="Company";
char szProduct[100+1]="Product";
char szSection[100+1]="Section";
char szSubkey[1024+1];
for (; pCfgMap && (pCfgMap->Type!=CFG_End); pCfgMap++)
switch (pCfgMap->Type)
{
case CFG_Company: SCopy(pCfgMap->Name,szCompany,100); break;
case CFG_Section: SCopy(pCfgMap->Name,szSection,100); break;
case CFG_Product: SCopy(pCfgMap->Name,szProduct,100); break;
case CFG_Integer:
sprintf(szSubkey,"Software\\%s\\%s\\%s",szCompany,szProduct,szSection);
if (pCfgMap->Name)
SetRegistryDWord(szSubkey,pCfgMap->Name, *((int*)(((BYTE*)vpData)+pCfgMap->Offset)) );
break;
case CFG_String:
// Compose value path
sprintf(szSubkey,"%s",szSection);
// Write if value
if (*(((char*)vpData)+pCfgMap->Offset))
{
if (pCfgMap->Name)
SetRegistryString(szSubkey,pCfgMap->Name, ((char*)vpData)+pCfgMap->Offset );
}
// Else delete value
else
{
DeleteRegistryValue(szSubkey,pCfgMap->Name);
}
break;
}
#endif
return true;
}
void CStdConfig::LoadDefault(CStdConfigValue *pCfgMap, void *vpData, const char *szOnlySection)
{
if (!pCfgMap || !vpData) return;
char szCompany[100+1]="Company";
char szProduct[100+1]="Product";
char szSection[100+1]="Section";
for (; pCfgMap && (pCfgMap->Type!=CFG_End); pCfgMap++)
switch (pCfgMap->Type)
{
case CFG_Company: SCopy(pCfgMap->Name,szCompany,100); break;
case CFG_Section: SCopy(pCfgMap->Name,szSection,100); break;
case CFG_Product: SCopy(pCfgMap->Name,szProduct,100); break;
case CFG_Integer:
if (!szOnlySection || SEqual(szSection,szOnlySection))
*((int*)(((BYTE*)vpData)+pCfgMap->Offset)) = pCfgMap->Default;
break;
case CFG_String:
if (!szOnlySection || SEqual(szSection,szOnlySection))
SCopy((char*)pCfgMap->Default,((char*)vpData)+pCfgMap->Offset,CFG_MaxString);
break;
}
}

View File

@ -1,57 +0,0 @@
/*
* OpenClonk, http://www.openclonk.org
*
* Copyright (c) 1998-2000 Matthes Bender
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
*
* Portions might be copyrighted by other authors who have contributed
* to OpenClonk.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* See isc_license.txt for full license and disclaimer.
*
* "Clonk" is a registered trademark of Matthes Bender.
* See clonk_trademark_license.txt for full license.
*/
/* Auto-registering data structures */
#ifndef STDCONFIG_H
#define STDCONFIG_H
#include <StdCompiler.h>
const size_t CFG_MaxString = 1024;
const int CFG_String = 1,
CFG_Integer = 2,
CFG_Company = 10,
CFG_Product = 11,
CFG_Section = 12,
CFG_End = 0;
class CStdConfigValue
{
public:
int Type;
const char *Name;
int Offset;
long Default; // Pointers are cast into this field, so be prepared
// to hold 64 bit on x86_64
};
class CStdConfig
{
public:
CStdConfig();
~CStdConfig();
protected:
void LoadDefault(CStdConfigValue *pCfgMap, void *vpData, const char *szOnlySection=NULL);
bool Save(CStdConfigValue *pCfgMap, void *vpData);
bool Load(CStdConfigValue *pCfgMap, void *vpData);
};
#endif // STDCONFIG_H

View File

@ -30,105 +30,6 @@
#include <C4windowswrapper.h>
#include <stdio.h>
bool DeleteRegistryValue(const char *szSubKey, const char *szValueName)
{
return DeleteRegistryValue(HKEY_CURRENT_USER,szSubKey,szValueName);
}
bool DeleteRegistryValue(HKEY hKey, const char *szSubKey, const char *szValueName)
{
long qerr;
HKEY ckey;
// Open the key
if ((qerr=RegOpenKeyEx(hKey,
szSubKey,
0,
KEY_ALL_ACCESS,
&ckey
))!=ERROR_SUCCESS) return false;
// Delete the key
if ((qerr=RegDeleteValue(ckey,
szValueName
))!=ERROR_SUCCESS) return false;
// Close the key
RegCloseKey(ckey);
// Success
return true;
}
bool SetRegistryDWord(const char *szSubKey, const char *szValueName, DWORD dwValue)
{
return SetRegistryDWord(HKEY_CURRENT_USER,szSubKey,szValueName,dwValue);
}
bool GetRegistryDWord(const char *szSubKey, const char *szValueName, DWORD *lpdwValue)
{
return GetRegistryDWord(HKEY_CURRENT_USER,szSubKey,szValueName,lpdwValue);
}
bool GetRegistryDWord(HKEY hKey, const char *szSubKey, const char *szValueName, DWORD *lpdwValue)
{
long qerr;
HKEY ckey;
DWORD valtype;
DWORD valsize=sizeof(DWORD);
// Open the key
if ((qerr=RegOpenKeyEx(hKey,
szSubKey,
0,
KEY_READ,
&ckey
))!=ERROR_SUCCESS) return false;
// Get the value
if ((qerr=RegQueryValueEx(ckey,
szValueName,
NULL,
&valtype,
(BYTE*) lpdwValue,
&valsize
))!=ERROR_SUCCESS) { RegCloseKey(ckey); return false; }
// Close the key
RegCloseKey(ckey);
if (valtype!=REG_DWORD) return false;
return true;
}
bool SetRegistryDWord(HKEY hKey, const char *szSubKey, const char *szValueName, DWORD dwValue)
{
long qerr;
HKEY ckey;
DWORD disposition;
// Open the key
if ((qerr=RegCreateKeyEx(hKey,
szSubKey,
0,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&ckey,
&disposition
))!=ERROR_SUCCESS) return false;
// Set the value
if ((qerr=RegSetValueEx(ckey,
szValueName,
0,
REG_DWORD,
(BYTE*) &dwValue,
sizeof(dwValue)
))!=ERROR_SUCCESS) { RegCloseKey(ckey); return false; }
// Close the key
RegCloseKey(ckey);
// Success
return true;
}
bool GetRegistryString(const char *szSubKey,
const char *szValueName,
char *sValue, DWORD dwValSize)
@ -198,7 +99,7 @@ bool SetRegistryString(const char *szSubKey,
return true;
}
bool DeleteRegistryKey(HKEY hKey, const char *szSubKey)
static bool DeleteRegistryKey(HKEY hKey, const char *szSubKey)
{
HKEY ckey;
// Open the key
@ -217,12 +118,12 @@ bool DeleteRegistryKey(HKEY hKey, const char *szSubKey)
return true;
}
bool DeleteRegistryKey(const char *szSubKey)
static bool DeleteRegistryKey(const char *szSubKey)
{
return DeleteRegistryKey(HKEY_CURRENT_USER, szSubKey);
}
bool SetRegClassesRoot(const char *szSubKey,
static bool SetRegClassesRoot(const char *szSubKey,
const char *szValueName,
const char *szStringValue)
{

View File

@ -26,30 +26,10 @@
#ifdef _WIN32
#include "StdCompiler.h"
#include <C4windowswrapper.h>
bool DeleteRegistryValue(HKEY hKey, const char *szSubKey,
const char *szValueName);
bool DeleteRegistryValue(const char *szSubKey, const char *szValueName);
bool GetRegistryDWord(HKEY hKey, const char *szSubKey,
const char *szValueName, DWORD *lpdwValue);
bool GetRegistryDWord(const char *szSubKey, const char *szValueName, DWORD *lpdwValue);
bool SetRegistryDWord(HKEY hKey, const char *szSubKey,
const char *szValueName, DWORD dwValue);
bool SetRegistryDWord(const char *szSubKey, const char *szValueName, DWORD dwValue);
bool GetRegistryString(const char *szSubKey, const char *szValueName, char *sValue, DWORD dwValSize);
bool SetRegistryString(const char *szSubKey, const char *szValueName, const char *szValue);
bool DeleteRegistryKey(HKEY hKey, const char *szSubKey);
bool DeleteRegistryKey(const char *szSubKey);
bool SetRegClassesRoot(const char *szSubKey,
const char *szValueName,
const char *szStringValue);
bool SetRegShell(const char *szClassName,
const char *szShellName,
const char *szShellCaption,

View File

@ -32,7 +32,6 @@
#include <StdWindow.h>
#include <StdRegistry.h>
#include <StdResStr.h>
#include <StdConfig.h>
#include <StdSurface2.h>
#include <StdFacet.h>
#include <StdDDraw2.h>