Added locale setting before calling dpkg to fix "link to" parsing on non-C locales
[midnight-commander.git] / lib / filehighlight / common.c
blob9a335d295ef4e92719c4ebce31ddf1dc2bd6fa46
1 /*
2 File highlight plugin.
3 Interface functions
5 Copyright (C) 2009 The Free Software Foundation, Inc.
7 Written by:
8 Slava Zanko <slavazanko@gmail.com>, 2009.
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software; you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of the
15 License, or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be
18 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 MA 02110-1301, USA.
28 #include <config.h>
30 #include "lib/global.h"
31 #include "lib/filehighlight.h"
32 #include "internal.h"
34 /*** global variables ****************************************************************************/
36 /*** file scope macro definitions ****************************************************************/
38 /*** file scope type declarations ****************************************************************/
40 /*** file scope variables ************************************************************************/
42 /*** file scope functions ************************************************************************/
44 static void
45 mc_fhl_filter_free (void *data)
47 mc_fhl_filter_t *filter = (mc_fhl_filter_t *) data;
49 g_free (filter->fgcolor);
50 g_free (filter->bgcolor);
51 mc_search_free (filter->search_condition);
52 g_free (filter);
55 /* --------------------------------------------------------------------------------------------- */
57 void
58 mc_fhl_array_free (mc_fhl_t * fhl)
60 if (fhl->filters != NULL)
62 g_ptr_array_foreach (fhl->filters, (GFunc) mc_fhl_filter_free, NULL);
63 fhl->filters = (GPtrArray *) g_ptr_array_free (fhl->filters, TRUE);
67 /* --------------------------------------------------------------------------------------------- */
68 /*** public functions ****************************************************************************/
69 /* --------------------------------------------------------------------------------------------- */
71 mc_fhl_t *
72 mc_fhl_new (gboolean need_auto_fill)
74 mc_fhl_t *fhl;
76 fhl = g_try_new0 (mc_fhl_t, 1);
77 if (fhl == NULL)
78 return NULL;
80 if (!need_auto_fill)
81 return fhl;
83 if (!mc_fhl_init_from_standard_files (fhl))
85 g_free (fhl);
86 return NULL;
89 if (!mc_fhl_parse_ini_file (fhl))
91 mc_fhl_free (&fhl);
92 return NULL;
95 return fhl;
98 /* --------------------------------------------------------------------------------------------- */
100 void
101 mc_fhl_free (mc_fhl_t ** fhl)
103 if (fhl == NULL || *fhl == NULL)
104 return;
106 mc_fhl_clear (*fhl);
108 g_free (*fhl);
109 *fhl = NULL;
112 /* --------------------------------------------------------------------------------------------- */
114 void
115 mc_fhl_clear (mc_fhl_t * fhl)
117 if (fhl != NULL)
119 mc_config_deinit (fhl->config);
120 mc_fhl_array_free (fhl);
124 /* --------------------------------------------------------------------------------------------- */