4 * User configuration support
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #ifndef lxdream_config_H
20 #define lxdream_config_H 1
22 #include <glib/gtypes.h>
23 #include <glib/glist.h>
30 #define CONFIG_TYPE_NONE 0
31 #define CONFIG_TYPE_FILE 1
32 #define CONFIG_TYPE_PATH 2
33 #define CONFIG_TYPE_KEY 3
34 #define CONFIG_TYPE_FILELIST 4
35 #define CONFIG_TYPE_INTEGER 5
37 #define DEFAULT_CONFIG_FILENAME "lxdreamrc"
39 typedef struct lxdream_config_entry {
41 const gchar *label; // i18n
43 const gchar *default_value;
45 } *lxdream_config_entry_t;
47 typedef struct lxdream_config_group {
49 struct lxdream_config_entry *params;
50 } *lxdream_config_group_t;
52 #define CONFIG_BIOS_PATH 0
53 #define CONFIG_FLASH_PATH 1
54 #define CONFIG_DEFAULT_PATH 2
55 #define CONFIG_SAVE_PATH 3
56 #define CONFIG_VMU_PATH 4
57 #define CONFIG_BOOTSTRAP 5
58 #define CONFIG_GDROM 6
59 #define CONFIG_RECENT 7
61 #define CONFIG_QUICK_STATE 9
62 #define CONFIG_KEY_MAX CONFIG_QUICK_STATE
64 extern struct lxdream_config_group lxdream_config_root[];
66 /* Global config values */
67 const gchar *lxdream_get_global_config_value( int key );
68 const struct lxdream_config_entry * lxdream_get_global_config_entry( int key );
69 void lxdream_set_global_config_value( int key, const gchar *value );
71 void lxdream_register_config_group( const gchar *key, lxdream_config_entry_t group );
72 void lxdream_set_config_value( lxdream_config_entry_t entry, const gchar *value );
73 gboolean lxdream_set_group_value( lxdream_config_group_t group, const gchar *key, const gchar *value );
74 void lxdream_copy_config_list( lxdream_config_entry_t dest, lxdream_config_entry_t src );
77 * Return a fully expanded path value for a key - this performs substitutions
78 * for ~ and simple shell variables ($VAR and ${VAR})
80 * The returned string is newly allocated and must be freed by the caller
82 gchar *lxdream_get_global_config_path_value( int key );
85 * Set a path value for a key, escaping if necessary to protect against
86 * shell-substitution on the round trip.
88 * @return the resultant config value.
90 const gchar *lxdream_set_global_config_path_value( int key, const gchar *value );
93 * Construct a list of strings for the given config key - The caller is
94 * responsible for freeing the list and its values.
96 GList *lxdream_get_global_config_list_value( int key );
99 * Set a config key based on a list of strings.
101 void lxdream_set_global_config_list_value( int key, const GList *list );
103 * Search the standard locations for the configuration file:
106 * $SYSCONF_DIR/lxdreamrc
107 * @return TRUE if the file was found, otherwise FALSE.
109 gboolean lxdream_find_config( );
112 * Set the configuration file filename to the supplied string.
113 * The string is copied internally (ie can be released by the
116 void lxdream_set_config_filename( const gchar *filename );
119 * Load the configuration from the previously determined filename.
121 gboolean lxdream_load_config( );
124 * Update the configuration
126 gboolean lxdream_save_config( );
129 * Make the user configuration directories if they don't already exist.
131 void lxdream_make_config_dir( );
137 #endif /* !lxdream_config_H */
.