示例#1
0
static int conf_init(rmt_conf *cf)
{
    int ret;

    if(cf == NULL){
        return RMT_ERROR;
    }

    cf->fname = NULL;
    cf->fh = NULL;
    cf->organizations = NULL;

    cf->organizations = dictCreate(&OrganizationDictType, NULL);
    if (cf->organizations == NULL) {
        return RMT_ERROR;
    }

    ret = conf_pool_init(&cf->source_pool);
    if(ret != RMT_OK){
        return RMT_ERROR;
    }
    
    ret = conf_pool_init(&cf->target_pool);
    if(ret != RMT_OK){
        return RMT_ERROR;
    } 

    cf->listen = CONF_UNSET_PTR;
    cf->maxmemory = CONF_UNSET_NUM;
    cf->threads = CONF_UNSET_NUM;
    cf->step = CONF_UNSET_NUM;
    cf->mbuf_size = CONF_UNSET_NUM;
    cf->noreply = CONF_UNSET_NUM;
    cf->rdb_diskless = CONF_UNSET_NUM;
    cf->source_safe = CONF_UNSET_NUM;
    cf->dir = CONF_UNSET_PTR;

    cf->max_clients = CONF_UNSET_NUM;

    cf->filter = CONF_UNSET_PTR;
    
    return RMT_OK;
}
示例#2
0
static rstatus_t
conf_handler(struct conf *cf, void *data)
{
    struct command *cmd;
    struct string *key, *value;
    uint32_t narg;

    if (array_n(&cf->arg) == 1) {
        value = array_top(&cf->arg);
        log_debug(LOG_VVERB, "conf handler on '%.*s'", value->len, value->data);
        return conf_pool_init(data, value);
    }

    narg = array_n(&cf->arg);
    value = array_get(&cf->arg, narg - 1);
    key = array_get(&cf->arg, narg - 2);

    log_debug(LOG_VVERB, "conf handler on %.*s: %.*s", key->len, key->data,
              value->len, value->data);

    for (cmd = conf_commands; cmd->name.len != 0; cmd++) {
        char *rv;

        if (string_compare(key, &cmd->name) != 0) {
            continue;
        }

        rv = cmd->set(cf, cmd, data);
        if (rv != CONF_OK) {
            log_error("conf: directive \"%.*s\" %s", key->len, key->data, rv);
            return NC_ERROR;
        }

        return NC_OK;
    }

    log_error("conf: directive \"%.*s\" is unknown", key->len, key->data);

    return NC_ERROR;
}