Removed calls to strerror() function from own libsamba implementation.
[midnight-commander.git] / src / filehighlight / common.c
blobcd5f0aa97712104fc5db8f073dd97bc6e71d21f4
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>
31 #include "../src/global.h"
32 #include "../src/filehighlight/fhl.h"
33 #include "internal.h"
35 /*** global variables ****************************************************************************/
37 /*** file scope macro definitions ****************************************************************/
39 /*** file scope type declarations ****************************************************************/
41 /*** file scope variables ************************************************************************/
43 /*** file scope functions ************************************************************************/
44 /* --------------------------------------------------------------------------------------------- */
46 void
47 mc_fhl_array_free (mc_fhl_t * fhl)
49 guint i;
50 mc_fhl_filter_t *mc_filter;
52 if (fhl->filters == NULL)
53 return;
55 for (i = 0; i < fhl->filters->len; i++) {
56 mc_filter = (mc_fhl_filter_t *) g_ptr_array_index (fhl->filters, i);
58 g_free (mc_filter->fgcolor);
59 g_free (mc_filter->bgcolor);
61 if (mc_filter->search_condition != NULL)
62 mc_search_free (mc_filter->search_condition);
64 g_free (mc_filter);
66 g_ptr_array_free (fhl->filters, TRUE);
67 fhl->filters = NULL;
70 /* --------------------------------------------------------------------------------------------- */
71 /*** public functions ****************************************************************************/
72 /* --------------------------------------------------------------------------------------------- */
74 mc_fhl_t *
75 mc_fhl_new (gboolean need_auto_fill)
78 mc_fhl_t *fhl;
80 fhl = g_try_new0 (mc_fhl_t, 1);
81 if (fhl == NULL)
82 return NULL;
84 if (!need_auto_fill)
85 return fhl;
87 if (!mc_fhl_init_from_standart_files (fhl)) {
88 g_free (fhl);
89 return NULL;
92 if (!mc_fhl_parse_ini_file (fhl)) {
93 mc_fhl_free (&fhl);
94 return NULL;
97 return fhl;
100 /* --------------------------------------------------------------------------------------------- */
102 void
103 mc_fhl_free (mc_fhl_t ** fhl)
105 if (fhl == NULL || *fhl == NULL)
106 return;
108 mc_fhl_clear (*fhl);
110 g_free (*fhl);
111 *fhl = NULL;
114 /* --------------------------------------------------------------------------------------------- */
116 void
117 mc_fhl_clear (mc_fhl_t * fhl)
119 if (fhl == NULL)
120 return;
122 if (fhl->config)
123 mc_config_deinit (fhl->config);
125 mc_fhl_array_free (fhl);
128 /* --------------------------------------------------------------------------------------------- */