Beispiel #1
0
static gboolean
mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
    mc_fhl_filter_t *mc_filter;
    gchar **exts, **exts_orig;
    gsize exts_size;
    GString *buf;

    exts_orig = exts =
        mc_config_get_string_list (fhl->config, group_name, "extensions", &exts_size);

    if (exts_orig == NULL || exts_orig[0] == NULL)
    {
        g_strfreev (exts_orig);
        return FALSE;
    }

    buf = g_string_sized_new (64);
    for (exts = exts_orig; *exts != NULL; exts++)
    {
        char *esc_ext;

        esc_ext = strutils_regex_escape (*exts);
        if (buf->len != 0)
            g_string_append_c (buf, '|');
        g_string_append (buf, esc_ext);
        g_free (esc_ext);
    }
    g_strfreev (exts_orig);

    g_string_prepend (buf, ".*\\.(");
    g_string_append (buf, ")$");

    mc_filter = g_new0 (mc_fhl_filter_t, 1);
    mc_filter->type = MC_FLHGH_T_FREGEXP;
    mc_filter->search_condition = mc_search_new (buf->str, -1);
    mc_filter->search_condition->is_case_sensitive =
        mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE);
    mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;

    mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
    g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
    g_string_free (buf, TRUE);
    return TRUE;
}
Beispiel #2
0
static gboolean
mc_fhl_parse_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
{
    mc_fhl_filter_t *mc_filter;

    const gchar *types[] = {
        "FILE", "FILE_EXE",
        "DIR", "LINK_DIR",
        "LINK", "HARDLINK", "SYMLINK",
        "STALE_LINK",
        "DEVICE", "DEVICE_BLOCK", "DEVICE_CHAR",
        "SPECIAL", "SPECIAL_SOCKET", "SPECIAL_FIFO", "SPECIAL_DOOR",
        NULL
    };
    int i;
    gchar *param_type = mc_config_get_string (fhl->config, group_name, "type", "");

    if (*param_type == '\0')
    {
        g_free (param_type);
        return FALSE;
    }

    for (i = 0; types[i] != NULL; i++)
    {
        if (strcmp (types[i], param_type) == 0)
            break;
    }
    g_free (param_type);
    if (types[i] == NULL)
        return FALSE;

    mc_filter = g_new0 (mc_fhl_filter_t, 1);
    mc_filter->type = MC_FLHGH_T_FTYPE;
    mc_filter->file_type = (mc_flhgh_ftype_type) i;
    mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);

    g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
    return TRUE;
}
Beispiel #3
0
static gboolean
mc_fhl_parse_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
{
    mc_fhl_filter_t *mc_filter;
    gchar *regexp = mc_config_get_string (fhl->config, group_name, "regexp", "");

    if (*regexp == '\0')
    {
        g_free (regexp);
        return FALSE;
    }

    mc_filter = g_new0 (mc_fhl_filter_t, 1);
    mc_filter->type = MC_FLHGH_T_FREGEXP;
    mc_filter->search_condition = mc_search_new (regexp, -1, DEFAULT_CHARSET);
    mc_filter->search_condition->is_case_sensitive = TRUE;
    mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;

    mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
    g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
    g_free (regexp);
    return TRUE;
}