From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Plugins/Library/ml_pmp/config.cpp | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Src/Plugins/Library/ml_pmp/config.cpp (limited to 'Src/Plugins/Library/ml_pmp/config.cpp') diff --git a/Src/Plugins/Library/ml_pmp/config.cpp b/Src/Plugins/Library/ml_pmp/config.cpp new file mode 100644 index 00000000..c14f110d --- /dev/null +++ b/Src/Plugins/Library/ml_pmp/config.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include + +#include "config.h" + +C_Config::~C_Config() +{ + free(m_inifile); + free(m_section); +} + +C_Config::C_Config(wchar_t *ini, wchar_t *section, C_Config * globalWrite) : globalWrite(globalWrite) +{ + m_strbuf[0]=0; + m_inifile=_wcsdup(ini); + m_section=_wcsdup(section); +} + +void C_Config::WriteInt(wchar_t *name, int value, wchar_t *section) +{ + wchar_t buf[32] = {0}; + wsprintf(buf,L"%d",value); + WriteString(name,buf,section); +} + +int C_Config::ReadInt(wchar_t *name, int defvalue, wchar_t *section) +{ + return GetPrivateProfileInt(section?section:m_section,name,defvalue,m_inifile); +} + +wchar_t *C_Config::WriteString(wchar_t *name, wchar_t *string, wchar_t *section) +{ + if(globalWrite && !section) globalWrite->WriteString(name,string,m_section); + WritePrivateProfileString(section?section:m_section,name,string,m_inifile); + return name; +} + +wchar_t *C_Config::ReadString(wchar_t *name, wchar_t *defstr, wchar_t *section) +{ + static wchar_t foobuf[] = L"___________config_lameness___________"; + m_strbuf[0]=0; + GetPrivateProfileString(section?section:m_section,name,foobuf,m_strbuf,sizeof(m_strbuf)/sizeof(wchar_t),m_inifile); + if (!lstrcmp(foobuf,m_strbuf)) return defstr; + + m_strbuf[sizeof(m_strbuf)/sizeof(wchar_t)-1]=0; + return m_strbuf; +} \ No newline at end of file -- cgit