#if defined(__WXMSW__) && !defined(_WINDOWS_)
#include <windows.h>
#endif //windows.h
+#if defined(__WXPM__)
+ #define INCL_DOS
+ #include <os2.h>
+ #define LINKAGEMODE _Optlink
+#else
+ #define LINKAGEMODE
+#endif
#include <stdlib.h>
#include <ctype.h>
// ----------------------------------------------------------------------------
// compare functions for sorting the arrays
-static int CompareEntries(ConfigEntry *p1, ConfigEntry *p2);
-static int CompareGroups(ConfigGroup *p1, ConfigGroup *p2);
+static int LINKAGEMODE CompareEntries(ConfigEntry *p1, ConfigEntry *p2);
+static int LINKAGEMODE CompareGroups(ConfigGroup *p1, ConfigGroup *p2);
// filter strings
static wxString FilterInValue(const wxString& str);
wxString strDir;
#ifdef __UNIX__
- strDir = _T("/etc/");
+ strDir = wxT("/etc/");
+ #elif defined(__WXPM__)
+ ULONG aulSysInfo[QSV_MAX] = {0};
+ UINT drive;
+ APIRET rc;
+
+ rc = DosQuerySysInfo( 1L, QSV_MAX, (PVOID)aulSysInfo, sizeof(ULONG)*QSV_MAX);
+ if (rc == 0)
+ {
+ drive = aulSysInfo[QSV_BOOT_DRIVE - 1];
+ switch(drive)
+ {
+ case 1:
+ strDir = "A:\\OS2\\";
+ break;
+ case 2:
+ strDir = "B:\\OS2\\";
+ break;
+ case 3:
+ strDir = "C:\\OS2\\";
+ break;
+ case 4:
+ strDir = "D:\\OS2\\";
+ break;
+ case 5:
+ strDir = "E:\\OS2\\";
+ break;
+ case 6:
+ strDir = "F:\\OS2\\";
+ break;
+ case 7:
+ strDir = "G:\\OS2\\";
+ break;
+ case 8:
+ strDir = "H:\\OS2\\";
+ break;
+ case 9:
+ strDir = "I:\\OS2\\";
+ break;
+ case 10:
+ strDir = "J:\\OS2\\";
+ break;
+ case 11:
+ strDir = "K:\\OS2\\";
+ break;
+ case 12:
+ strDir = "L:\\OS2\\";
+ break;
+ case 13:
+ strDir = "M:\\OS2\\";
+ break;
+ case 14:
+ strDir = "N:\\OS2\\";
+ break;
+ case 15:
+ strDir = "O:\\OS2\\";
+ break;
+ case 16:
+ strDir = "P:\\OS2\\";
+ break;
+ case 17:
+ strDir = "Q:\\OS2\\";
+ break;
+ case 18:
+ strDir = "R:\\OS2\\";
+ break;
+ case 19:
+ strDir = "S:\\OS2\\";
+ break;
+ case 20:
+ strDir = "T:\\OS2\\";
+ break;
+ case 21:
+ strDir = "U:\\OS2\\";
+ break;
+ case 22:
+ strDir = "V:\\OS2\\";
+ break;
+ case 23:
+ strDir = "W:\\OS2\\";
+ break;
+ case 24:
+ strDir = "X:\\OS2\\";
+ break;
+ case 25:
+ strDir = "Y:\\OS2\\";
+ break;
+ case 26:
+ strDir = "Z:\\OS2\\";
+ break;
+ }
+ }
#elif defined(__WXSTUBS__)
- wxASSERT_MSG( FALSE, _T("TODO") ) ;
+ wxASSERT_MSG( FALSE, wxT("TODO") ) ;
#elif defined(__WXMAC__)
- wxASSERT_MSG( FALSE, _T("TODO") ) ;
+ wxASSERT_MSG( FALSE, wxT("TODO") ) ;
#else // Windows
wxChar szWinDir[MAX_PATH];
::GetWindowsDirectory(szWinDir, MAX_PATH);
strDir = szWinDir;
- strDir << _T('\\');
+ strDir << wxT('\\');
#endif // Unix/Windows
return strDir;
wxGetHomeDir(&strDir);
#ifdef __UNIX__
- if (strDir.Last() != _T('/')) strDir << _T('/');
+ if (strDir.Last() != wxT('/')) strDir << wxT('/');
#else
- if (strDir.Last() != _T('\\')) strDir << _T('\\');
+ if (strDir.Last() != wxT('\\')) strDir << wxT('\\');
#endif
return strDir;
wxString str = GetGlobalDir();
str << szFile;
- if ( wxStrchr(szFile, _T('.')) == NULL )
+ if ( wxStrchr(szFile, wxT('.')) == NULL )
#ifdef __UNIX__
- str << _T(".conf");
+ str << wxT(".conf");
#else // Windows
- str << _T(".ini");
+ str << wxT(".ini");
#endif // UNIX/Win
return str;
wxString str = GetLocalDir();
#ifdef __UNIX__
- str << _T('.');
+ str << wxT('.');
#endif
str << szFile;
#ifdef __WXMSW__
- if ( wxStrchr(szFile, _T('.')) == NULL )
- str << _T(".ini");
+ if ( wxStrchr(szFile, wxT('.')) == NULL )
+ str << wxT(".ini");
#endif
return str;
;
// skip blank/comment lines
- if ( *pStart == _T('\0')|| *pStart == _T(';') || *pStart == _T('#') )
+ if ( *pStart == wxT('\0')|| *pStart == wxT(';') || *pStart == wxT('#') )
continue;
- if ( *pStart == _T('[') ) { // a new group
+ if ( *pStart == wxT('[') ) { // a new group
pEnd = pStart;
- while ( *++pEnd != _T(']') ) {
- if ( *pEnd == _T('\n') || *pEnd == _T('\0') )
+ while ( *++pEnd != wxT(']') ) {
+ if ( *pEnd == wxT('\n') || *pEnd == wxT('\0') )
break;
}
- if ( *pEnd != _T(']') ) {
+ if ( *pEnd != wxT(']') ) {
wxLogError(_("file '%s': unexpected character %c at line %d."),
file.GetName(), *pEnd, n + 1);
continue; // skip this line
// check that there is nothing except comments left on this line
bool bCont = TRUE;
- while ( *++pEnd != _T('\0') && bCont ) {
+ while ( *++pEnd != wxT('\0') && bCont ) {
switch ( *pEnd ) {
- case _T('#'):
- case _T(';'):
+ case wxT('#'):
+ case wxT(';'):
bCont = FALSE;
break;
- case _T(' '):
- case _T('\t'):
+ case wxT(' '):
+ case wxT('\t'):
// ignore whitespace ('\n' impossible here)
break;
}
else { // a key
const wxChar *pEnd = pStart;
- while ( *pEnd != _T('=') && !wxIsspace(*pEnd) ) {
- if ( *pEnd == _T('\\') ) {
+ while ( *pEnd != wxT('=') && !wxIsspace(*pEnd) ) {
+ if ( *pEnd == wxT('\\') ) {
// next character may be space or not - still take it because it's
// quoted
pEnd++;
while ( isspace(*pEnd) )
pEnd++;
- if ( *pEnd++ != _T('=') ) {
+ if ( *pEnd++ != wxT('=') ) {
wxLogError(_("file '%s', line %d: '=' expected."),
file.GetName(), n + 1);
}
wxString strName = path.Name();
if ( strName.IsEmpty() ) {
// setting the value of a group is an error
- wxASSERT_MSG( wxIsEmpty(szValue), _T("can't set value of a group!") );
+ wxASSERT_MSG( wxIsEmpty(szValue), wxT("can't set value of a group!") );
// ... except if it's empty in which case it's a way to force it's creation
m_pCurrentGroup->SetDirty();
{
// ltoa() is not ANSI :-(
wxString buf;
- buf.Printf(_T("%ld"), lValue);
+ buf.Printf(wxT("%ld"), lValue);
return Write(key, buf);
}
if ( bGroupIfEmptyAlso && m_pCurrentGroup->IsEmpty() ) {
if ( m_pCurrentGroup != m_pRootGroup ) {
ConfigGroup *pGroup = m_pCurrentGroup;
- SetPath(_T("..")); // changes m_pCurrentGroup!
+ SetPath(wxT("..")); // changes m_pCurrentGroup!
m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name());
}
//else: never delete the root group
if ( remove(m_strLocalFile.fn_str()) == -1 )
wxLogSysError(_("can't delete user configuration file '%s'"), m_strLocalFile.c_str());
- m_strLocalFile = m_strGlobalFile = _T("");
+ m_strLocalFile = m_strGlobalFile = wxT("");
Init();
return TRUE;
// this group wasn't present in local config file, add it now
if ( pParent != NULL ) {
wxString strFullName;
- strFullName << _T("[")
+ strFullName << wxT("[")
// +1: no '/'
<< FilterOutEntryName(GetFullName().c_str() + 1)
- << _T("]");
+ << wxT("]");
m_pLine = m_pConfig->LineListInsert(strFullName,
pParent->GetLastGroupLine());
pParent->SetLastGroup(this); // we're surely after all the others
LineList *line = GetGroupLine();
wxString strFullName;
- strFullName << _T("[") << (GetFullName().c_str() + 1) << _T("]"); // +1: no '/'
+ strFullName << wxT("[") << (GetFullName().c_str() + 1) << wxT("]"); // +1: no '/'
line->SetText(strFullName);
SetDirty();
if ( Parent() )
return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name();
else
- return _T("");
+ return wxT("");
}
// ----------------------------------------------------------------------------
if ( bUser ) {
wxString strVal = FilterOutValue(strValue);
wxString strLine;
- strLine << FilterOutEntryName(m_strName) << _T('=') << strVal;
+ strLine << FilterOutEntryName(m_strName) << wxT('=') << strVal;
if ( m_pLine != NULL ) {
// entry was read from the local config file, just modify the line
bool bQuoted = !str.IsEmpty() && str[0] == '"';
for ( size_t n = bQuoted ? 1 : 0; n < str.Len(); n++ ) {
- if ( str[n] == _T('\\') ) {
+ if ( str[n] == wxT('\\') ) {
switch ( str[++n] ) {
- case _T('n'):
- strResult += _T('\n');
+ case wxT('n'):
+ strResult += wxT('\n');
break;
- case _T('r'):
- strResult += _T('\r');
+ case wxT('r'):
+ strResult += wxT('\r');
break;
- case _T('t'):
- strResult += _T('\t');
+ case wxT('t'):
+ strResult += wxT('\t');
break;
- case _T('\\'):
- strResult += _T('\\');
+ case wxT('\\'):
+ strResult += wxT('\\');
break;
- case _T('"'):
- strResult += _T('"');
+ case wxT('"'):
+ strResult += wxT('"');
break;
}
}
else {
- if ( str[n] != _T('"') || !bQuoted )
+ if ( str[n] != wxT('"') || !bQuoted )
strResult += str[n];
else if ( n != str.Len() - 1 ) {
wxLogWarning(_("unexpected \" at position %d in '%s'."),
strResult.Alloc(str.Len());
// quoting is necessary to preserve spaces in the beginning of the string
- bool bQuote = wxIsspace(str[0]) || str[0] == _T('"');
+ bool bQuote = wxIsspace(str[0]) || str[0] == wxT('"');
if ( bQuote )
- strResult += _T('"');
+ strResult += wxT('"');
wxChar c;
for ( size_t n = 0; n < str.Len(); n++ ) {
switch ( str[n] ) {
- case _T('\n'):
- c = _T('n');
+ case wxT('\n'):
+ c = wxT('n');
break;
- case _T('\r'):
- c = _T('r');
+ case wxT('\r'):
+ c = wxT('r');
break;
- case _T('\t'):
- c = _T('t');
+ case wxT('\t'):
+ c = wxT('t');
break;
- case _T('\\'):
- c = _T('\\');
+ case wxT('\\'):
+ c = wxT('\\');
break;
- case _T('"'):
+ case wxT('"'):
if ( bQuote ) {
- c = _T('"');
+ c = wxT('"');
break;
}
//else: fall through
}
// we get here only for special characters
- strResult << _T('\\') << c;
+ strResult << wxT('\\') << c;
}
if ( bQuote )
- strResult += _T('"');
+ strResult += wxT('"');
return strResult;
}
strResult.Alloc(str.Len());
for ( const wxChar *pc = str.c_str(); *pc != '\0'; pc++ ) {
- if ( *pc == _T('\\') )
+ if ( *pc == wxT('\\') )
pc++;
strResult += *pc;
wxString strResult;
strResult.Alloc(str.Len());
- for ( const wxChar *pc = str.c_str(); *pc != _T('\0'); pc++ ) {
+ for ( const wxChar *pc = str.c_str(); *pc != wxT('\0'); pc++ ) {
wxChar c = *pc;
// we explicitly allow some of "safe" chars and 8bit ASCII characters
// which will probably never have special meaning
// NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR
// should *not* be quoted
- if ( !wxIsalnum(c) && !wxStrchr(_T("@_/-!.*%"), c) && ((c & 0x80) == 0) )
- strResult += _T('\\');
+ if ( !wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%"), c) && ((c & 0x80) == 0) )
+ strResult += wxT('\\');
strResult += c;
}