summaryrefslogtreecommitdiffstats
path: root/Src/pfc
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 14:54:57 +0200
committerJef <jef@targetspot.com>2024-09-24 14:54:57 +0200
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/pfc
parentAdding .gitignore (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar
winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.bz2
winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.lz
winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.xz
winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.zst
winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.zip
Diffstat (limited to 'Src/pfc')
-rw-r--r--Src/pfc/cfg_var.cpp138
-rw-r--r--Src/pfc/cfg_var.h124
-rw-r--r--Src/pfc/critsec.h14
-rw-r--r--Src/pfc/foobar2000.h3
-rw-r--r--Src/pfc/grow_buf.cpp78
-rw-r--r--Src/pfc/grow_buf.h42
-rw-r--r--Src/pfc/mem_block.h55
-rw-r--r--Src/pfc/pfc.dsp116
-rw-r--r--Src/pfc/pfc.dsw41
-rw-r--r--Src/pfc/pfc.h20
-rw-r--r--Src/pfc/pfc_unicode.dsp132
-rw-r--r--Src/pfc/ptr_list.h127
-rw-r--r--Src/pfc/string.cpp34
-rw-r--r--Src/pfc/string.h205
-rw-r--r--Src/pfc/string_unicode.cpp250
-rw-r--r--Src/pfc/string_unicode.h60
16 files changed, 1439 insertions, 0 deletions
diff --git a/Src/pfc/cfg_var.cpp b/Src/pfc/cfg_var.cpp
new file mode 100644
index 000000000..58ca463e0
--- /dev/null
+++ b/Src/pfc/cfg_var.cpp
@@ -0,0 +1,138 @@
+#define STRICT
+#include <windows.h>
+#include "cfg_var.h"
+#include "string_unicode.h"
+
+static const char *m_inifile, *m_section;
+
+int cfg_var::reg_read_int(HKEY hk,int def)
+{
+
+ return GetPrivateProfileIntA(m_section,var_get_name(),def,m_inifile);
+}
+
+void cfg_var::reg_write_int(HKEY hk,int val)
+{
+/* long temp=val;
+ RegSetValueEx(hk,var_get_name(),0,REG_DWORD,(const BYTE*)&temp,4);*/
+ char tmp[512] = {0};
+ wsprintfA(tmp,"%d",val);
+ WritePrivateProfileStringA(m_section,var_get_name(),tmp,m_inifile);
+}
+
+void cfg_var::reg_write_struct(HKEY hk,const void * ptr,UINT size)
+{
+
+ WritePrivateProfileStructA(m_section,var_get_name(),(void *)ptr,size,m_inifile);
+}
+
+bool cfg_var::reg_read_struct(HKEY hk,void * ptr,UINT size)
+{
+ GetPrivateProfileStructA(m_section,var_get_name(),ptr,size,m_inifile);
+ return 1;
+}
+
+int cfg_var::reg_get_struct_size(HKEY hk)
+{
+ DWORD sz=0,t=0;
+ if (RegQueryValueExA(hk,var_get_name(),0,&t,0,&sz)!=ERROR_SUCCESS) return 0;
+ return sz;
+}
+
+bool string_a::reg_read(HKEY hk,const char * name)
+{
+ char tmp[4096] = {0};
+ GetPrivateProfileStringA(m_section,name,"|||",tmp,sizeof(tmp)-1,m_inifile);
+ if(strstr(tmp,"|||")==tmp) return 0;
+ lstrcpyA(buffer_get(strlen(tmp)+1),tmp);
+ buffer_done();
+ return 1;
+}
+
+void string_a::reg_write(HKEY hk,const char * name)
+{
+ WritePrivateProfileStringA(m_section,name,(const char*)*this,m_inifile);
+}
+
+
+cfg_var * cfg_var::list=0;
+
+/*HKEY cfg_var::reg_open(const char * regname)
+{
+ HKEY hk;
+ RegCreateKey(HKEY_CURRENT_USER,regname,&hk);
+ return hk;
+}*/
+
+
+void cfg_var::config_read(const char *inifile, const char *section)
+{
+ HKEY hk = 0; //reg_open(regname);
+ m_inifile=inifile;
+ m_section=section;
+ cfg_var * ptr;
+ for(ptr = list; ptr; ptr=ptr->next) ptr->read(hk);
+ //RegCloseKey(hk);
+}
+
+void cfg_var::config_write(const char *inifile, const char *section)
+{
+ HKEY hk = 0; //reg_open(regname);
+ m_inifile=inifile;
+ m_section=section;
+ cfg_var * ptr;
+ for(ptr = list; ptr; ptr=ptr->next) ptr->write(hk);
+ //RegCloseKey(hk);
+}
+
+void cfg_var::config_reset()
+{
+ cfg_var * ptr;
+ for(ptr = list; ptr; ptr=ptr->next) ptr->reset();
+}
+
+void cfg_int::read(HKEY hk)
+{
+ val = reg_read_int(hk,def);
+}
+
+void cfg_int::write(HKEY hk)
+{
+ if (val!=reg_read_int(hk,def))
+ reg_write_int(hk,val);
+}
+
+void cfg_string::read(HKEY hk)
+{
+ string_a temp;
+ if (temp.reg_read(hk,var_get_name())) val=temp;
+}
+
+void cfg_string::write(HKEY hk)
+{
+ string_a temp = def;
+ string_a name = var_get_name();
+
+ if (!temp.reg_read(hk,name) || lstrcmpA(val,temp))
+ val.reg_write(hk,name);
+}
+
+#ifdef PFC_UNICODE
+
+void cfg_string_w::read(HKEY hk)
+{
+ string_w temp;
+ if (temp.reg_read(hk,string_w(var_get_name()))) val=temp;
+}
+
+void cfg_string_w::write(HKEY hk)
+{
+ string_w temp = def;
+ string_w name = var_get_name();
+ string_w val_w = val;
+
+ if (!temp.reg_read(hk,name) || wcscmp(val_w,temp))
+ val_w.reg_write(hk,name);
+}
+
+#endif \ No newline at end of file
diff --git a/Src/pfc/cfg_var.h b/Src/pfc/cfg_var.h
new file mode 100644
index 000000000..68f8863df
--- /dev/null
+++ b/Src/pfc/cfg_var.h
@@ -0,0 +1,124 @@
+#ifndef _PFC_CFG_VAR_H_
+#define _PFC_CFG_VAR_H_
+
+#ifndef NOVTABLE
+#define NOVTABLE _declspec(novtable)
+#endif
+
+#include "string.h"
+#include "string_unicode.h"
+
+//unicode in reg functions is NOT working
+
+class NOVTABLE cfg_var
+{
+private:
+ string var_name;
+ static cfg_var * list;
+ cfg_var * next;
+ static HKEY reg_open(const char * regname);
+protected:
+ cfg_var(const char * name) : var_name(name) {next=list;list=this;};
+
+ const char * var_get_name() {return var_name;}
+
+ //override me
+ virtual void read(HKEY hk)=0;
+ virtual void write(HKEY hk)=0;
+ virtual void reset()=0;
+
+ //helper
+ int reg_get_struct_size(HKEY hk);
+ bool reg_read_struct(HKEY hk,void * ptr,UINT size);
+ void reg_write_struct(HKEY hk,const void * ptr,UINT size);
+ void reg_write_int(HKEY hk,int val);
+ int reg_read_int(HKEY hk,int def);
+
+public:
+ static void config_read(const char *inifile, const char *section);
+ static void config_write(const char *inifile, const char *section);
+ static void config_reset();
+};
+
+class cfg_int : private cfg_var
+{
+private:
+ int val,def;
+ virtual void read(HKEY hk);
+ virtual void write(HKEY hk);
+ virtual void reset() {val=def;}
+public:
+ cfg_int(const wchar_t* name, int v) : cfg_var(string_utf8(name)) { val = def = v; }
+ cfg_int(const char * name,int v) : cfg_var(name) {val=def=v;}
+ operator int() const {return val;}
+ int operator=(int v) {return val=v;}
+ inline int get_def() {return def;}
+
+};
+
+class cfg_string : private cfg_var
+{
+private:
+ string val,def;
+ virtual void read(HKEY hk);
+ virtual void write(HKEY hk);
+ virtual void reset() {val=def;}
+public:
+ cfg_string(const char * name,const char * v) : cfg_var(name), val(v), def(v) {}
+ operator const char * () const {return val;}
+ const char * operator=(const char* v) {val=v;return val;}
+ string & get_string() {return val;}
+ void s_SetDlgItemText(HWND wnd,int id) {val.s_SetDlgItemText(wnd,id);}
+ void s_GetDlgItemText(HWND wnd,int id) {val.s_GetDlgItemText(wnd,id);}
+};
+
+#ifdef PFC_UNICODE
+
+class cfg_string_w : private cfg_var
+{
+private:
+ string_w val,def;
+ virtual void read(HKEY hk);
+ virtual void write(HKEY hk);
+ virtual void reset() {val=def;}
+public:
+ cfg_string_w(const char * name,const WCHAR * v) : cfg_var(name), val(v), def(v) {}
+ cfg_string_w(const char * name,const char * v) : cfg_var(name), val(string_w(v)), def(string_w(v)) {}
+ operator const WCHAR * () const {return val;}
+ void operator=(const WCHAR* v) {val=v;}
+ string_w & get_string() {return val;}
+ void s_SetDlgItemText(HWND wnd,int id) {val.s_SetDlgItemText(wnd,id);}
+ void s_GetDlgItemText(HWND wnd,int id) {val.s_GetDlgItemText(wnd,id);}
+};
+
+#endif
+
+template<class T>
+class cfg_struct_t : private cfg_var
+{
+private:
+ T val,def;
+
+ virtual void read(HKEY hk)
+ {
+ reg_read_struct(hk,&val,sizeof(T));
+ }
+
+ virtual void write(HKEY hk)
+ {
+ T temp = def;
+ reg_read_struct(hk,&temp,sizeof(T));
+ if (memcmp(&temp,&val,sizeof(T)))
+ reg_write_struct(hk,&val,sizeof(T));
+ }
+
+ virtual void reset() {val=def;}
+public:
+ cfg_struct_t(const char * name,const T& v) : cfg_var(name) {val=def=v;}
+ cfg_struct_t(const char * name,int filler) : cfg_var(name) {memset(&val,filler,sizeof(T));memset(&def,filler,sizeof(T));}
+ T& get_val() {return val;}
+ operator T&() {return val;}
+ T* operator=(const T& v) {val=v; return (T*)&val;}
+};
+
+#endif \ No newline at end of file
diff --git a/Src/pfc/critsec.h b/Src/pfc/critsec.h
new file mode 100644
index 000000000..54aad2723
--- /dev/null
+++ b/Src/pfc/critsec.h
@@ -0,0 +1,14 @@
+#ifndef _PFC_CRITSEC_H_
+#define _PFC_CRITSEC_H_
+
+class critical_section : public CRITICAL_SECTION
+{
+public:
+ inline void enter() {EnterCriticalSection(this);}
+ inline void leave() {LeaveCriticalSection(this);}
+ critical_section() {InitializeCriticalSection(this);}
+ ~critical_section() {DeleteCriticalSection(this);}
+ //BOOL TryEnter() {return TryEnterCriticalSection(this);}
+};
+
+#endif \ No newline at end of file
diff --git a/Src/pfc/foobar2000.h b/Src/pfc/foobar2000.h
new file mode 100644
index 000000000..b42a400b0
--- /dev/null
+++ b/Src/pfc/foobar2000.h
@@ -0,0 +1,3 @@
+#define PFC_UNICODE
+#include "../pfc/pfc.h"
+
diff --git a/Src/pfc/grow_buf.cpp b/Src/pfc/grow_buf.cpp
new file mode 100644
index 000000000..627f70db5
--- /dev/null
+++ b/Src/pfc/grow_buf.cpp
@@ -0,0 +1,78 @@
+#include "pfc.h"
+
+void grow_buf::makespace(int new_size)
+{
+ if (!ptr || !size)
+ {
+ size = 1;
+ while(size<new_size)
+ {
+ if (size == (1 << 31))
+ {
+ return;
+ }
+ size<<=1;
+ }
+ ptr = malloc(size);
+ }
+ else
+ {
+ if (size<new_size)
+ {
+ do
+ {
+ if (size == (1 << 31))
+ {
+ free(ptr);
+ ptr=0;
+ return;
+ }
+ size<<=1;
+ }
+ while (size<new_size);
+ ptr = realloc(ptr,size);
+ }
+ }
+}
+
+void * grow_buf::finish()
+{
+ void * rv=0;
+ if (ptr)
+ {
+ rv = realloc(ptr,used);
+ ptr = 0;
+ size = 0;
+ used = 0;
+ }
+ return rv;
+}
+
+void grow_buf::reset()
+{
+ if (ptr) {free(ptr);ptr=0;}
+ used=0;
+ size=0;
+}
+
+static void foo_memcpy(void * dst,const void * src,size_t bytes)
+{
+ if (src) memcpy(dst,src,bytes);
+ else memset(dst,0,bytes);
+}
+
+bool grow_buf::write(const void * data, size_t bytes)
+{
+ makespace(used+bytes);
+ if (!ptr)
+ return false;
+ foo_memcpy((char*)ptr+used,data,bytes);
+ used+=bytes;
+ return true;
+}
+
+void grow_buf::write_ptr(const void * data, int bytes,int offset)
+{
+ if (offset+bytes>used) {used = offset;write(data,bytes);}
+ else foo_memcpy((char*)ptr+offset,data,bytes);
+} \ No newline at end of file
diff --git a/Src/pfc/grow_buf.h b/Src/pfc/grow_buf.h
new file mode 100644
index 000000000..ab039ff88
--- /dev/null
+++ b/Src/pfc/grow_buf.h
@@ -0,0 +1,42 @@
+#ifndef _PFC_GROW_BUF_H_
+#define _PFC_GROW_BUF_H_
+
+class grow_buf
+{
+private:
+ void * ptr;
+ int size,used;
+ void makespace(int);
+public:
+ grow_buf(int init_size = 0)
+ {
+ if (init_size<8) init_size=8;
+ size = 0;
+ used = 0;
+ ptr = 0;
+ makespace(init_size);
+ }
+
+ ~grow_buf() {reset();}
+
+ inline const void * get_ptr_c() const {return ptr;}
+ inline void * get_ptr() {return ptr;}
+ inline int get_size() const {return used;}
+ inline void truncate(int z) {if (z<used) used=z;}
+
+ void * finish();
+ void reset();
+
+ bool write(const void * data, size_t bytes);
+ void write_ptr(const void * data, int bytes,int offset);
+
+ inline void write_byte(BYTE b) {write(&b,1);}
+ inline void write_word(WORD w) {write(&w,2);}
+ inline void write_dword(DWORD dw) {write(&dw,4);}
+ inline void write_byte_ptr(BYTE b,int ptr) {write_ptr(&b,1,ptr);}
+ inline void write_word_ptr(WORD w,int ptr) {write_ptr(&w,2,ptr);}
+ inline void write_dword_ptr(DWORD dw,int ptr) {write_ptr(&dw,4,ptr);}
+};
+
+
+#endif \ No newline at end of file
diff --git a/Src/pfc/mem_block.h b/Src/pfc/mem_block.h
new file mode 100644
index 000000000..733573157
--- /dev/null
+++ b/Src/pfc/mem_block.h
@@ -0,0 +1,55 @@
+#ifndef _PFC_MEM_BLOCK_H_
+#define _PFC_MEM_BLOCK_H_
+
+class mem_block
+{
+private:
+ void * data;
+ int size;
+public:
+ mem_block() {data=0;size=0;}
+ ~mem_block() {if (data) free(data);}
+
+ int get_size() const {return size;}
+
+ void * get_ptr() const {return data;}
+
+ void * set_size(int new_size)
+ {
+ if (data==0) data = malloc(size = new_size);
+ else if (size!=new_size)
+ {
+ void * new_data = realloc(data,new_size);
+ if (!new_data) return 0;
+ data = new_data;
+ size = new_size;
+ }
+ return data;
+ }
+
+ void * check_size(int new_size)
+ {
+ if (size<new_size) return set_size(new_size);
+ else return data;
+ }
+
+ operator void * () const {return data;}
+
+};
+
+template<class T>
+class mem_block_t : private mem_block
+{
+public:
+ int get_size() const {return mem_block::get_size()/sizeof(T);}
+
+ T* get_ptr() const {return static_cast<T*>(mem_block::get_ptr());}
+
+ T* set_size(int new_size) {return static_cast<T*>(mem_block::set_size(new_size*sizeof(T)));}
+
+ T* check_size(int new_size) {return static_cast<T*>(mem_block::check_size(new_size*sizeof(T)));}
+
+ operator T * () const {return get_ptr();}
+};
+
+#endif \ No newline at end of file
diff --git a/Src/pfc/pfc.dsp b/Src/pfc/pfc.dsp
new file mode 100644
index 000000000..15598b967
--- /dev/null
+++ b/Src/pfc/pfc.dsp
@@ -0,0 +1,116 @@
+# Microsoft Developer Studio Project File - Name="pfc" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=pfc - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "pfc.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "pfc.mak" CFG="pfc - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "pfc - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "pfc - Win32 Debug Winamp" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "pfc - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "pfc - Win32 Debug Winamp"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "pfc___Win32_Debug_Winamp"
+# PROP BASE Intermediate_Dir "pfc___Win32_Debug_Winamp"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "pfc___Win32_Debug_Winamp"
+# PROP Intermediate_Dir "pfc___Win32_Debug_Winamp"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "pfc - Win32 Release"
+# Name "pfc - Win32 Debug Winamp"
+# Begin Source File
+
+SOURCE=.\cfg_var.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\cfg_var.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\critsec.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\grow_buf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\grow_buf.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\pfc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\string.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\string.h
+# End Source File
+# End Target
+# End Project
diff --git a/Src/pfc/pfc.dsw b/Src/pfc/pfc.dsw
new file mode 100644
index 000000000..e43019fd7
--- /dev/null
+++ b/Src/pfc/pfc.dsw
@@ -0,0 +1,41 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "pfc"=".\pfc.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "pfc_unicode"=".\pfc_unicode.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/Src/pfc/pfc.h b/Src/pfc/pfc.h
new file mode 100644
index 000000000..c6472d57b
--- /dev/null
+++ b/Src/pfc/pfc.h
@@ -0,0 +1,20 @@
+#ifndef STRICT
+#define STRICT
+#endif
+#include <windows.h>
+
+#ifndef NOVTABLE
+#define NOVTABLE _declspec(novtable)
+#endif
+
+#define tabsize(x) (sizeof(x)/sizeof(*x))
+
+#include "string.h"
+#ifdef PFC_UNICODE
+#include "string_unicode.h"
+#endif
+#include "cfg_var.h"
+#include "critsec.h"
+#include "grow_buf.h"
+#include "mem_block.h"
+#include "ptr_list.h" \ No newline at end of file
diff --git a/Src/pfc/pfc_unicode.dsp b/Src/pfc/pfc_unicode.dsp
new file mode 100644
index 000000000..092f898e9
--- /dev/null
+++ b/Src/pfc/pfc_unicode.dsp
@@ -0,0 +1,132 @@
+# Microsoft Developer Studio Project File - Name="pfc_unicode" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=pfc_unicode - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "pfc_unicode.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "pfc_unicode.mak" CFG="pfc_unicode - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "pfc_unicode - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "pfc_unicode - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "pfc_unicode - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_unicode"
+# PROP Intermediate_Dir "Release_unicode"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "PFC_UNICODE" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "pfc_unicode - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_unicode"
+# PROP Intermediate_Dir "Debug_unicode"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "PFC_UNICODE" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "pfc_unicode - Win32 Release"
+# Name "pfc_unicode - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\cfg_var.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\cfg_var.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\critsec.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\grow_buf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\grow_buf.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mem_block.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\pfc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ptr_list.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\string.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\string.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\string_unicode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\string_unicode.h
+# End Source File
+# End Target
+# End Project
diff --git a/Src/pfc/ptr_list.h b/Src/pfc/ptr_list.h
new file mode 100644
index 000000000..063395bba
--- /dev/null
+++ b/Src/pfc/ptr_list.h
@@ -0,0 +1,127 @@
+#include "mem_block.h"
+
+class ptr_list
+{
+private:
+ mem_block_t<void *> data;
+ int count;
+
+protected:
+ void * get_raw_ptr() {return data.get_ptr();}
+
+public:
+ ptr_list() {count=0;}
+ int get_count() const {return count;}
+ void * get_item(int n) const
+ {
+ if (n>=0 && n<count) return data[n];
+ else return 0;
+ }
+ int add_item(void * ptr)//returns index
+ {
+ count++;
+ data.check_size(count);
+ data[count-1] = ptr;
+ return count-1;
+ }
+ int find_item(void * ptr)//returns index, -1 if not found
+ {
+ int n;
+ for(n=0;n<count;n++)
+ {
+ if (data[n] == ptr) return n;
+ }
+ return -1;
+ }
+
+ bool have_item(void * ptr) {return find_item(ptr)>=0;}
+
+ void remove_item(void * ptr)
+ {
+ int idx = find_item(ptr);
+ if (idx>=0) remove_by_idx(idx);
+ }
+ void * remove_by_idx(int idx)
+ {
+ void * ptr = 0;
+ if (idx>=0 && idx<count)
+ {
+ ptr = data[idx];
+ int n;
+ count--;
+ for(n=idx;n<count;n++)
+ {
+ data[n] = data[n+1];
+ }
+ }
+ return ptr;
+ }
+
+ void remove_all()
+ {
+ count=0;
+ }
+
+ int insert_item(void * ptr,int idx) //returns index
+ {
+ if (idx>count || idx<0) idx = count;
+
+ count++;
+ data.check_size(count);
+ int n;
+ for(n=count-1;n>idx;n--)
+ {
+ data[n]=data[n-1];
+ }
+ data[idx] = ptr;
+
+ return idx;
+ }
+
+ void * operator[](int idx) const {return get_item(idx);}
+};
+
+template<class T>
+class ptr_list_t : protected ptr_list
+{
+public:
+ int get_count() const {return ptr_list::get_count();}
+
+ T * get_item(int n) const {return static_cast<T*>(ptr_list::get_item(n));}
+ int add_item(T * ptr) {return ptr_list::add_item(static_cast<void*>(ptr));}
+ int find_item(T * ptr) {return ptr_list::find_item(static_cast<void*>(ptr));}
+ bool have_item(T * ptr) {return ptr_list::have_item(static_cast<void*>(ptr));}
+ void remove_item(T * ptr) {ptr_list::remove_item(static_cast<void*>(ptr));}
+ T * remove_by_idx(int idx) {return static_cast<T*>(ptr_list::remove_by_idx(idx));}
+ void remove_all() {ptr_list::remove_all();}
+ void * operator[](int idx) const {return get_item(idx);}
+ int insert_item(int idx,T* ptr) {return ptr_list::insert_item(idx,static_cast<void*>(ptr));}
+
+ void delete_item(T * ptr)
+ {
+ remove_item(ptr);
+ delete ptr;
+ }
+
+ void delete_by_idx(int idx)
+ {
+ T * ptr = remove_by_idx(idx);
+ if (ptr) delete ptr;
+ }
+
+ void delete_all()
+ {
+ int n,max=get_count();
+ for(n=0;n<max;n++)
+ {
+ T * ptr = get_item(n);
+ if (ptr) delete ptr;
+ }
+ remove_all();
+ }
+
+ void sort(int (__cdecl *compare )(const T ** elem1, const T** elem2 ) )
+ {
+ qsort(get_raw_ptr(),get_count(),sizeof(void*),(int (__cdecl *)(const void *, const void *) )compare);
+ }
+};
diff --git a/Src/pfc/string.cpp b/Src/pfc/string.cpp
new file mode 100644
index 000000000..bdf796073
--- /dev/null
+++ b/Src/pfc/string.cpp
@@ -0,0 +1,34 @@
+#define STRICT
+#include <windows.h>
+#include <stdio.h>
+#include "string_unicode.h"
+
+void string_a::s_GetWindowText(HWND w)
+{
+ reset();
+ int len=GetWindowTextLengthA(w)+1;
+ GetWindowTextA(w,string_buffer_a(*this,len),len);
+
+}
+
+void string_a::s_SetWindowText(HWND w)
+{
+ SetWindowTextA(w,*this);
+}
+
+
+/*bool string_a::reg_read(HKEY hk,const char * name)
+{
+ DWORD sz=0,t=0;
+ if (RegQueryValueExA(hk,name,0,&t,0,&sz)!=ERROR_SUCCESS) return 0;
+ if (sz==0 || t!=REG_SZ) return 0;
+ RegQueryValueExA(hk,name,0,0,(BYTE*)buffer_get(sz),&sz);
+ buffer_done();
+ return 1;
+}
+
+void string_a::reg_write(HKEY hk,const char * name)
+{
+ RegSetValueExA(hk,name,0,REG_SZ,(const BYTE*)(const char*)*this,(length()+1));
+}
+*/ \ No newline at end of file
diff --git a/Src/pfc/string.h b/Src/pfc/string.h
new file mode 100644
index 000000000..34317e046
--- /dev/null
+++ b/Src/pfc/string.h
@@ -0,0 +1,205 @@
+#ifndef _PFC_STRING_H_
+#define _PFC_STRING_H_
+
+template <class myChar> class string_base
+{
+private:
+ myChar * ptr;
+ size_t size,used;
+ void makespace(size_t s)
+ {
+ if (size<s)
+ {
+ do size<<=1; while(size<s);
+ ptr=(myChar*)realloc(ptr,size*sizeof(myChar));
+ }
+ }
+
+ static int mylen(const myChar * p) {int r=0;while(p[r]) r++;return r;}
+public:
+ const myChar * get_ptr() const {return ptr;}
+ void add_char(myChar c)
+ {
+ makespace(used+2);
+ ptr[used++]=c;
+ ptr[used]=0;
+ }
+ string_base()
+ {
+ used=0;
+ size=8;
+ ptr=(myChar*)malloc(size*sizeof(myChar));
+ ptr[0]=0;
+ }
+
+ ~string_base() { if (ptr) free(ptr);}
+
+ operator const myChar*() const {return get_ptr();}
+
+ const myChar & operator*() const {return *get_ptr();}
+
+ size_t length() const {return used;}
+ int is_empty() const {return used==0;}
+
+ void add_string(const myChar * c)
+ {
+ int d=mylen(c);
+ makespace(used+d+1);
+ memcpy(ptr+used,c,sizeof(myChar)*d);
+ used+=d;
+ ptr[used]=0;
+ }
+
+ void add_string_n(const myChar * c,int count)
+ {
+ makespace(used+count+1);
+ memcpy(ptr+used,c,sizeof(myChar)*count);
+ ptr[used+count]=0;
+ used+=mylen(ptr+used);
+ }
+
+ void reset() {truncate(0);}
+ void truncate(size_t x) {if (used>x) {used=x;ptr[x]=0;}}
+
+ void set_string(const myChar * s) {reset();add_string(s);}
+
+ myChar *buffer_get(size_t n)
+ {
+ makespace(n+1);
+ memset(ptr,0,size);
+ return ptr;
+ }
+
+ inline void buffer_done() {used=mylen(ptr);}
+
+ void set_char(int offset,myChar c)//hack for some ghey routines
+ {
+ if (!c) truncate(offset);
+ else if (offset<used) ptr[offset]=c;
+ }
+
+ int find_first(myChar c) //return -1 if not found
+ {
+ int n;
+ for(n=0;n<used;n++)
+ {
+ if (ptr[n]==c) return n;
+ }
+ return -1;
+ }
+ int find_last(myChar c)
+ {
+ int n;;
+ for(n=used-1;n>=0;n--)
+ {
+ if (ptr[n]==c) return n;
+ }
+ return -1;
+ }
+
+ int replace_char(myChar c1,myChar c2)
+ {
+ int rv=0;
+ int n;
+ for(n=0;n<used;n++)
+ {
+ if (ptr[n]==c1) {ptr[n]=c2;rv++;}
+ }
+ return rv;
+ }
+
+};
+
+template<class myChar>
+class string_buffer
+{
+private:
+ string_base<myChar> * parent;
+ myChar * data;
+public:
+ string_buffer(string_base<myChar> & s,UINT siz) {parent=&s;data=s.buffer_get(siz);}
+ ~string_buffer() {parent->buffer_done();}
+ operator myChar* () {return data;}
+};
+
+#define string_buffer_w string_buffer<WCHAR>
+#define string_buffer_a string_buffer<char>
+
+class string_w;
+#define string string_a
+
+class string_a : public string_base<char>
+{
+public:
+ string_a() {}
+ string_a(HWND w) {s_GetWindowText(w);}
+ string_a(const char* z) {set_string(z);}
+ string_a(const WCHAR* z) {set_string_w(z);}
+ string_a(const string_a& z) {set_string(z);}
+ string_a(const string_w& z);
+ void add_string_w(const WCHAR * c);
+ void set_string_w(const WCHAR * c);
+ void s_GetWindowText(HWND w);
+ inline void from_window(HWND w) {s_GetWindowText(w);}
+ void s_SetWindowText(HWND w);
+ const char * operator=(const char * s) {set_string(s);return get_ptr();}
+ const char * operator+=(const char * s) {add_string(s);return get_ptr();}
+ const char * operator=(const WCHAR * s) {set_string_w(s);return get_ptr();}
+ const char * operator+=(const WCHAR * s) {add_string_w(s);return get_ptr();}
+ const char * operator=(string_a & s) {set_string(s);return get_ptr();}
+ const char * operator+=(string_a & s) {add_string(s);return get_ptr();}
+ inline void s_GetDlgItemText(HWND w,int id) {s_GetWindowText(GetDlgItem(w,id));}
+ inline void s_SetDlgItemText(HWND w,int id) {s_SetWindowText(GetDlgItem(w,id));}
+ bool reg_read(HKEY hk,const char * name);
+ void reg_write(HKEY hk,const char * name);
+};
+
+class string_printf_a : public string_a
+{
+public:
+ string_printf_a(const char * fmt,...);
+};
+
+#define string_printf string_printf_a
+
+template<class myChar>
+class string_file_title : public string_base<myChar>
+{
+public:
+ string_file_title(const myChar * fn)
+ {
+ const myChar * ptr=fn,*dot=0,*src=fn;
+ while(*ptr)
+ {
+ if (*ptr=='\\' || *ptr=='/' || *ptr==':') src=ptr+1;
+ else if (*ptr=='.') dot=ptr;
+ ptr++;
+ }
+
+ while(*src && (!dot || src<dot)) add_char(*(src++));
+ }
+};
+
+#define string_f2t_a string_file_title<char>
+#define string_f2t_w string_file_title<WCHAR>
+
+template<class myChar>
+class string_extension : public string_base<myChar>
+{
+public:
+ string_extension(const myChar * foo)
+ {
+ const myChar * ptr = 0;
+ while(*foo)
+ {
+ if (*foo == '.') ptr = foo;
+ foo++;
+ }
+ if (ptr) set_string(ptr+1);
+ }
+};
+
+#define string_extension_a string_extension<char>
+#define string_extension_w string_extension<WCHAR>
+
+#endif //_PFC_STRING_H_ \ No newline at end of file
diff --git a/Src/pfc/string_unicode.cpp b/Src/pfc/string_unicode.cpp
new file mode 100644
index 000000000..8952b888f
--- /dev/null
+++ b/Src/pfc/string_unicode.cpp
@@ -0,0 +1,250 @@
+#define STRICT
+#include <windows.h>
+#include <stdio.h>
+#include "string_unicode.h"
+
+static bool is_nt()
+{
+ OSVERSIONINFO os;
+ memset(&os,0,sizeof(os));
+ os.dwOSVersionInfoSize=sizeof(os);
+ GetVersionEx(&os);
+ return os.dwPlatformId == VER_PLATFORM_WIN32_NT;
+}
+
+void string_w::s_GetWindowText(HWND w)
+{
+ if (!is_nt())
+ {
+ set_string_a(string_a(w));
+ }
+ else
+ {
+ reset();
+ int len=GetWindowTextLengthW(w)+1;
+ GetWindowTextW(w,string_buffer_w(*this,len),len);
+ }
+}
+
+void string_w::set_string_a(const char * c)
+{
+ int len= (int)strlen(c)+1;
+ MultiByteToWideChar(CP_ACP,0,c,-1,string_buffer_w(*this,len),len);
+}
+
+void string_w::add_string_a(const char * c)
+{
+ add_string(string_w(c));
+}
+
+void string_w::s_SetWindowText(HWND w)
+{
+ if (!is_nt())
+ {
+ string_a(*this).s_SetWindowText(w);
+ }
+ else
+ {
+ SetWindowTextW(w,*this);
+ }
+}
+
+void string_a::set_string_w(const WCHAR * c)
+{
+ int len=((int)wcslen(c)+1)*2;
+ WideCharToMultiByte(CP_ACP,0,c,-1,string_buffer_a(*this,len),len,0,0);
+}
+
+void string_a::add_string_w(const WCHAR * c)
+{
+ add_string(string_a(c));
+}
+
+//utf8 stuff
+
+static const BYTE mask_tab[6]={0x80,0xE0,0xF0,0xF8,0xFC,0xFE};
+
+static const BYTE val_tab[6]={0,0xC0,0xE0,0xF0,0xF8,0xFC};
+
+static int utf82wide(int *wide,const BYTE *utf8)
+{
+ int res=0;
+ int n;
+ int cnt=0;
+ while(1)
+ {
+ if ((*utf8&mask_tab[cnt])==val_tab[cnt]) break;
+ if (++cnt==6) return 0;
+ }
+ cnt++;
+
+
+ if (cnt==2 && !(*utf8&0x1E)) return 0;
+
+ if (cnt==1)
+ res=*utf8;
+ else
+ res=(0xFF>>(cnt+1))&*utf8;
+
+ for (n=1;n<cnt;n++)
+ {
+ if ((utf8[n]&0xC0) != 0x80)
+ return 0;
+ if (!res && n==2 && !((utf8[n]&0x7F) >> (7 - cnt)))
+ return 0;
+
+ res=(res<<6)|(utf8[n]&0x3F);
+ }
+
+ if (wide)
+ *wide=res;
+
+ return cnt;
+}
+
+
+static int wide2utf8(char *target, int wide,int max)
+{
+ int count;
+
+ if (wide < 0x80)
+ count = 1;
+ else if (wide < 0x800)
+ count = 2;
+ else if (wide < 0x10000)
+ count = 3;
+ else if (wide < 0x200000)
+ count = 4;
+ else if (wide < 0x4000000)
+ count = 5;
+ else if (wide <= 0x7FFFFFFF)
+ count = 6;
+ else
+ return 0;
+ if (count>max) return 0;
+
+ if (target == 0)
+ return count;
+
+ switch (count)
+ {
+ case 6:
+ target[5] = 0x80 | (wide & 0x3F);
+ wide = wide >> 6;
+ wide |= 0x4000000;
+ case 5:
+ target[4] = 0x80 | (wide & 0x3F);
+ wide = wide >> 6;
+ wide |= 0x200000;
+ case 4:
+ target[3] = 0x80 | (wide & 0x3F);
+ wide = wide >> 6;
+ wide |= 0x10000;
+ case 3:
+ target[2] = 0x80 | (wide & 0x3F);
+ wide = wide >> 6;
+ wide |= 0x800;
+ case 2:
+ target[1] = 0x80 | (wide & 0x3F);
+ wide = wide >> 6;
+ wide |= 0xC0;
+ case 1:
+ target[0] = wide;
+ }
+
+ return count;
+}
+
+void string_w::add_string_utf8(const char * z)
+{
+ string_w temp;
+ temp.set_string_utf8(z);
+ add_string(temp);
+}
+
+void string_w::set_string_utf8(const char * src)
+//static int UTF8ToWide(const char* src,WCHAR* dst,int len,int out_len)
+{
+ int cur_wchar;
+ for(;;)
+ {
+ cur_wchar=0;
+ int t=utf82wide(&cur_wchar,(const BYTE*)src);
+ if (!t || !cur_wchar || cur_wchar>0xFFFF) break;
+ src+=t;
+ add_char((WCHAR)cur_wchar);
+ }
+}
+
+
+string_printf_a::string_printf_a(const char * fmt,...)
+{
+ va_list list;
+ va_start(list,fmt);
+ vsprintf(string_buffer_a(*this,1024),fmt,list);
+ va_end(list);
+}
+
+string_printf_w::string_printf_w(const WCHAR * fmt,...)
+{
+ va_list list;
+ va_start(list,fmt);
+ vswprintf(string_buffer_w(*this,1024),1024,fmt,list);
+ va_end(list);
+}
+
+
+string_a::string_a(const string_w & z) {add_string_w(z);}
+
+
+
+void string_utf8::convert(const WCHAR * src)
+{
+ char temp[8] = {0};
+ while(src && *src)
+ {
+ int len=wide2utf8(temp,*src,7);
+ if (!len) break;
+ temp[len]=0;
+ add_string(temp);
+ src++;
+ }
+}
+
+
+bool string_w::reg_read(HKEY hk,const WCHAR * name)
+{
+ if (!is_nt())
+ {
+ string_a temp(*this);
+ if (temp.reg_read(hk,string_a(name)))
+ {
+ set_string_a(temp);
+ return 1;
+ }
+ else return 0;
+ }
+ else
+ {
+ DWORD sz=0,t=0;
+ if (RegQueryValueExW(hk,name,0,&t,0,&sz)!=ERROR_SUCCESS) return 0;
+ if (sz==0 || t!=REG_SZ) return 0;
+ RegQueryValueExW(hk,name,0,0,(BYTE*)buffer_get(sz>>1),&sz);
+ buffer_done();
+ return 1;
+ }
+}
+
+void string_w::reg_write(HKEY hk,const WCHAR * name)
+{
+ if (!is_nt())
+ {
+ string_a(*this).reg_write(hk,string_a(name));
+ }
+ else
+ {
+ RegSetValueExW(hk,name,0,REG_SZ,(const BYTE*)(const WCHAR*)*this,((DWORD)length()+1)*2);
+ }
+}
+
+bool string_w::test_os() {return is_nt();} \ No newline at end of file
diff --git a/Src/pfc/string_unicode.h b/Src/pfc/string_unicode.h
new file mode 100644
index 000000000..7c690e0f2
--- /dev/null
+++ b/Src/pfc/string_unicode.h
@@ -0,0 +1,60 @@
+#ifndef _PFC_STRING_UNICODE_H_
+#define _PFC_STRING_UNICODE_H_
+
+#include "string.h"
+
+class string_w : public string_base<WCHAR>
+{
+public:
+ string_w() {}
+ string_w(HWND w) {s_GetWindowText(w);}
+ string_w(const WCHAR * z) {set_string(z);}
+ void add_string_a(const char * c);
+ void set_string_a(const char * c);
+ string_w(const char * z) {set_string_a(z);}
+ string_w(const string_w & z) {set_string(z);}
+ string_w(const string_a & z) {set_string_a(z);}
+ void add_string_utf8(const char * z);
+ void set_string_utf8(const char * z);
+ void s_GetWindowText(HWND w);
+ inline void from_window(HWND w) {s_GetWindowText(w);}
+ void s_SetWindowText(HWND w);
+ const WCHAR * operator=(const WCHAR * s) {set_string(s);return get_ptr();}
+ const WCHAR * operator+=(const WCHAR * s) {add_string(s);return get_ptr();}
+ const WCHAR * operator=(const char * s) {set_string_a(s);return get_ptr();}
+ const WCHAR * operator+=(const char * s) {add_string_a(s);return get_ptr();}
+ const WCHAR * operator=(string_w & s) {set_string(s);return get_ptr();}
+ const WCHAR * operator+=(string_w & s) {add_string(s);return get_ptr();}
+ inline void s_GetDlgItemText(HWND w,int id) {s_GetWindowText(GetDlgItem(w,id));}
+ inline void s_SetDlgItemText(HWND w,int id) {s_SetWindowText(GetDlgItem(w,id));}
+ bool reg_read(HKEY hk,const WCHAR * name);
+ void reg_write(HKEY hk,const WCHAR * name);
+
+ static bool test_os();
+};
+
+class string_reg : public string_w
+{
+public:
+ string_reg(HKEY hk,const WCHAR * name) {reg_read(hk,name);}
+ string_reg(HKEY hk,const char * name) {reg_read(hk,string_w(name));}
+};
+
+
+class string_printf_w : public string_w
+{
+public:
+ string_printf_w(const WCHAR * fmt,...);
+};
+
+
+class string_utf8 : public string_a
+{
+private:
+ void convert(const WCHAR * foo);
+public:
+ string_utf8(const WCHAR * foo) {convert(foo);}
+ string_utf8(const char * foo) {convert(string_w(foo));}
+};
+
+#endif //_PFC_STRING_UNICODE_H_ \ No newline at end of file