root/lib/mcconfig.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 #ifndef MC__CONFIG_H
   2 #define MC__CONFIG_H
   3 
   4 #include "lib/vfs/vfs.h"  // vfs_path_t
   5 
   6 /*** typedefs(not structures) and defined constants **********************************************/
   7 
   8 #define CONFIG_APP_SECTION               "Midnight-Commander"
   9 #define CONFIG_PANELS_SECTION            "Panels"
  10 #define CONFIG_LAYOUT_SECTION            "Layout"
  11 #define CONFIG_MISC_SECTION              "Misc"
  12 #define CONFIG_EXT_EDITOR_VIEWER_SECTION "External editor or viewer parameters"
  13 
  14 /*** enums ***************************************************************************************/
  15 
  16 /*** structures declarations (and typedefs of structures)*****************************************/
  17 
  18 typedef struct mc_config_t
  19 {
  20     GKeyFile *handle;
  21     gchar *ini_path;
  22 } mc_config_t;
  23 
  24 /*** global variables defined in .c file *********************************************************/
  25 
  26 extern int num_history_items_recorded;
  27 
  28 /*** declarations of public functions ************************************************************/
  29 
  30 /* mcconfig/common.c: */
  31 
  32 mc_config_t *mc_config_init (const gchar *ini_path, gboolean read_only);
  33 void mc_config_deinit (mc_config_t *mc_config);
  34 
  35 gboolean mc_config_has_param (const mc_config_t *mc_config, const char *group, const gchar *param);
  36 gboolean mc_config_has_group (mc_config_t *mc_config, const char *group);
  37 
  38 gboolean mc_config_del_key (mc_config_t *mc_config, const char *group, const gchar *param);
  39 gboolean mc_config_del_group (mc_config_t *mc_config, const char *group);
  40 
  41 gboolean mc_config_read_file (mc_config_t *mc_config, const gchar *ini_path, gboolean read_only,
  42                               gboolean remove_empty);
  43 gboolean mc_config_save_file (mc_config_t *config, GError **mcerror);
  44 gboolean mc_config_save_to_file (mc_config_t *mc_config, const gchar *ini_path, GError **mcerror);
  45 
  46 /* mcconfig/get.c: */
  47 
  48 gchar **mc_config_get_groups (const mc_config_t *mc_config, gsize *len);
  49 gchar **mc_config_get_keys (const mc_config_t *mc_config, const gchar *group, gsize *len);
  50 
  51 gchar *mc_config_get_string (mc_config_t *mc_config, const gchar *group, const gchar *param,
  52                              const gchar *def);
  53 MC_MOCKABLE gchar *mc_config_get_string_raw (mc_config_t *mc_config, const gchar *group,
  54                                              const gchar *param, const gchar *def);
  55 gboolean mc_config_get_bool (mc_config_t *mc_config, const gchar *group, const gchar *param,
  56                              gboolean def);
  57 int mc_config_get_int (mc_config_t *mc_config, const gchar *group, const gchar *param, int def);
  58 
  59 gchar **mc_config_get_string_list (mc_config_t *mc_config, const gchar *group, const gchar *param,
  60                                    gsize *length);
  61 gboolean *mc_config_get_bool_list (mc_config_t *mc_config, const gchar *group, const gchar *param,
  62                                    gsize *length);
  63 int *mc_config_get_int_list (mc_config_t *mc_config, const gchar *group, const gchar *param,
  64                              gsize *length);
  65 
  66 /* mcconfig/set.c: */
  67 
  68 void mc_config_set_string_raw (mc_config_t *mc_config, const gchar *group, const gchar *param,
  69                                const gchar *value);
  70 void mc_config_set_string_raw_value (mc_config_t *mc_config, const gchar *group, const gchar *param,
  71                                      const gchar *value);
  72 void mc_config_set_string (mc_config_t *mc_config, const gchar *group, const gchar *param,
  73                            const gchar *value);
  74 void mc_config_set_bool (mc_config_t *mc_config, const gchar *group, const gchar *param,
  75                          gboolean value);
  76 void mc_config_set_int (mc_config_t *mc_config, const gchar *group, const gchar *param, int value);
  77 
  78 void mc_config_set_string_list (mc_config_t *mc_config, const gchar *group, const gchar *param,
  79                                 const gchar *const value[], gsize length);
  80 void mc_config_set_bool_list (mc_config_t *mc_config, const gchar *group, const gchar *param,
  81                               gboolean value[], gsize length);
  82 void mc_config_set_int_list (mc_config_t *mc_config, const gchar *group, const gchar *param,
  83                              int value[], gsize length);
  84 
  85 /* mcconfig/paths.c: */
  86 
  87 void mc_config_init_config_paths (GError **error);
  88 void mc_config_deinit_config_paths (void);
  89 
  90 const char *mc_config_get_data_path (void);
  91 const char *mc_config_get_cache_path (void);
  92 MC_MOCKABLE const char *mc_config_get_home_dir (void);
  93 const char *mc_config_get_path (void);
  94 char *mc_config_get_full_path (const char *config_name);
  95 vfs_path_t *mc_config_get_full_vpath (const char *config_name);
  96 
  97 /* mcconfig/history.h */
  98 
  99 /* read history to the mc_config, but don't save config to file */
 100 GList *mc_config_history_get (const char *name);
 101 /* read recent item from the history */
 102 char *mc_config_history_get_recent_item (const char *name);
 103 /* load history from the mc_config */
 104 GList *mc_config_history_load (mc_config_t *cfg, const char *name);
 105 /* save history to the mc_config, but don't save config to file */
 106 void mc_config_history_save (mc_config_t *cfg, const char *name, GList *h);
 107 
 108 /*** inline functions ****************************************************************************/
 109 
 110 #endif

/* [previous][next][first][last][top][bottom][index][help]  */