00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef _XLV_CONFIG_H
00029 #define _XLV_CONFIG_H
00030
00031 #include <glib.h>
00032 #include <stdio.h>
00033
00034 #define XLV_CONFIG_HOME_DIR ".xlv"
00035 #define XLV_CONFIG_ETC_DIR "xlv"
00036
00042 typedef struct _XLV_ConfigSection XLV_ConfigSection;
00044 typedef struct _XLV_ConfigKey XLV_ConfigKey;
00046 typedef struct _XLV_Config XLV_Config;
00047
00049 typedef struct _XLV_ConfigOptions XLV_ConfigOptions;
00051 typedef struct _XLV_ConfigOptions_Section XLV_ConfigOptions_Section;
00053 typedef struct _XLV_ConfigOptions_Key XLV_ConfigOptions_Key;
00054
00057 struct _XLV_Config {
00058 gchar *m_filename;
00059 FILE *m_fd;
00060 GList *m_sections;
00061 };
00062
00065 struct _XLV_ConfigSection {
00066 XLV_Config *m_config;
00067 XLV_ConfigSection *m_next_section;
00068
00070 gchar *m_section_name;
00071 GList *m_keys;
00072 };
00073
00076 struct _XLV_ConfigKey {
00077 XLV_ConfigSection *m_section;
00081 XLV_ConfigKey *m_next_key;
00083 guint8 *m_keyname;
00085 guint8 m_keytype;
00086
00088 union {
00090 gpointer data;
00092 guint32 i;
00094 gfloat f;
00095 } m_keydata;
00096 #define XLV_CONFIG_KEY_STRING 0
00097 #define XLV_CONFIG_KEY_INT 1
00098 #define XLV_CONFIG_KEY_FLOAT 2
00099 #define XLV_CONFIG_KEY_UNDEF 3
00100 };
00101
00102 struct _XLV_ConfigOptions_Key {
00103 const gchar *m_key_name;
00104 guint8 m_type_expected;
00105 gpointer m_data;
00106 };
00107
00108 struct _XLV_ConfigOptions_Section {
00109 const gchar *m_section_name;
00110 XLV_ConfigOptions_Key *m_keys;
00111 };
00112
00113 struct _XLV_ConfigOptions {
00114 XLV_ConfigOptions_Section *m_sections;
00115 };
00116
00117 #ifdef __cplusplus
00118 extern "C" {
00119 #endif
00120
00127 gchar *xlv_config_check_file (const gchar * filename,
00128 gboolean force_local);
00129
00137 XLV_Config *xlv_config_file_new (const gchar * filename);
00138
00145 void xlv_config_release (XLV_Config * config, gboolean flush);
00146
00156 XLV_ConfigSection *xlv_config_get_section (XLV_Config * config,
00157 const guint8 * section_name);
00158
00166 XLV_ConfigKey *xlv_config_get_key (XLV_ConfigSection * section,
00167 const guint8 * section_key);
00168
00180 XLV_ConfigSection *xlv_config_next_section (XLV_Config * config,
00181 XLV_ConfigSection * section);
00182
00193 XLV_ConfigKey *xlv_config_next_key (XLV_ConfigSection * section,
00194 XLV_ConfigKey * key);
00195
00201 void xlv_config_get_options (XLV_Config * config,
00202 XLV_ConfigOptions * options);
00203
00204 #ifdef __cplusplus
00205 }
00206 #endif
00207
00210 #endif