mirror of https://github.com/MidnightCommander/mc
lib/mcconfig: fix coding style; apply source file template.
Unconstify some function arguments. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
500e49b50a
commit
0efb799db3
|
@ -1,5 +1,5 @@
|
|||
#ifndef MC_CONFIG_H
|
||||
#define MC_CONFIG_H
|
||||
#ifndef MC__CONFIG_H
|
||||
#define MC__CONFIG_H
|
||||
|
||||
#include "lib/vfs/vfs.h" /* vfs_path_t */
|
||||
|
||||
|
@ -30,89 +30,77 @@ typedef struct mc_config_t
|
|||
mc_config_t *mc_config_init (const gchar * ini_path, gboolean read_only);
|
||||
void mc_config_deinit (mc_config_t * mc_config);
|
||||
|
||||
gboolean mc_config_del_key (mc_config_t *, const char *, const gchar *);
|
||||
gboolean mc_config_del_group (mc_config_t *, const char *);
|
||||
gboolean mc_config_has_param (const mc_config_t * mc_config, const char *group,
|
||||
const gchar * param);
|
||||
gboolean mc_config_has_group (mc_config_t * mc_config, const char *group);
|
||||
|
||||
gboolean mc_config_has_param (const mc_config_t *, const char *, const gchar *);
|
||||
gboolean mc_config_has_group (mc_config_t *, const char *);
|
||||
gboolean mc_config_del_key (mc_config_t * mc_config, const char *group, const gchar * param);
|
||||
gboolean mc_config_del_group (mc_config_t * mc_config, const char *group);
|
||||
|
||||
gboolean mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
|
||||
gboolean remove_empty);
|
||||
|
||||
gboolean mc_config_save_file (mc_config_t * config, GError ** error);
|
||||
|
||||
gboolean mc_config_save_to_file (mc_config_t * config, const gchar * filename, GError ** error);
|
||||
gboolean mc_config_save_file (mc_config_t * config, GError ** mcerror);
|
||||
gboolean mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path,
|
||||
GError ** mcerror);
|
||||
|
||||
|
||||
/* mcconfig/get.c: */
|
||||
|
||||
gchar **mc_config_get_groups (const mc_config_t * mc_config, gsize * len);
|
||||
|
||||
gchar **mc_config_get_keys (const mc_config_t * mc_config, const gchar * group, gsize * len);
|
||||
|
||||
gchar *mc_config_get_string (mc_config_t *, const gchar *, const gchar *, const gchar *);
|
||||
|
||||
gchar *mc_config_get_string_raw (const mc_config_t *, const gchar *, const gchar *, const gchar *);
|
||||
|
||||
gboolean mc_config_get_bool (mc_config_t *, const gchar *, const gchar *, gboolean);
|
||||
|
||||
int mc_config_get_int (mc_config_t *, const gchar *, const gchar *, int);
|
||||
|
||||
gchar *mc_config_get_string (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
const gchar * def);
|
||||
gchar *mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
const gchar * def);
|
||||
gboolean mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
gboolean def);
|
||||
int mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def);
|
||||
|
||||
gchar **mc_config_get_string_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gsize * length);
|
||||
|
||||
gboolean *mc_config_get_bool_list (mc_config_t *, const gchar *, const gchar *, gsize *);
|
||||
|
||||
int *mc_config_get_int_list (mc_config_t *, const gchar *, const gchar *, gsize *);
|
||||
gboolean *mc_config_get_bool_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gsize * length);
|
||||
int *mc_config_get_int_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
gsize * length);
|
||||
|
||||
|
||||
/* mcconfig/set.c: */
|
||||
|
||||
void mc_config_set_string_raw (mc_config_t *, const gchar *, const gchar *, const gchar *);
|
||||
|
||||
void mc_config_set_string_raw_value (mc_config_t *, const gchar *, const gchar *, const gchar *);
|
||||
|
||||
void mc_config_set_string (const mc_config_t *, const gchar *, const gchar *, const gchar *);
|
||||
|
||||
void mc_config_set_bool (mc_config_t *, const gchar *, const gchar *, gboolean);
|
||||
|
||||
void mc_config_set_int (mc_config_t *, const gchar *, const gchar *, int);
|
||||
void mc_config_set_string_raw (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
const gchar * value);
|
||||
void mc_config_set_string_raw_value (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value);
|
||||
void mc_config_set_string (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
const gchar * value);
|
||||
void mc_config_set_bool (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
gboolean value);
|
||||
void mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
int value);
|
||||
|
||||
void
|
||||
mc_config_set_string_list (mc_config_t *, const gchar *,
|
||||
const gchar *, const gchar * const[], gsize);
|
||||
|
||||
void mc_config_set_bool_list (mc_config_t *, const gchar *, const gchar *, gboolean[], gsize);
|
||||
|
||||
void mc_config_set_int_list (mc_config_t *, const gchar *, const gchar *, int[], gsize);
|
||||
|
||||
|
||||
/* mcconfig/dialog.c: */
|
||||
|
||||
void mc_config_show_dialog (void);
|
||||
mc_config_set_string_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
const gchar * const value[], gsize length);
|
||||
void mc_config_set_bool_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
gboolean value[], gsize length);
|
||||
void mc_config_set_int_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
|
||||
int value[], gsize length);
|
||||
|
||||
|
||||
/* mcconfig/paths.c: */
|
||||
|
||||
void mc_config_init_config_paths (GError ** error);
|
||||
|
||||
void mc_config_deinit_config_paths (void);
|
||||
|
||||
gboolean mc_config_migrate_from_old_place (GError ** error, char **msg);
|
||||
|
||||
const char *mc_config_get_data_path (void);
|
||||
|
||||
const char *mc_config_get_cache_path (void);
|
||||
|
||||
const char *mc_config_get_path (void);
|
||||
|
||||
const char *mc_config_get_home_dir (void);
|
||||
|
||||
const char *mc_config_get_path (void);
|
||||
char *mc_config_get_full_path (const char *config_name);
|
||||
|
||||
vfs_path_t *mc_config_get_full_vpath (const char *config_name);
|
||||
|
||||
gboolean mc_config_migrate_from_old_place (GError ** mcerror, char **msg);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif
|
||||
#endif /* MC__CONFIG_H */
|
||||
|
|
|
@ -30,18 +30,20 @@
|
|||
#include "lib/global.h"
|
||||
#include "lib/vfs/vfs.h" /* mc_stat */
|
||||
#include "lib/util.h"
|
||||
|
||||
#include "lib/mcconfig.h"
|
||||
|
||||
/*** global variables **************************************************/
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables **********************************************/
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path, GError ** mcerror)
|
||||
|
@ -80,6 +82,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
|
|||
(cur_written = mc_write (fd, (const void *) written_data, total_written)) > 0;
|
||||
written_data += cur_written, total_written -= cur_written)
|
||||
;
|
||||
|
||||
mc_close (fd);
|
||||
g_free (data);
|
||||
|
||||
|
@ -94,9 +97,9 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/*** public functions **************************************************/
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
mc_config_t *
|
||||
mc_config_init (const gchar * ini_path, gboolean read_only)
|
||||
|
@ -105,7 +108,6 @@ mc_config_init (const gchar * ini_path, gboolean read_only)
|
|||
struct stat st;
|
||||
|
||||
mc_config = g_try_malloc0 (sizeof (mc_config_t));
|
||||
|
||||
if (mc_config == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -115,6 +117,7 @@ mc_config_init (const gchar * ini_path, gboolean read_only)
|
|||
g_free (mc_config);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ini_path == NULL)
|
||||
return mc_config;
|
||||
|
||||
|
@ -140,7 +143,7 @@ mc_config_init (const gchar * ini_path, gboolean read_only)
|
|||
return mc_config;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_deinit (mc_config_t * mc_config)
|
||||
|
@ -153,51 +156,51 @@ mc_config_deinit (mc_config_t * mc_config)
|
|||
}
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_has_param (const mc_config_t * mc_config, const char *group, const gchar * param)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return FALSE;
|
||||
|
||||
return g_key_file_has_key (mc_config->handle, group, param, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_has_group (mc_config_t * mc_config, const char *group)
|
||||
{
|
||||
if (!mc_config || !group)
|
||||
if (mc_config == NULL || group == NULL)
|
||||
return FALSE;
|
||||
|
||||
return g_key_file_has_group (mc_config->handle, group);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_del_key (mc_config_t * mc_config, const char *group, const gchar * param)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return FALSE;
|
||||
|
||||
return g_key_file_remove_key (mc_config->handle, group, param, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_del_group (mc_config_t * mc_config, const char *group)
|
||||
{
|
||||
if (!mc_config || !group)
|
||||
if (mc_config == NULL || group == NULL)
|
||||
return FALSE;
|
||||
|
||||
return g_key_file_remove_group (mc_config->handle, group, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
|
||||
|
@ -247,7 +250,7 @@ mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean r
|
|||
return ok;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_save_file (mc_config_t * mc_config, GError ** mcerror)
|
||||
|
@ -260,7 +263,7 @@ mc_config_save_file (mc_config_t * mc_config, GError ** mcerror)
|
|||
return mc_config_new_or_override_file (mc_config, mc_config->ini_path, mcerror);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path, GError ** mcerror)
|
||||
|
@ -271,7 +274,6 @@ mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path, GError
|
|||
return FALSE;
|
||||
|
||||
return mc_config_new_or_override_file (mc_config, ini_path, mcerror);
|
||||
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -24,19 +24,26 @@
|
|||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
|
||||
#include "lib/mcconfig.h"
|
||||
|
||||
/*** global variables **************************************************/
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables **********************************************/
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
/*** file scope functions ************************************************************************/
|
||||
|
||||
/*** public functions **************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gchar **
|
||||
mc_config_get_groups (const mc_config_t * mc_config, gsize * len)
|
||||
|
@ -56,7 +63,7 @@ mc_config_get_groups (const mc_config_t * mc_config, gsize * len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gchar **
|
||||
mc_config_get_keys (const mc_config_t * mc_config, const gchar * group, gsize * len)
|
||||
|
@ -76,7 +83,7 @@ mc_config_get_keys (const mc_config_t * mc_config, const gchar * group, gsize *
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gchar *
|
||||
mc_config_get_string (mc_config_t * mc_config, const gchar * group,
|
||||
|
@ -87,7 +94,7 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
|
|||
gchar *ret;
|
||||
estr_t conv_res;
|
||||
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return g_strdup (def);
|
||||
|
||||
if (!mc_config_has_param (mc_config, group, param))
|
||||
|
@ -123,15 +130,15 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
|
|||
return g_string_free (buffer, FALSE);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gchar *
|
||||
mc_config_get_string_raw (const mc_config_t * mc_config, const gchar * group,
|
||||
mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * def)
|
||||
{
|
||||
gchar *ret;
|
||||
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return g_strdup (def);
|
||||
|
||||
if (!mc_config_has_param (mc_config, group, param))
|
||||
|
@ -146,12 +153,12 @@ mc_config_get_string_raw (const mc_config_t * mc_config, const gchar * group,
|
|||
return ret != NULL ? ret : g_strdup (def);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param, gboolean def)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return def;
|
||||
|
||||
if (!mc_config_has_param (mc_config, group, param))
|
||||
|
@ -163,12 +170,12 @@ mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar *
|
|||
return g_key_file_get_boolean (mc_config->handle, group, param, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return def;
|
||||
|
||||
if (!mc_config_has_param (mc_config, group, param))
|
||||
|
@ -180,41 +187,40 @@ mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * p
|
|||
return g_key_file_get_integer (mc_config->handle, group, param, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gchar **
|
||||
mc_config_get_string_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gsize * length)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_key_file_get_string_list (mc_config->handle, group, param, length, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean *
|
||||
mc_config_get_bool_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gsize * length)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_key_file_get_boolean_list (mc_config->handle, group, param, length, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int *
|
||||
mc_config_get_int_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gsize * length)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
if (mc_config == NULL || group == NULL || param == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_key_file_get_integer_list (mc_config->handle, group, param, length, NULL);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -127,6 +127,7 @@ static const struct
|
|||
};
|
||||
#endif /* MC_HOMEDIR_XDG */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions *********************************************************************** */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -150,12 +151,11 @@ mc_config_init_one_config_path (const char *path_base, const char *subdir, GErro
|
|||
mc_return_val_if_error (mcerror, FALSE);
|
||||
|
||||
full_path = g_build_filename (path_base, subdir, (char *) NULL);
|
||||
|
||||
if (g_file_test (full_path, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
if (g_file_test (full_path, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
config_dir_present = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s %s\n", _("FATAL: not a directory:"), full_path);
|
||||
|
@ -199,7 +199,6 @@ mc_config_copy (const char *old_name, const char *new_name, GError ** mcerror)
|
|||
|
||||
if (g_file_test (old_name, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
|
||||
GDir *dir;
|
||||
const char *dir_name;
|
||||
|
||||
|
@ -255,6 +254,7 @@ mc_config_fix_migrated_rules (void)
|
|||
rename (old_name, new_name);
|
||||
g_free (new_name);
|
||||
}
|
||||
|
||||
g_free (old_name);
|
||||
}
|
||||
}
|
||||
|
@ -405,6 +405,7 @@ mc_config_get_home_dir (void)
|
|||
if (homedir == NULL || *homedir == '\0')
|
||||
homedir = g_get_home_dir ();
|
||||
}
|
||||
|
||||
return homedir;
|
||||
}
|
||||
|
||||
|
@ -445,6 +446,7 @@ mc_config_migrate_from_old_place (GError ** mcerror, char **msg)
|
|||
for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++)
|
||||
{
|
||||
char *old_name;
|
||||
|
||||
if (*mc_config_files_reference[rule_index].old_filename == '\0')
|
||||
continue;
|
||||
|
||||
|
@ -462,6 +464,7 @@ mc_config_migrate_from_old_place (GError ** mcerror, char **msg)
|
|||
mc_config_copy (old_name, new_name, mcerror);
|
||||
g_free (new_name);
|
||||
}
|
||||
|
||||
g_free (old_name);
|
||||
}
|
||||
|
||||
|
@ -501,14 +504,11 @@ mc_config_get_full_path (const char *config_name)
|
|||
mc_config_init_config_paths (NULL);
|
||||
|
||||
for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++)
|
||||
{
|
||||
if (strcmp (config_name, mc_config_files_reference[rule_index].new_filename) == 0)
|
||||
{
|
||||
return g_build_filename (*mc_config_files_reference[rule_index].new_basedir,
|
||||
mc_config_files_reference[rule_index].new_filename,
|
||||
(char *) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -530,6 +530,7 @@ mc_config_get_full_vpath (const char *config_name)
|
|||
|
||||
ret_vpath = vfs_path_from_str (str_path);
|
||||
g_free (str_path);
|
||||
|
||||
return ret_vpath;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,18 +24,20 @@
|
|||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
|
||||
#include "lib/mcconfig.h"
|
||||
|
||||
/*** global variables **************************************************/
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables **********************************************/
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gchar *
|
||||
mc_config_normalize_before_save (const gchar * value)
|
||||
|
@ -65,109 +67,91 @@ mc_config_normalize_before_save (const gchar * value)
|
|||
return g_string_free (buffer, FALSE);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/*** public functions **************************************************/
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_string_raw (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value)
|
||||
{
|
||||
if (!mc_config || !group || !param || !value)
|
||||
return;
|
||||
|
||||
g_key_file_set_string (mc_config->handle, group, param, value);
|
||||
if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
|
||||
g_key_file_set_string (mc_config->handle, group, param, value);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_string_raw_value (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value)
|
||||
{
|
||||
if (!mc_config || !group || !param || !value)
|
||||
return;
|
||||
|
||||
g_key_file_set_value (mc_config->handle, group, param, value);
|
||||
if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
|
||||
g_key_file_set_value (mc_config->handle, group, param, value);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_string (const mc_config_t * mc_config, const gchar * group,
|
||||
mc_config_set_string (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value)
|
||||
{
|
||||
gchar *buffer;
|
||||
if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
|
||||
{
|
||||
gchar *buffer;
|
||||
|
||||
if (!mc_config || !group || !param || !value)
|
||||
return;
|
||||
|
||||
buffer = mc_config_normalize_before_save (value);
|
||||
|
||||
g_key_file_set_string (mc_config->handle, group, param, buffer);
|
||||
|
||||
g_free (buffer);
|
||||
buffer = mc_config_normalize_before_save (value);
|
||||
g_key_file_set_string (mc_config->handle, group, param, buffer);
|
||||
g_free (buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_bool (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gboolean value)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
return;
|
||||
|
||||
g_key_file_set_boolean (mc_config->handle, group, param, value);
|
||||
if (mc_config != NULL && group != NULL && param != NULL)
|
||||
g_key_file_set_boolean (mc_config->handle, group, param, value);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int value)
|
||||
{
|
||||
if (!mc_config || !group || !param)
|
||||
return;
|
||||
|
||||
g_key_file_set_integer (mc_config->handle, group, param, value);
|
||||
if (mc_config != NULL && group != NULL && param != NULL)
|
||||
g_key_file_set_integer (mc_config->handle, group, param, value);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_string_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * const value[], gsize length)
|
||||
{
|
||||
if (!mc_config || !group || !param || !value || length == 0)
|
||||
return;
|
||||
|
||||
g_key_file_set_string_list (mc_config->handle, group, param, value, length);
|
||||
if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
|
||||
g_key_file_set_string_list (mc_config->handle, group, param, value, length);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_bool_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, gboolean value[], gsize length)
|
||||
{
|
||||
if (!mc_config || !group || !param || !value || length == 0)
|
||||
return;
|
||||
|
||||
g_key_file_set_boolean_list (mc_config->handle, group, param, value, length);
|
||||
if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
|
||||
g_key_file_set_boolean_list (mc_config->handle, group, param, value, length);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_set_int_list (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, int value[], gsize length)
|
||||
{
|
||||
if (!mc_config || !group || !param || !value || length == 0)
|
||||
return;
|
||||
|
||||
g_key_file_set_integer_list (mc_config->handle, group, param, value, length);
|
||||
if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
|
||||
g_key_file_set_integer_list (mc_config->handle, group, param, value, length);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -193,7 +193,7 @@ mc_deserialize_str (const char prefix, const char *data, GError ** error)
|
|||
*/
|
||||
|
||||
char *
|
||||
mc_serialize_config (const mc_config_t * data, GError ** error)
|
||||
mc_serialize_config (mc_config_t * data, GError ** error)
|
||||
{
|
||||
gchar **groups, **group_iterator;
|
||||
GString *buffer;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
char *mc_serialize_str (const char prefix, const char *data, GError ** error);
|
||||
char *mc_deserialize_str (const char prefix, const char *data, GError ** error);
|
||||
|
||||
char *mc_serialize_config (const mc_config_t * data, GError ** error);
|
||||
char *mc_serialize_config (mc_config_t * data, GError ** error);
|
||||
mc_config_t *mc_deserialize_config (const char *data, GError ** error);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
|
|
@ -48,7 +48,7 @@ static GPtrArray *mc_config_get_string__return_value;
|
|||
|
||||
/* @Mock */
|
||||
gchar *
|
||||
mc_config_get_string_raw (const mc_config_t * config_ignored, const gchar * group,
|
||||
mc_config_get_string_raw (mc_config_t * config_ignored, const gchar * group,
|
||||
const gchar * param, const gchar * default_value)
|
||||
{
|
||||
char *return_value;
|
||||
|
|
Loading…
Reference in New Issue