2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2019-05-09 13:57:51 +08:00
|
|
|
|
#include "../stdlib/noncopyable.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-05-18 21:19:21 +08:00
|
|
|
|
#ifndef ACL_CLIENT_ONLY
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ACL_XINETD_CFG_PARSER;
|
|
|
|
|
struct ACL_CFG_INT_TABLE;
|
|
|
|
|
struct ACL_CFG_INT64_TABLE;
|
|
|
|
|
struct ACL_CFG_STR_TABLE;
|
|
|
|
|
struct ACL_CFG_BOOL_TABLE;
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
typedef struct master_int_tbl
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
int defval;
|
|
|
|
|
int *target;
|
|
|
|
|
int min;
|
|
|
|
|
int max;
|
|
|
|
|
} master_int_tbl;
|
|
|
|
|
|
|
|
|
|
typedef struct master_str_tbl
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *defval;
|
|
|
|
|
char **target;
|
|
|
|
|
} master_str_tbl;
|
|
|
|
|
|
|
|
|
|
typedef struct master_bool_tbl
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
int defval;
|
|
|
|
|
int *target;
|
|
|
|
|
} master_bool_tbl;
|
|
|
|
|
|
|
|
|
|
typedef struct master_int64_tbl
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
__int64 defval;
|
|
|
|
|
__int64 *target;
|
|
|
|
|
__int64 min;
|
|
|
|
|
__int64 max;
|
|
|
|
|
#else
|
|
|
|
|
long long int defval;
|
|
|
|
|
long long int *target;
|
|
|
|
|
long long int min;
|
|
|
|
|
long long int max;
|
|
|
|
|
#endif
|
|
|
|
|
} master_int64_tbl;
|
|
|
|
|
|
|
|
|
|
class master_base;
|
|
|
|
|
|
2019-05-09 13:57:51 +08:00
|
|
|
|
class ACL_CPP_API master_conf : public noncopyable
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
master_conf();
|
|
|
|
|
~master_conf();
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> bool <EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param table {master_bool_tbl*}
|
|
|
|
|
*/
|
|
|
|
|
void set_cfg_bool(master_bool_tbl* table);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> int <EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param table {master_int_tbl*}
|
|
|
|
|
*/
|
|
|
|
|
void set_cfg_int(master_int_tbl* table);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> int64 <EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param table {master_int64_tbl*}
|
|
|
|
|
*/
|
|
|
|
|
void set_cfg_int64(master_int64_tbl* table);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param table {master_str_tbl*}
|
|
|
|
|
*/
|
|
|
|
|
void set_cfg_str(master_str_tbl* table);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
* @param path {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
void load(const char* path);
|
|
|
|
|
|
2017-07-22 21:32:21 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> load <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD>ʾû<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
|
2017-07-22 21:32:21 +08:00
|
|
|
|
*/
|
|
|
|
|
const char* get_path(void) const;
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ֮ǰ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ潫<EFBFBD>ᱻ<EFBFBD>ͷţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>øú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD>ʹ<EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
void reset(void);
|
|
|
|
|
|
|
|
|
|
ACL_CFG_INT_TABLE* get_int_cfg() const;
|
|
|
|
|
ACL_CFG_INT64_TABLE* get_int64_cfg() const;
|
|
|
|
|
ACL_CFG_STR_TABLE* get_str_cfg() const;
|
|
|
|
|
ACL_CFG_BOOL_TABLE* get_bool_cfg() const;
|
2017-07-22 21:32:21 +08:00
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
private:
|
2017-07-22 21:32:21 +08:00
|
|
|
|
char* path_;
|
|
|
|
|
bool cfg_loaded_;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
ACL_XINETD_CFG_PARSER* cfg_;
|
|
|
|
|
ACL_CFG_INT_TABLE* int_cfg_;
|
|
|
|
|
ACL_CFG_INT64_TABLE* int64_cfg_;
|
|
|
|
|
ACL_CFG_STR_TABLE* str_cfg_;
|
|
|
|
|
ACL_CFG_BOOL_TABLE* bool_cfg_;
|
|
|
|
|
|
|
|
|
|
master_int_tbl* int_tbl_;
|
|
|
|
|
master_str_tbl* str_tbl_;
|
|
|
|
|
master_bool_tbl* bool_tbl_;
|
|
|
|
|
master_int64_tbl* int64_tbl_;
|
|
|
|
|
|
|
|
|
|
void load_str(void);
|
|
|
|
|
void load_bool(void);
|
|
|
|
|
void load_int(void);
|
|
|
|
|
void load_int64(void);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
|
|
|
|
#endif // ACL_CLIENT_ONLY
|