]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fileconf.cpp
CanRead() now restores the stream to its previous state (potential
[wxWidgets.git] / src / common / fileconf.cpp
index 5e9762390ca7b8a5c46f90fac874cc052792d4f3..0193dbdb2c97758d9c1b35dbbcaa053277bbb3e0 100644 (file)
 #pragma implementation "fileconf.h"
 #endif
 
-// ============================================================================
-// declarations
-// ============================================================================
-
 // ----------------------------------------------------------------------------
 // headers
 // ----------------------------------------------------------------------------
+
 #include  "wx/wxprec.h"
 
 #ifdef    __BORLANDC__
   #pragma hdrstop
 #endif  //__BORLANDC__
 
+#if wxUSE_CONFIG
+
 #ifndef   WX_PRECOMP
   #include  "wx/string.h"
   #include  "wx/intl.h"
 #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>
@@ -68,8 +74,8 @@
 // ----------------------------------------------------------------------------
 
 // 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);
@@ -94,6 +100,97 @@ wxString wxFileConfig::GetGlobalDir()
 
   #ifdef __UNIX__
     strDir = _T("/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") ) ;
   #elif defined(__WXMAC__)
@@ -341,7 +438,7 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
     }
     else {                        // a key
       const wxChar *pEnd = pStart;
-      while ( !wxIsspace(*pEnd) ) {
+      while ( *pEnd != _T('=') && !wxIsspace(*pEnd) ) {
         if ( *pEnd == _T('\\') ) {
           // next character may be space or not - still take it because it's
           // quoted
@@ -1277,7 +1374,7 @@ void ConfigEntry::SetValue(const wxString& strValue, bool bUser)
   if ( bUser ) {
     wxString strVal = FilterOutValue(strValue);
     wxString strLine;
-    strLine << FilterOutEntryName(m_strName) << _T(" = ") << strVal;
+    strLine << FilterOutEntryName(m_strName) << _T('=') << strVal;
 
     if ( m_pLine != NULL ) {
       // entry was read from the local config file, just modify the line
@@ -1483,3 +1580,6 @@ static wxString GetAppName(const wxString& appName)
     else
         return appName;
 }
+
+#endif // wxUSE_CONFIG
+