summaryrefslogtreecommitdiffstats
path: root/lib/mcconfig.h
blob: abc28efe8793c4986a9f776a8dd692e25ce0093d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef MC__CONFIG_H
#define MC__CONFIG_H

#include "lib/vfs/vfs.h"        /* vfs_path_t */

/*** typedefs(not structures) and defined constants **********************************************/

#define CONFIG_APP_SECTION "Midnight-Commander"
#define CONFIG_PANELS_SECTION "Panels"
#define CONFIG_LAYOUT_SECTION "Layout"
#define CONFIG_MISC_SECTION "Misc"
#define CONFIG_EXT_EDITOR_VIEWER_SECTION "External editor or viewer parameters"

/*** enums ***************************************************************************************/

/*** structures declarations (and typedefs of structures)*****************************************/

typedef struct mc_config_t
{
    GKeyFile *handle;
    gchar *ini_path;
} mc_config_t;

/*** global variables defined in .c file *********************************************************/

extern int num_history_items_recorded;

/*** declarations of public functions ************************************************************/

/* mcconfig/common.c: */

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_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_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 ** 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 * 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 * 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 * 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 * 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);

const char *mc_config_get_data_path (void);
const char *mc_config_get_cache_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);

/* mcconfig/history.h */

/* read history to the mc_config, but don't save config to file */
GList *mc_config_history_get (const char *name);
/* read recent item from the history */
char *mc_config_history_get_recent_item (const char *name);
/* load history from the mc_config */
GList *mc_config_history_load (mc_config_t * cfg, const char *name);
/* save history to the mc_config, but don't save config to file */
void mc_config_history_save (mc_config_t * cfg, const char *name, GList * h);


/*** inline functions ****************************************************************************/

#endif /* MC__CONFIG_H */