added: SLog class -- session logger

messages are displayed in the browser (with locales)
changed: MountParser
         now if there is an error in a line -- the line is simply skipped
         


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@741 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-06-19 20:59:58 +00:00
parent b369fda1d9
commit 0a7432b059
35 changed files with 2417 additions and 1671 deletions

View File

@@ -15,10 +15,10 @@
MountParser::MountParser()
{
dirs = 0;
skip_static = false;
mount_type_tab = 0;
mount_fs_tab = 0;
mount_par_tab = 0;
skip_static = false;
mount_type_tab = 0;
mount_fs_tab = 0;
mount_par_tab = 0;
static_mount_id = -1;
}
@@ -248,15 +248,14 @@ return -1;
}
void MountParser::ReadMountType()
bool MountParser::ReadMountType()
{
ReadWord(temp);
if( temp.empty() )
{
// an empty line (some white characters only)
err = WINIX_ERR_EMPTY;
return;
return false;
}
mount.type = FindIndex(mount_type_tab, temp);
@@ -267,34 +266,38 @@ void MountParser::ReadMountType()
}
else
{
err = WINIX_ERR_MOUNT_UNKNOWN;
log << log1 << "MP: unknown mount type: " << temp << logend;
slog << logerror << T("unknown_mount_type") << ": " << temp << logend;
}
return mount.type != -1;
}
void MountParser::ReadMountPoint()
bool MountParser::ReadMountPoint()
{
ReadWord(temp);
ReadWord(last_dir);
pdir = dirs->GetDir(temp);
pdir = dirs->GetDir(last_dir);
if( pdir )
{
mount.dir_id = pdir->id;
log << log3 << "MP: mount point (directory): " << temp << logend;
log << log3 << "MP: mount point (directory): " << last_dir << logend;
}
else
{
err = WINIX_ERR_NO_MOUNTPOINT;
log << log1 << "MP: there is no such a mount point (directory): " << temp << logend;
log << log1 << "MP: there is no such a mount point (directory): " << last_dir << logend;
slog << logerror << T("no_such_dir") << ": " << last_dir << logend;
}
return pdir != 0;
}
void MountParser::ReadFs()
bool MountParser::ReadFs()
{
ReadWord(temp);
mount.fs = FindIndex(mount_fs_tab, temp);
@@ -305,9 +308,11 @@ void MountParser::ReadFs()
}
else
{
err = WINIX_ERR_UNKNOWN_FILESYSTEM;
log << log1 << "MP: unknown filesystem: " << temp << logend;
slog << logerror << T("unknown_filesystem") << ": " << temp << " (" << last_dir << ")" << logend;
}
return mount.fs != -1;
}
@@ -347,7 +352,8 @@ void MountParser::ReadMountParams()
}
else
{
log << log1 << "MP: unknown mount param: " << temp << " (skipped)" << logend;
log << log1 << "MP: unknown mount param: " << temp << logend;
slog << logwarning << T("unknown_mount_param") << ": " << temp << " (" << T("skipped") << ")" << logend;
}
}
}
@@ -356,38 +362,25 @@ void MountParser::ReadMountParams()
void MountParser::ReadRow(std::map<long, Mount> & output)
{
ReadMountType();
if( err == WINIX_ERR_EMPTY )
if( ReadMountType() && ReadMountPoint() && ReadFs() )
{
err = WINIX_ERR_OK;
SkipLine();
return;
}
if( err == WINIX_ERR_OK )
ReadMountPoint();
if( err == WINIX_ERR_OK )
ReadFs();
if( err == WINIX_ERR_OK )
ReadMountParams();
if( err == WINIX_ERR_OK )
{
if( skip_static && mount.type==static_mount_id )
{
log << log1 << "MP: static mount points are skipped (dont_use_static_dirs in config is true)" << logend;
slog << logwarning << T("skipped_static_mount") << ": " << last_dir << logend;
}
else
{
std::pair<std::map<long, Mount>::iterator, bool> res = output.insert( std::make_pair(mount.dir_id, mount) );
if( !res.second )
{
log << log1 << "MP: this mount point exists (skipped)" << logend;
slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
}
}
}
SkipLine();
@@ -396,31 +389,21 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
Error MountParser::Parse(const std::wstring & input, std::map<long, Mount> & output)
void MountParser::Parse(const std::wstring & input, std::map<long, Mount> & output)
{
if( !dirs || !mount_type_tab || !mount_fs_tab || !mount_par_tab )
{
log << log1 << "pdir: " << pdir << logend;
log << log1 << "type: " << mount_type_tab << logend;
log << log1 << "fs: " << mount_fs_tab << logend;
log << log1 << "par: " << mount_par_tab << logend;
log << log1 << "MP: input tables not set" << logend;
return WINIX_NOTHING_TO_DO; // !! may a better code?
return;
}
pinput = input.c_str();
err = WINIX_ERR_OK;
mount.param.resize(mount_par_tab->size());
mount.ClearParams();
output.clear();
while( *pinput && err == WINIX_ERR_OK )
while( *pinput )
ReadRow(output);
return err;
}