|
SASC
DVBSoftCAM
|
#include <data.h>
Inheritance diagram for cStructLoaderPlain:Public Member Functions | |
| cStructLoaderPlain (const char *Type, const char *Filename, int Flags) | |
| virtual void | Load (bool reload) |
| virtual void | Save (void) |
| cStructLoaderPlain (const char *Type, const char *Filename, int Flags) | |
| virtual void | Load (bool reload) |
| virtual void | Save (void) |
Protected Member Functions | |
| virtual cStructItem * | ParseLine (char *line) |
| virtual bool | ParseLinePlain (const char *line)=0 |
| virtual void | PreLoad (void) |
| virtual void | PreSave (FILE *f) |
| virtual void | PostSave (FILE *f) |
| virtual cStructItem * | ParseLine (char *line) |
| virtual bool | ParseLinePlain (const char *line)=0 |
| virtual void | PreLoad (void) |
| virtual void | PreSave (FILE *f) |
| virtual void | PostSave (FILE *f) |
| cStructLoaderPlain::cStructLoaderPlain | ( | const char * | Type, |
| const char * | Filename, | ||
| int | Flags | ||
| ) |
Definition at line 421 of file data.c.
:cStructLoader(Type,Filename,Flags) {}
| cStructLoaderPlain::cStructLoaderPlain | ( | const char * | Type, |
| const char * | Filename, | ||
| int | Flags | ||
| ) |
| void cStructLoaderPlain::Load | ( | bool | reload | ) | [virtual] |
Reimplemented from cStructLoader.
Definition at line 432 of file data.c.
References cStructLoader::CheckAccess(), L_GEN_ERROR, L_GEN_INFO, cStructLoader::ListLock(), cStructLoader::ListUnlock(), cStructLoader::LoadFinished(), cStructLoader::OpenFailed(), ParseLinePlain(), cStructLoader::path, cStructLoader::PostLoad(), PreLoad(), PRINTF, skipspace(), SL_CLRFLAG, SL_DISABLED, SL_LOADED, SL_SETFLAG, SL_TSTFLAG, strreplace(), and cStructLoader::type.
Referenced by cTpsAuHook::DummyProcess().
{
if(SL_TSTFLAG(SL_DISABLED) || reload) return;
FILE *f=fopen(path,"r");
if(f) {
PreLoad();
ListLock(true);
SL_SETFLAG(SL_LOADED);
PRINTF(L_GEN_INFO,"loading %s from %s",type,path);
CheckAccess();
int lineNum=0;
char buff[4096];
while(fgets(buff,sizeof(buff),f)) {
lineNum++;
if(!index(buff,'\n') && !feof(f)) {
PRINTF(L_GEN_ERROR,"file %s readbuffer overflow line#%d",path,lineNum);
SL_CLRFLAG(SL_LOADED);
break;
}
strreplace(buff,'\n',0); strreplace(buff,'\r',0); // chomp
bool hasContent=false;
char *ls;
for(ls=buff; *ls; ls++) {
if(*ls==';' || *ls=='#') break;
if(*ls>' ') hasContent=true;
}
if(hasContent) {
*ls=0;
if(!ParseLinePlain(skipspace(buff)))
PRINTF(L_GEN_ERROR,"file %s has error in line #%d",path,lineNum);
}
}
ListUnlock();
PostLoad();
fclose(f);
LoadFinished();
}
else
OpenFailed();
}
| virtual void cStructLoaderPlain::Load | ( | bool | reload | ) | [virtual] |
Reimplemented from cStructLoader.
| virtual cStructItem* cStructLoaderPlain::ParseLine | ( | char * | line | ) | [inline, protected, virtual] |
| virtual cStructItem* cStructLoaderPlain::ParseLine | ( | char * | line | ) | [inline, protected, virtual] |
| virtual bool cStructLoaderPlain::ParseLinePlain | ( | const char * | line | ) | [protected, pure virtual] |
Implemented in cEcmCache, cEcmCache, cSmartCardSlots, cSystemLinkCardClient, cTpsKeys, cSmartCardSlots, cSystemLinkCardClient, and cTpsKeys.
Referenced by Load().
| virtual bool cStructLoaderPlain::ParseLinePlain | ( | const char * | line | ) | [protected, pure virtual] |
Implemented in cEcmCache, cEcmCache, cSmartCardSlots, cSystemLinkCardClient, cTpsKeys, cSmartCardSlots, cSystemLinkCardClient, and cTpsKeys.
| virtual void cStructLoaderPlain::PostSave | ( | FILE * | f | ) | [inline, protected, virtual] |
| virtual void cStructLoaderPlain::PostSave | ( | FILE * | f | ) | [inline, protected, virtual] |
| virtual void cStructLoaderPlain::PreLoad | ( | void | ) | [protected, virtual] |
Reimplemented from cStructLoader.
| void cStructLoaderPlain::PreLoad | ( | void | ) | [protected, virtual] |
Reimplemented from cStructLoader.
Reimplemented in cTpsKeys, and cTpsKeys.
Definition at line 425 of file data.c.
References cSimpleListBase::Clear(), cStructLoader::ListLock(), cStructLoader::ListUnlock(), and cStructLoader::Modified().
Referenced by Load().
{
ListLock(true);
Clear(); Modified(false);
ListUnlock();
}
| virtual void cStructLoaderPlain::PreSave | ( | FILE * | f | ) | [protected, virtual] |
| void cStructLoaderPlain::PreSave | ( | FILE * | f | ) | [protected, virtual] |
| void cStructLoaderPlain::Save | ( | void | ) | [virtual] |
Reimplemented from cStructLoader.
Definition at line 479 of file data.c.
References cStructLoader::CheckDoSave(), cSafeFile::Close(), cSimpleList< cStructItem >::First(), L_CORE_LOAD, cStructLoader::ListLock(), cStructLoader::ListUnlock(), cStructLoader::Modified(), cSimpleList< cStructItem >::Next(), cSafeFile::Open(), cStructLoader::path, PostSave(), PreSave(), PRINTF, and cStructLoader::type.
Referenced by cTpsAuHook::DummyProcess().
{
if(CheckDoSave()) {
cSafeFile f(path);
if(f.Open()) {
ListLock(false);
PreSave(f);
for(cStructItem *it=First(); it; it=Next(it))
if(!it->Deleted() && !it->Save(f)) break;
PostSave(f);
f.Close();
Modified(false);
ListUnlock();
PRINTF(L_CORE_LOAD,"saved %s to %s",type,path);
}
}
}
| virtual void cStructLoaderPlain::Save | ( | void | ) | [virtual] |
Reimplemented from cStructLoader.