added: issues ticket system
added functions: ticket, createticket, editticket
(there is no 'rm' function working for tickets yet)
changed: mount parser and mount points
now we have more parameters (arguments in parameters)
some refactoring in functions 'emacs' and 'mkdir'
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@554 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include "mountparser.h"
|
||||
#include "data.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
bool MountParser::IsWhite(int c)
|
||||
@@ -39,11 +39,38 @@ void MountParser::SkipLine()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadWord(std::string & res)
|
||||
void MountParser::ReadWordQuote(std::string & res)
|
||||
{
|
||||
++pinput;
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!='\"' )
|
||||
{
|
||||
if( pinput[0]=='\\' && pinput[1]=='\"' )
|
||||
{
|
||||
res += '\"';
|
||||
pinput += 2;
|
||||
}
|
||||
else
|
||||
if( pinput[0]=='\\' && pinput[1]=='\\' )
|
||||
{
|
||||
res += '\\';
|
||||
pinput += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
res += *pinput;
|
||||
pinput += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( *pinput == '"' )
|
||||
++pinput;
|
||||
}
|
||||
|
||||
|
||||
// a white character is the separator
|
||||
void MountParser::ReadWordWhite(std::string & res)
|
||||
{
|
||||
res.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
@@ -52,64 +79,71 @@ void MountParser::ReadWord(std::string & res)
|
||||
}
|
||||
|
||||
|
||||
bool MountParser::ReadParamArg(int & out)
|
||||
// the comma or the second bracket ')' are the separators
|
||||
void MountParser::ReadWordComma(std::string & res)
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
char * new_pos;
|
||||
long temp = strtol(pinput, &new_pos, 10);
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!=')' )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
|
||||
if( pinput == new_pos )
|
||||
return false;
|
||||
|
||||
pinput = new_pos;
|
||||
SkipWhite();
|
||||
|
||||
// here can we make a test whether the temp is greater from 'int' type
|
||||
out = (int)temp;
|
||||
|
||||
return true;
|
||||
// trimming last white characters
|
||||
// (white characters can be in the middle of the string)
|
||||
TrimWhite(res);
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParamArgs(std::vector<int> & args)
|
||||
void MountParser::ReadWord(std::string & res, bool comma_bracket_separator)
|
||||
{
|
||||
int arg;
|
||||
res.clear();
|
||||
SkipWhite();
|
||||
|
||||
while( ReadParamArg(arg) )
|
||||
if( *pinput == '"' )
|
||||
{
|
||||
args.push_back(arg);
|
||||
|
||||
log << log3 << "MP: mount param arg: " << arg << logend;
|
||||
|
||||
ReadWordQuote(res);
|
||||
}
|
||||
else
|
||||
if( comma_bracket_separator )
|
||||
{
|
||||
ReadWordComma(res);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadWordWhite(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadParamArgsLoop(Mount::ParamArg & args)
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!=')' )
|
||||
{
|
||||
ReadWord(temp_arg, true);
|
||||
|
||||
if( !temp_arg.empty() )
|
||||
args.push_back(temp_arg);
|
||||
|
||||
if( *pinput == ',' )
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParam(std::string & res, std::vector<int> & args)
|
||||
void MountParser::ReadParamArgs(Mount::ParamArg & args)
|
||||
{
|
||||
SkipWhite();
|
||||
res.clear();
|
||||
args.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!='(' && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
|
||||
if( res.empty() )
|
||||
return;
|
||||
|
||||
|
||||
// reading arguments
|
||||
SkipWhite();
|
||||
|
||||
|
||||
if( *pinput == '(' )
|
||||
{
|
||||
++pinput;
|
||||
ReadParamArgs(args);
|
||||
ReadParamArgsLoop(args);
|
||||
|
||||
if( *pinput != ')' )
|
||||
{
|
||||
@@ -121,16 +155,42 @@ void MountParser::ReadParam(std::string & res, std::vector<int> & args)
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadParamName(std::string & res)
|
||||
{
|
||||
SkipWhite();
|
||||
res.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!='(' && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParam(std::string & res, Mount::ParamArg & args)
|
||||
{
|
||||
ReadParamName(res);
|
||||
|
||||
if( res.empty() )
|
||||
return;
|
||||
|
||||
ReadParamArgs(args);
|
||||
|
||||
SkipWhite();
|
||||
|
||||
if( *pinput == ',' )
|
||||
++pinput;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadMountType()
|
||||
{
|
||||
SkipWhite();
|
||||
ReadWord(temp);
|
||||
|
||||
if( temp.empty() )
|
||||
@@ -151,6 +211,12 @@ void MountParser::ReadMountType()
|
||||
log << log3 << "MP: mount type: thread" << logend;
|
||||
}
|
||||
else
|
||||
if( temp == "ticket" )
|
||||
{
|
||||
mount.type = Mount::ticket;
|
||||
log << log3 << "MP: mount type: ticket" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Error::mount_unknown;
|
||||
log << log1 << "MP: unknown mount type: " << temp << logend;
|
||||
@@ -161,9 +227,6 @@ void MountParser::ReadMountType()
|
||||
|
||||
void MountParser::ReadMountPoint()
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
// !! narazie bez cudzyslowow
|
||||
ReadWord(temp);
|
||||
|
||||
pdir = data.dirs.GetDir(temp);
|
||||
@@ -182,21 +245,41 @@ void MountParser::ReadMountPoint()
|
||||
|
||||
|
||||
|
||||
void MountParser::LogMountParams()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
log << log3 << "MP: mount param: " << temp << "(";
|
||||
|
||||
for(i=0 ; i<param_args.size() ; ++i)
|
||||
{
|
||||
log << param_args[i];
|
||||
|
||||
if( i != param_args.size()-1 )
|
||||
log << ",";
|
||||
}
|
||||
|
||||
log << ")" << logend;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadMountParams()
|
||||
{
|
||||
mount.ClearParams();
|
||||
|
||||
for( ReadParam(temp, param_args) ; !temp.empty() ; ReadParam(temp, param_args) )
|
||||
{
|
||||
if( !mount.ParseStrParam(temp, param_args) )
|
||||
Mount::ParamCode p = Mount::ParseParam(temp.c_str());
|
||||
|
||||
if( p != Mount::par_none )
|
||||
{
|
||||
log << log1 << "MP: unknown mount param: " << temp << logend;
|
||||
err = Error::mount_no_param;
|
||||
return;
|
||||
mount.param[p].defined = true;
|
||||
mount.param[p].arg = param_args;
|
||||
LogMountParams();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "MP: mount param: " << temp << logend;
|
||||
log << log1 << "MP: unknown mount param: " << temp << " (skipped)" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +304,13 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
|
||||
ReadMountParams();
|
||||
|
||||
if( err == Error::ok )
|
||||
output.insert( std::make_pair(mount.dir_id, mount) );
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
SkipLine();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user