E-MailRelay

gverifierfactory.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gverifierfactory.h
19///
20
21#ifndef G_VERIFIER_FACTORY_H
22#define G_VERIFIER_FACTORY_H
23
24#include "gdef.h"
25#include "gverifierfactorybase.h"
26#include "gverifier.h"
27#include "geventstate.h"
28#include "gstringview.h"
29#include "gstringarray.h"
30#include <string>
31#include <utility>
32#include <memory>
33
34 namespace GVerifiers
35{
36 class VerifierFactory ;
37}
38
39//| \class GVerifiers::VerifierFactory
40/// A VerifierFactory implementation.
41///
42 class GVerifiers::VerifierFactory : public GSmtp::VerifierFactoryBase
43{
44 public:
45 VerifierFactory() ;
46 ///< Constructor.
47
48 static Spec parse( std::string_view spec , const G::Path & base_dir = {} ,
49 const G::Path & app_dir = {} , G::StringArray * warnings_p = nullptr ) ;
50 ///< Parses a verifier specification string like "/usr/bin/foo" or
51 ///< "net:127.0.0.1:99" or "net:/run/spamd.s", returning the
52 ///< type and value in a Spec tuple, eg. ("file","/usr/bin/foo")
53 ///< or ("net","127.0.0.1:99").
54 ///<
55 ///< Any relative file paths are made absolute using the given
56 ///< base directory, if given. (This is normally from
57 ///< G::Process::cwd() called at startup).
58 ///<
59 ///< Any "@app" sub-strings in file paths are substituted with
60 ///< the given application directory, if given.
61 ///<
62 ///< Returns 'first' empty if a fatal parsing error, with the
63 ///< reason in 'second'.
64 ///<
65 ///< Returns warnings by reference for non-fatal errors, such
66 ///< as missing files.
67
68 protected: // overrides
69 std::unique_ptr<GSmtp::Verifier> newVerifier( GNet::EventState ,
70 const GSmtp::Verifier::Config & config ,
71 const GSmtp::VerifierFactoryBase::Spec & spec ) override ;
72
73 private:
74 static void checkFile( Spec & result , G::StringArray * warnings_p ) ;
75 static void fixFile( Spec & result , const G::Path & base_dir , const G::Path & app_dir ) ;
76 static void checkNet( Spec & result ) ;
77 static void checkRange( Spec & result ) ;
78 static void checkExit( Spec & result ) ;
79} ;
80
81#endif
GNet::EventState
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
GSmtp::VerifierFactoryBase
A factory interface for addresss verifiers.
Definition: gverifierfactorybase.h:41
GVerifiers::VerifierFactory
A VerifierFactory implementation.
Definition: gverifierfactory.h:43
GVerifiers::VerifierFactory::parse
static Spec parse(std::string_view spec, const G::Path &base_dir={}, const G::Path &app_dir={}, G::StringArray *warnings_p=nullptr)
Parses a verifier specification string like "/usr/bin/foo" or "net:127.0.0.1:99" or "net:/run/spamd....
Definition: gverifierfactory.cpp:36
GVerifiers::VerifierFactory::newVerifier
std::unique_ptr< GSmtp::Verifier > newVerifier(GNet::EventState, const GSmtp::Verifier::Config &config, const GSmtp::VerifierFactoryBase::Spec &spec) override
Returns a Verifier on the heap.
Definition: gverifierfactory.cpp:76
GVerifiers::VerifierFactory::VerifierFactory
VerifierFactory()
Constructor.
G::Path
A Path object represents a file system path.
Definition: gpath.h:82
geventstate.h
gstringarray.h
gstringview.h
gverifier.h
gverifierfactorybase.h
GVerifiers
Address verifier classes.
Definition: gexecutableverifier.h:31
G::StringArray
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstringarray.h:30
GSmtp::VerifierFactoryBase::Spec
Verifier specification tuple for GSmtp::VerifierFactoryBase::newVerifier().
Definition: gverifierfactorybase.h:44
GSmtp::Verifier::Config
Configuration passed to address verifier constructors.
Definition: gverifier.h:57