Commit 1e55712f authored by Olivier Bertrand's avatar Olivier Bertrand

- On Linux, closing an INI table removes it from the inihandl cache

modified:
  storage/connect/inihandl.c
  storage/connect/osutil.h
  storage/connect/tabsys.cpp

- Clean. Remove some unused functions

modified:
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
parent 0df7a43e
...@@ -99,10 +99,10 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES] = {NULL}; ...@@ -99,10 +99,10 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES] = {NULL};
#define PROFILE_MAX_LINE_LEN 1024 #define PROFILE_MAX_LINE_LEN 1024
/* Wine profile name in $HOME directory; must begin with slash */ /* Wine profile name in $HOME directory; must begin with slash */
static const char PROFILE_WineIniName[] = "/.winerc"; //static const char PROFILE_WineIniName[] = "/.winerc";
/* Wine profile: the profile file being used */ /* Wine profile: the profile file being used */
static char PROFILE_WineIniUsed[MAX_PATHNAME_LEN] = ""; //static char PROFILE_WineIniUsed[MAX_PATHNAME_LEN] = "";
/* Check for comments in profile */ /* Check for comments in profile */
#define IS_ENTRY_COMMENT(str) ((str)[0] == ';') #define IS_ENTRY_COMMENT(str) ((str)[0] == ';')
...@@ -560,6 +560,55 @@ static BOOL PROFILE_Open(LPCSTR filename) ...@@ -560,6 +560,55 @@ static BOOL PROFILE_Open(LPCSTR filename)
} }
/***********************************************************************
* PROFILE_Close
*
* Flush the named profile to disk and remove it from the cache.
***********************************************************************/
static void PROFILE_Close(LPCSTR filename)
{
int i;
BOOL close = FALSE;
struct stat buf;
PROFILE *tempProfile;
if (trace > 1)
htrc("PROFILE_Close: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES);
/* Check for a match */
for (i = 0; i < N_CACHED_PROFILES; i++) {
if (trace > 1)
htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i);
if (MRUProfile[i]->filename && !strcmp(filename, MRUProfile[i]->filename)) {
if (i) {
/* Make the profile to close current */
tempProfile = MRUProfile[i];
MRUProfile[i] = MRUProfile[0];
MRUProfile[0] = tempProfile;
CurProfile=tempProfile;
} // endif i
if (trace > 1) {
if (!stat(CurProfile->filename, &buf) && CurProfile->mtime == buf.st_mtime)
htrc("(%s): already opened (mru=%d)\n", filename, i);
else
htrc("(%s): already opened, needs refreshing (mru=%d)\n", filename, i);
} // endif trace
close = TRUE;
break;
} // endif filename
} // endfor i
if (close)
PROFILE_ReleaseFile();
} // end of PROFILE_Close
/*********************************************************************** /***********************************************************************
* PROFILE_DeleteSection * PROFILE_DeleteSection
* *
......
...@@ -32,6 +32,8 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength); ...@@ -32,6 +32,8 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength);
BOOL MessageBeep(uint); BOOL MessageBeep(uint);
unsigned long _filelength(int fd); unsigned long _filelength(int fd);
void PROFILE_Close(LPCSTR filename);
int GetPrivateProfileString( int GetPrivateProfileString(
LPCTSTR lpAppName, // section name LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name LPCTSTR lpKeyName, // key name
......
...@@ -559,9 +559,9 @@ DllExport PDBUSER PlgGetUser(PGLOBAL g); ...@@ -559,9 +559,9 @@ DllExport PDBUSER PlgGetUser(PGLOBAL g);
DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true); DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true);
DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int); DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int);
DllExport void PlgDBfree(MBLOCK&); DllExport void PlgDBfree(MBLOCK&);
DllExport PSZ GetIniString(PGLOBAL, void *, LPCSTR, LPCSTR, LPCSTR, LPCSTR); //lExport PSZ GetIniString(PGLOBAL, void *, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
DllExport int GetIniSize(char *, char *, char *, char *); //lExport int GetIniSize(char *, char *, char *, char *);
DllExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR); //lExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
DllExport void NewPointer(PTABS, void *, void *); DllExport void NewPointer(PTABS, void *, void *);
......
...@@ -411,12 +411,13 @@ char *PlgGetDataPath(PGLOBAL g) ...@@ -411,12 +411,13 @@ char *PlgGetDataPath(PGLOBAL g)
{ {
PCATLG cat = PlgGetCatalog(g, false); PCATLG cat = PlgGetCatalog(g, false);
if (!cat) //if (!cat)
return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini); // return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini);
return cat->GetDataPath(); return (cat) ? cat->GetDataPath() : NULL;
} // end of PlgGetDataPath } // end of PlgGetDataPath
#if 0
/***********************************************************************/ /***********************************************************************/
/* PlgGetXdbPath: sets the fully qualified file name of a database */ /* PlgGetXdbPath: sets the fully qualified file name of a database */
/* description file in lgn and the new datapath in dp. */ /* description file in lgn and the new datapath in dp. */
...@@ -513,6 +514,7 @@ bool PlgSetXdbPath(PGLOBAL g, PSZ dbname, PSZ dbpath, ...@@ -513,6 +514,7 @@ bool PlgSetXdbPath(PGLOBAL g, PSZ dbname, PSZ dbpath,
return false; return false;
} // end of PlgSetXdbPath } // end of PlgSetXdbPath
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Extract from a path name the required component. */ /* Extract from a path name the required component. */
...@@ -1040,6 +1042,7 @@ void PlugCleanup(PGLOBAL g, bool dofree) ...@@ -1040,6 +1042,7 @@ void PlugCleanup(PGLOBAL g, bool dofree)
} // end of PlugCleanup } // end of PlugCleanup
#if 0
/***********************************************************************/ /***********************************************************************/
/* That stupid Windows 98 does not provide this function. */ /* That stupid Windows 98 does not provide this function. */
/***********************************************************************/ /***********************************************************************/
...@@ -1116,6 +1119,7 @@ DllExport PSZ GetIniString(PGLOBAL g, void *mp, LPCSTR sec, LPCSTR key, ...@@ -1116,6 +1119,7 @@ DllExport PSZ GetIniString(PGLOBAL g, void *mp, LPCSTR sec, LPCSTR key,
return p; return p;
} // end of GetIniString } // end of GetIniString
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* GetAmName: return the name correponding to an AM code. */ /* GetAmName: return the name correponding to an AM code. */
......
...@@ -388,7 +388,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc) ...@@ -388,7 +388,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
void TDBINI::CloseDB(PGLOBAL g) void TDBINI::CloseDB(PGLOBAL g)
{ {
// Nothing to do #if !defined(WIN32)
PROFILE_Close(Ifile);
#endif // !WIN32
} // end of CloseDB } // end of CloseDB
// ------------------------ INICOL functions ---------------------------- // ------------------------ INICOL functions ----------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment