Exemplo n.º 1
0
EAPI const char *
efreet_ini_localestring_get(Efreet_Ini *ini, const char *key)
{
    const char *lang, *country, *modifier;
    const char *val = NULL;
    char *buf;
    int maxlen = 5; /* _, @, [, ] and \0 */
    int found = 0;

    EINA_SAFETY_ON_NULL_RETURN_VAL(ini, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);

    lang = efreet_lang_get();
    country = efreet_lang_country_get();
    modifier = efreet_lang_modifier_get();

    maxlen += strlen(key);
    if (lang) maxlen += strlen(lang);
    if (country) maxlen += strlen(country);
    if (modifier) maxlen += strlen(modifier);

    buf = alloca(maxlen);

    if (lang && modifier && country)
    {
        snprintf(buf, maxlen, "%s[%s_%s@%s]", key, lang, country, modifier);
        val = efreet_ini_string_get(ini, buf);
        if (val && (*val != '\0')) found = 1;
    }

    if (!found && lang && country)
    {
        snprintf(buf, maxlen, "%s[%s_%s]", key, lang, country);
        val = efreet_ini_string_get(ini, buf);
        if (val && (*val != '\0')) found = 1;
    }

    if (!found && lang && modifier)
    {
        snprintf(buf, maxlen, "%s[%s@%s]", key, lang, modifier);
        val = efreet_ini_string_get(ini, buf);
        if (val && (*val != '\0')) found = 1;
    }

    if (!found && lang)
    {
        snprintf(buf, maxlen, "%s[%s]", key, lang);
        val = efreet_ini_string_get(ini, buf);
        if (val && (*val != '\0')) found = 1;
    }

    if (!found)
        val = efreet_ini_string_get(ini, key);

    return val;
}
Exemplo n.º 2
0
static void
_get_freespace(Efreet_Ini *ini, const char *section, int *total, int *avail)
{
    efreet_ini_section_set(ini, section);
    const char *path = efreet_ini_string_get(ini, "Path");
    struct statfs fs;
    statfs(path, &fs);
    *total = fs.f_blocks * fs.f_bsize / ( 1024 * 1024 );
    *avail = fs.f_bavail * fs.f_bsize / ( 1024 * 1024 );
}
Exemplo n.º 3
0
/**
 * @param ini The ini struct to work with
 * @param key The key to search for
 * @return Returns 1 if the boolean is true, 0 otherwise
 * @brief Retrieves the boolean value at key @a key from the ini @a ini
 */
EAPI unsigned int
efreet_ini_boolean_get(Efreet_Ini *ini, const char *key)
{
    const char *str;

    if (!ini || !key || !ini->section) return 0;

    str = efreet_ini_string_get(ini, key);
    if (str && !strcmp("true", str)) return 1;

    return 0;
}
Exemplo n.º 4
0
/**
 * @param ini The Efree_Ini to work with
 * @param key The key to lookup
 * @return Returns the double associated with the given key or -1 if not
 * found.
 * @brief Retrieves the value for the given key or -1 if none found.
 */
EAPI double
efreet_ini_double_get(Efreet_Ini *ini, const char *key)
{
    const char *str;

    if (!ini || !key || !ini->section) return -1;

    str = efreet_ini_string_get(ini, key);
    if (str) return atof(str);

    return -1;
}
Exemplo n.º 5
0
EAPI unsigned int
efreet_ini_boolean_get(Efreet_Ini *ini, const char *key)
{
    const char *str;

    EINA_SAFETY_ON_NULL_RETURN_VAL(ini, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(key, 0);

    str = efreet_ini_string_get(ini, key);
    if (str && !strcmp("true", str)) return 1;

    return 0;
}
Exemplo n.º 6
0
EAPI double
efreet_ini_double_get(Efreet_Ini *ini, const char *key)
{
    const char *str;

    EINA_SAFETY_ON_NULL_RETURN_VAL(ini, -1);
    EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, -1);
    EINA_SAFETY_ON_NULL_RETURN_VAL(key, -1);

    str = efreet_ini_string_get(ini, key);
    if (str) return atof(str);

    return -1;
}