1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
28
typedef struct _GdmConfig GdmConfig;
31
GDM_CONFIG_VALUE_INVALID,
32
GDM_CONFIG_VALUE_BOOL,
34
GDM_CONFIG_VALUE_STRING,
35
GDM_CONFIG_VALUE_LOCALE_STRING,
36
GDM_CONFIG_VALUE_STRING_ARRAY,
37
GDM_CONFIG_VALUE_LOCALE_STRING_ARRAY,
41
GDM_CONFIG_SOURCE_INVALID,
42
GDM_CONFIG_SOURCE_MANDATORY,
43
GDM_CONFIG_SOURCE_DEFAULT,
44
GDM_CONFIG_SOURCE_CUSTOM,
45
GDM_CONFIG_SOURCE_BUILT_IN,
46
GDM_CONFIG_SOURCE_RUNTIME_USER,
47
} GdmConfigSourceType;
49
#define GDM_CONFIG_INVALID_ID -1
51
struct _GdmConfigValue
53
GdmConfigValueType type;
56
typedef struct _GdmConfigValue GdmConfigValue;
58
typedef gboolean (* GdmConfigFunc) (GdmConfig *config,
59
GdmConfigSourceType source,
62
GdmConfigValue *value,
69
GdmConfigValueType type;
74
#define GDM_CONFIG_ERROR (gdm_config_error_quark ())
78
GDM_CONFIG_ERROR_UNKNOWN_OPTION,
79
GDM_CONFIG_ERROR_BAD_VALUE,
80
GDM_CONFIG_ERROR_PARSE_ERROR,
81
GDM_CONFIG_ERROR_FAILED
84
GQuark gdm_config_error_quark (void);
86
GdmConfig * gdm_config_new (void);
87
void gdm_config_free (GdmConfig *config);
89
void gdm_config_set_validate_func (GdmConfig *config,
92
void gdm_config_set_notify_func (GdmConfig *config,
95
void gdm_config_set_default_file (GdmConfig *config,
97
void gdm_config_set_mandatory_file (GdmConfig *config,
99
void gdm_config_set_custom_file (GdmConfig *config,
101
void gdm_config_add_entry (GdmConfig *config,
102
const GdmConfigEntry *entry);
103
void gdm_config_add_static_entries (GdmConfig *config,
104
const GdmConfigEntry *entries);
105
const GdmConfigEntry * gdm_config_lookup_entry (GdmConfig *config,
108
const GdmConfigEntry * gdm_config_lookup_entry_for_id (GdmConfig *config,
111
gboolean gdm_config_load (GdmConfig *config,
113
gboolean gdm_config_process_all (GdmConfig *config,
115
gboolean gdm_config_process_entry (GdmConfig *config,
116
const GdmConfigEntry *entry,
118
gboolean gdm_config_process_entries (GdmConfig *config,
119
const GdmConfigEntry **entries,
123
gboolean gdm_config_save_custom_file (GdmConfig *config,
125
char ** gdm_config_get_keys_for_group (GdmConfig *config,
126
const gchar *group_name,
129
GPtrArray * gdm_config_get_server_groups (GdmConfig *config);
131
gboolean gdm_config_peek_value (GdmConfig *config,
134
const GdmConfigValue **value);
135
gboolean gdm_config_get_value (GdmConfig *config,
138
GdmConfigValue **value);
139
gboolean gdm_config_set_value (GdmConfig *config,
142
GdmConfigValue *value);
144
/* convenience functions */
145
gboolean gdm_config_get_value_for_id (GdmConfig *config,
147
GdmConfigValue **value);
148
gboolean gdm_config_set_value_for_id (GdmConfig *config,
150
GdmConfigValue *value);
152
gboolean gdm_config_peek_string_for_id (GdmConfig *config,
155
gboolean gdm_config_get_string_for_id (GdmConfig *config,
158
gboolean gdm_config_get_bool_for_id (GdmConfig *config,
161
gboolean gdm_config_get_int_for_id (GdmConfig *config,
164
gboolean gdm_config_set_string_for_id (GdmConfig *config,
167
gboolean gdm_config_set_bool_for_id (GdmConfig *config,
170
gboolean gdm_config_set_int_for_id (GdmConfig *config,
176
GdmConfigValue * gdm_config_value_new (GdmConfigValueType type);
177
void gdm_config_value_free (GdmConfigValue *value);
178
GdmConfigValue * gdm_config_value_copy (const GdmConfigValue *value);
179
int gdm_config_value_compare (const GdmConfigValue *value_a,
180
const GdmConfigValue *value_b);
182
GdmConfigValue * gdm_config_value_new_from_string (GdmConfigValueType type,
185
const char * gdm_config_value_get_string (const GdmConfigValue *value);
186
const char * gdm_config_value_get_locale_string (const GdmConfigValue *value);
187
const char ** gdm_config_value_get_string_array (const GdmConfigValue *value);
189
int gdm_config_value_get_int (const GdmConfigValue *value);
190
gboolean gdm_config_value_get_bool (const GdmConfigValue *value);
192
void gdm_config_value_set_string (GdmConfigValue *value,
194
void gdm_config_value_set_locale_string (GdmConfigValue *value,
197
void gdm_config_value_set_string_array (GdmConfigValue *value,
199
void gdm_config_value_set_locale_string_array (GdmConfigValue *value,
201
void gdm_config_value_set_int (GdmConfigValue *value,
203
void gdm_config_value_set_bool (GdmConfigValue *value,
205
char * gdm_config_value_to_string (const GdmConfigValue *value);
208
GdmConfigEntry * gdm_config_entry_copy (const GdmConfigEntry *entry);
209
void gdm_config_entry_free (GdmConfigEntry *entry);
213
#endif /* _GDM_CONFIG_H */