示例#1
0
文件: config.c 项目: sunlaobo/lamb
int lamb_get_int64(const config_t *cfg, const char *key, long long *val) {
    if (!config_lookup_int64(cfg, key, val)) {
        return -1;
    }

    return 0;
}
示例#2
0
static int read_config_auth(char config_file[BUFSIZE], struct config_auth* s_auth)
{
    config_t cfg;
    const char* buf;

    config_init(&cfg);

    if (!config_read_file(&cfg, config_file)) {
        pam_http_syslog(LOG_ALERT, "%s:%d - %s\n", config_error_file(&cfg),
            config_error_line(&cfg), config_error_text(&cfg));
        config_destroy(&cfg);
        return 0;
    }

    if (!config_lookup_string(&cfg, "auth_url", &buf)) {
        pam_http_syslog(LOG_ALERT, "No 'auth_url' setting in configuration file.");
        config_destroy(&cfg);
        return 0;
    }
    s_auth->c_auth_url = strndup(buf, BUFSIZE);

    s_auth->c_method = config_get_string(&cfg, "auth_method", DEFAULT_METHOD);
    if (strncmp(s_auth->c_method, HTTP_METHOD_GET, 3) != 0 && strncmp(s_auth->c_method, HTTP_METHOD_POST, 4) != 0) {
        pam_http_syslog(LOG_ALERT, "Wrong 'auth_method' setting in configuration file (%s).", s_auth->c_method);
        config_destroy(&cfg);
        return 0;
    }

    s_auth->c_username_field = config_get_string(&cfg, "auth_username_field", DEFAULT_USERNAME_FIELD);
    s_auth->c_password_field = config_get_string(&cfg, "auth_password_field", DEFAULT_PASSWORD_FIELD);
    if (!config_lookup_int64(&cfg, "auth_timeout", &s_auth->timeout)) {
        s_auth->timeout = DEFAULT_CURL_TIMEOUT;
    }
    if (!config_lookup_int64(&cfg, "auth_success_code", &s_auth->success_code)) {
        s_auth->success_code = DEFAULT_HTTP_SUCCESS_CODE;
    }

    config_destroy(&cfg);
    return 1;
}
示例#3
0
void
fpp_config_initialize(void)
{
    if (initialized)
        return;

    config_t    cfg;
    char       *local_config = get_local_config_path(config_file_name);
    char       *global_config = get_global_config_path(config_file_name);

    config = default_config;

    config_init(&cfg);

    if (!config_read_file(&cfg, local_config)) {
        if (!config_read_file(&cfg, global_config)) {
            goto quit;
        }
    }

    long long intval;
    const char *stringval;

    if (config_lookup_int64(&cfg, "audio_buffer_min_ms", &intval)) {
        config.audio_buffer_min_ms = intval;
    }

    if (config_lookup_int64(&cfg, "audio_buffer_max_ms", &intval)) {
        config.audio_buffer_max_ms = intval;
    }

    if (config_lookup_int64(&cfg, "xinerama_screen", &intval)) {
        config.xinerama_screen = intval;
    }


    if (config_lookup_string(&cfg, "pepperflash_path", &stringval)) {
        config.pepperflash_path = strdup(stringval);
    }

    if (config_lookup_string(&cfg, "flash_command_line", &stringval)) {
        config.flash_command_line = strdup(stringval);
    }

    if (config_lookup_int64(&cfg, "enable_3d", &intval)) {
        config.enable_3d = intval;
    }

    config_destroy(&cfg);

quit:
    g_free(local_config);
    g_free(global_config);

    initialize_quirks();

    // calculate plugin data directory
    local_config = get_local_config_path(config_dir_name);
    pepper_data_dir = g_strdup_printf("%s/%s", local_config, fpp_config_get_plugin_name());
    pepper_salt_file_name = g_strdup_printf("%s/%s", local_config, salt_file_name);
    g_free(local_config);

    initialized = 1;
}