32 G_DEBUG(
"GSmtp::FactoryParser::parse: [" << identifier <<
"]" ) ;
33 if( identifier.find(
"net:") == 0U )
37 else if( allow_spam && identifier.find(
"spam:") == 0U )
41 else if( allow_spam && identifier.find(
"spam-edit:") == 0U )
45 else if( identifier.find(
"file:") == 0U )
49 else if( identifier.find(
"exit:") == 0U )
53 else if( !identifier.empty() )
55 return Result(
"file" , identifier ) ;
65 Result p = parse( identifier , allow_spam ) ;
66 if( p.first ==
"net" || ( allow_spam && p.first ==
"spam" ) )
68 return std::string() ;
70 else if( p.first ==
"file" )
74 return "no such file" ;
76 return "probably not executable" ;
78 return "not an absolute path" ;
80 return std::string() ;
82 else if( p.first ==
"exit" )
85 return "not a numeric exit code" ;
87 return std::string() ;
91 return std::string() ;
95GSmtp::FactoryParser::Result::Result()
98GSmtp::FactoryParser::Result::Result(
const std::string & first_ ,
const std::string & second_ ) :
104GSmtp::FactoryParser::Result::Result(
const std::string & first_ ,
const std::string & second_ ,
int third_ ) :
static Result parse(const std::string &identifier, bool allow_spam)
Parses an identifier like "/usr/bin/foo" or "net:127.0.0.1:99" or "net:/run/spamd....
static std::string check(const std::string &identifier, bool allow_spam)
Parses and checks an identifier.
static bool isExecutable(const Path &, std::nothrow_t)
Returns true if the path is probably executable by the calling process.
static bool exists(const Path &file)
Returns true if the file (directory, device etc.) exists.
A Path object represents a file system path.
bool isAbsolute() const
Returns !isRelative().
static std::string tail(const std::string &in, std::size_t pos, const std::string &default_=std::string())
Returns the last part of the string after the given position.
static bool isUInt(const std::string &s)
Returns true if the string can be converted into an unsigned integer without throwing an exception.
Result tuple for GSmtp::FactoryParser::parse().