|
|
|
@ -56,7 +56,7 @@ CCallsignList::~CCallsignList()
|
|
|
|
bool CCallsignList::LoadFromFile(const char *filename)
|
|
|
|
bool CCallsignList::LoadFromFile(const char *filename)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
bool ok = false;
|
|
|
|
char sz[CALLSIGN_LEN+1];
|
|
|
|
char sz[32];
|
|
|
|
|
|
|
|
|
|
|
|
// and load
|
|
|
|
// and load
|
|
|
|
std::ifstream file (filename);
|
|
|
|
std::ifstream file (filename);
|
|
|
|
@ -69,7 +69,13 @@ bool CCallsignList::LoadFromFile(const char *filename)
|
|
|
|
// fill with file content
|
|
|
|
// fill with file content
|
|
|
|
while ( file.getline(sz, sizeof(sz)).good() )
|
|
|
|
while ( file.getline(sz, sizeof(sz)).good() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
push_back(CCallsign(sz));
|
|
|
|
// remove leading & trailing spaces
|
|
|
|
|
|
|
|
char *szt = TrimWhiteSpaces(sz);
|
|
|
|
|
|
|
|
// and load
|
|
|
|
|
|
|
|
if ( ::strlen(szt) > 0 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
push_back(CCallsign(szt));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// close file
|
|
|
|
// close file
|
|
|
|
file.close();
|
|
|
|
file.close();
|
|
|
|
@ -116,27 +122,6 @@ bool CCallsignList::NeedReload(void)
|
|
|
|
return needReload;
|
|
|
|
return needReload;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCallsignList::GetLastModTime(time_t *time)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( m_Filename != NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int file=0;
|
|
|
|
|
|
|
|
if( (file = ::open(m_Filename, O_RDONLY)) != -1 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct stat fileStat;
|
|
|
|
|
|
|
|
if( ::fstat(file, &fileStat) != -1 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*time = fileStat.st_mtime;
|
|
|
|
|
|
|
|
ok = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// compare
|
|
|
|
// compare
|
|
|
|
|
|
|
|
|
|
|
|
@ -151,3 +136,43 @@ bool CCallsignList::IsListed(const CCallsign &callsign) const
|
|
|
|
|
|
|
|
|
|
|
|
return listed;
|
|
|
|
return listed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// helpers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *CCallsignList::TrimWhiteSpaces(char *str)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char *end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trim leading space
|
|
|
|
|
|
|
|
while(*str == ' ') str++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// All spaces?
|
|
|
|
|
|
|
|
if(*str == 0)
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trim trailing space
|
|
|
|
|
|
|
|
end = str + ::strlen(str) - 1;
|
|
|
|
|
|
|
|
while((end > str) && (*end == ' ')) end--;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write new null terminator
|
|
|
|
|
|
|
|
*(end+1) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CCallsignList::GetLastModTime(time_t *time)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( m_Filename != NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct stat fileStat;
|
|
|
|
|
|
|
|
if( ::stat(m_Filename, &fileStat) != -1 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*time = fileStat.st_mtime;
|
|
|
|
|
|
|
|
ok = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
|
|
|
}
|
|
|
|
|