X-Git-Url: https://git.hcoop.net/hcoop/debian/courier-authlib.git/blobdiff_plain/1420868b3e321353480efbb7eb35e1e8d9943223..463a5c942956f42fce366796356201639cb0d92b:/authconfigfile.h diff --git a/authconfigfile.h b/authconfigfile.h new file mode 100644 index 0000000..e87258c --- /dev/null +++ b/authconfigfile.h @@ -0,0 +1,101 @@ +#ifndef authconfigfile_h +#define authconfigfile_h + +#if HAVE_CONFIG_H +#include "courier_auth_config.h" +#endif + +#include +#if HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include + +namespace courier { + namespace auth { +#if 0 + } +} +#endif + +class config_file { + +protected: + const char *filename; + + std::map parsed_config; +private: + bool loaded; + time_t config_timestamp; + +public: + config_file(const char *filenameArg); + bool load(bool reload=false); + +private: + virtual bool do_load()=0; + virtual void do_reload()=0; + + class isspace; + class not_isspace; + + bool open_and_load_file(bool reload); + + public: + + + template + bool config(const char *name, + value_type &value, + bool required, + const char *default_value=0) + const + { + std::string string_value; + + if (!getconfig(name, string_value, required, default_value)) + return false; + + std::istringstream i(string_value); + + i >> value; + return true; + } + + std::string config(const char *name) const; + std::string config(const char *name, const char *default_value) const; + + bool getconfig(const char *name, + std::string &value, + bool required, + const char *default_value=0) const; + + static std::string expand_string(const std::string &s, + const std::map ¶meters); + + static std::string + parse_custom_query(const std::string &s, + const std::string &login, + const std::string &defdomain, + std::map ¶meters); +}; + +template<> +bool config_file::config(const char *name, + std::string &value, + bool required, + const char *default_value) const; + +#if 0 +{ + { +#endif + } +} + +#endif