资源简介

数字货币 交易所 撮合系统 源码,C 语言,可用,学习研究

资源截图

代码片段和文件信息

/*
 * Description: 
 *     History: yang@haipo.me 2017/04/21 create
 */

# include “ah_config.h“

struct settings settings;

static int read_config_from_json(json_t *root)
{
    int ret;
    ret = load_cfg_process(root “process“ &settings.process);
    if (ret < 0) {
        printf(“load process config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_log(root “log“ &settings.log);
    if (ret < 0) {
        printf(“load log config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_alert(root “alert“ &settings.alert);
    if (ret < 0) {
        printf(“load alert config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_http_svr(root “svr“ &settings.svr);
    if (ret < 0) {
        printf(“load svr config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_svr(root “monitor“ &settings.monitor);
    if (ret < 0) {
        printf(“load monitor config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_rpc_clt(root “matchengine“ &settings.matchengine);
    if (ret < 0) {
        printf(“load matchengine clt config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_rpc_clt(root “marketprice“ &settings.marketprice);
    if (ret < 0) {
        printf(“load marketprice clt config fail: %d\n“ ret);
        return -__LINE__;
    }
    ret = load_cfg_rpc_clt(root “readhistory“ &settings.readhistory);
    if (ret < 0) {
        printf(“load readhistory clt config fail: %d\n“ ret);
        return -__LINE__;
    }

    ERR_RET(read_cfg_real(root “timeout“ &settings.timeout false 1.0));
    ERR_RET(read_cfg_int(root “worker_num“ &settings.worker_num false 1));

    return 0;
}

int init_config(const char *path)
{
    json_error_t error;
    json_t *root = json_load_file(path 0 &error);
    if (root == NULL) {
        printf(“json_load_file from: %s fail: %s in line: %d\n“ path error.text error.line);
        return -__LINE__;
    }
    if (!json_is_object(root)) {
        json_decref(root);
        return -__LINE__;
    }
    int ret = read_config_from_json(root);
    if (ret < 0) {
        json_decref(root);
        return ret;
    }
    json_decref(root);

    return 0;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-09-03 13:57  viabtc_exchange_server-master\
     文件        7316  2018-09-03 13:57  viabtc_exchange_server-master\.gitignore
     文件        1077  2018-09-03 13:57  viabtc_exchange_server-master\LICENSE
     文件        4033  2018-09-03 13:57  viabtc_exchange_server-master\README.md
     目录           0  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\
     文件        2244  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_config.c
     文件        1250  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_config.h
     文件        3582  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_listener.c
     文件         161  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_listener.h
     文件        2973  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_main.c
     文件       10329  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_server.c
     文件         155  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\ah_server.h
     文件        1031  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\config.json
     文件         242  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\makefile
     文件          84  2018-09-03 13:57  viabtc_exchange_server-master\accesshttp\restart.sh
     目录           0  2018-09-03 13:57  viabtc_exchange_server-master\accessws\
     文件        7851  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_asset.c
     文件         336  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_asset.h
     文件        5327  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_auth.c
     文件         238  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_auth.h
     文件        4658  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_config.c
     文件        2072  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_config.h
     文件        9462  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_deals.c
     文件         297  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_deals.h
     文件       14482  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_depth.c
     文件         374  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_depth.h
     文件        8886  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_kline.c
     文件         257  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_kline.h
     文件        3582  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_listener.c
     文件         161  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_listener.h
     文件        4553  2018-09-03 13:57  viabtc_exchange_server-master\accessws\aw_main.c
............此处省略223个文件信息

评论

共有 条评论