-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcq_conf.h
65 lines (56 loc) · 1.82 KB
/
dcq_conf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************
* 文件名称: dcq_conf.h
* 简要描述: domain company query 配置解析
*
* 当前版本:1.0
* 作者: ZJJ
* 日期: 2020/11/29
* 说明: json 配置文件解析相关逻辑
******************************************************************/
#ifndef __DCQ_CONF_H__
#define __DCQ_CONF_H__
#include <iostream>
#include <string>
#include <map>
#include <fstream>
#include <jsoncpp/json/json.h>
#include "dcq_db.h"
using namespace std;
#define DEFAULT_DB "/home/domain.db"
#define DEFAULT_DEBUG_LEVEL (0)
#define DEFAULT_TIME_OUT (60)
#define DEFAULT_KEY "主办单位名称"
struct global_context
{
string db = DEFAULT_DB;
int debug_level = DEFAULT_DEBUG_LEVEL;
int time_out = DEFAULT_DEBUG_LEVEL;
vector<string> key;
};
struct icp_context
{
string curl = "";
string type = "";
};
struct conf_context
{
struct global_context global;
vector<struct icp_context> icp;
dcq_db_context *db_handle = nullptr;
};
/*******************************************************************
* 函数名称: dcq_config_load
* 简要描述: 将 config_file 指向的配置信息加载到 out_conf 中
* 输入参数: config_file 配置文件路径
* 输出参数: out_conf 输出的配置信息
* 返回值: errno 0 成功, <0 打开文件失败或格式不匹配
******************************************************************/
extern int dcq_config_load(string config_file, struct conf_context **out_conf);
/*******************************************************************
* 函数名称: dcq_config_load
* 简要描述: 释放记载的配置信息
* 输入参数: conf 配置信息
* 返回值: 无
******************************************************************/
extern void dcq_config_free(struct conf_context *conf);
#endif