Lines Matching defs:config
42 #include "osi/include/config.h"
79 static void btif_config_remove_unpaired(config_t *config);
80 static void btif_config_remove_restricted(config_t *config);
133 static pthread_mutex_t lock; // protects operations on |config|.
134 static config_t *config;
148 config = btif_config_open(CONFIG_FILE_PATH);
150 if (!config) {
151 LOG_WARN("%s unable to load config file: %s; using backup.",
153 config = btif_config_open(CONFIG_BACKUP_PATH);
157 if (!config) {
159 config = btif_config_transcode(CONFIG_LEGACY_FILE_PATH);
163 if (!config) {
164 LOG_ERROR("%s unable to transcode legacy file; creating empty config.", __func__);
165 config = config_new_empty();
171 config_set_string(config, INFO_SECTION, FILE_SOURCE, file_source);
173 if (!config) {
174 LOG_ERROR("%s unable to allocate a config object.", __func__);
178 btif_config_remove_unpaired(config);
182 btif_config_remove_restricted(config);
184 // Read or set config file creation timestamp
185 const char* time_str = config_get_string(config, INFO_SECTION, FILE_TIMESTAMP, NULL);
192 config_set_string(config, INFO_SECTION, FILE_TIMESTAMP, btif_config_time_created);
198 config_timer = alarm_new("btif.config");
211 config_free(config);
215 config = NULL;
221 config_t *config = config_new(filename);
222 if (!config)
225 if (!config_has_section(config, "Adapter")) {
226 LOG_ERROR(LOG_TAG, "Config is missing adapter section");
227 config_free(config);
231 return config;
243 config_free(config);
246 config = NULL;
262 assert(config != NULL);
266 bool ret = config_has_section(config, section);
273 assert(config != NULL);
278 bool ret = config_has_key(config, section, key);
285 assert(config != NULL);
291 bool ret = config_has_key(config, section, key);
293 *value = config_get_int(config, section, key, *value);
300 assert(config != NULL);
305 config_set_int(config, section, key, value);
312 assert(config != NULL);
319 const char *stored_value = config_get_string(config, section, key, NULL);
332 assert(config != NULL);
338 config_set_string(config, section, key, value);
345 assert(config != NULL);
352 const char *value_str = config_get_string(config, section, key, NULL);
373 assert(config != NULL);
378 const char *value_str = config_get_string(config, section, key, NULL);
391 assert(config != NULL);
406 config_set_string(config, section, key, str);
414 assert(config != NULL);
415 return (const btif_config_section_iter_t *)config_section_begin(config);
419 assert(config != NULL);
420 return (const btif_config_section_iter_t *)config_section_end(config);
424 assert(config != NULL);
430 assert(config != NULL);
436 assert(config != NULL);
441 bool ret = config_remove_key(config, section, key);
448 assert(config != NULL);
455 assert(config != NULL);
463 assert(config != NULL);
469 config_free(config);
471 config = config_new_empty();
472 if (config == NULL) {
477 bool ret = config_save(config, CONFIG_FILE_PATH);
491 assert(config != NULL);
496 config_t *config_paired = config_new_clone(config);
507 // The paired config used to carry information about
535 dprintf(fd, "\nBluetooth Config:\n");
537 dprintf(fd, " Config Source: ");
561 dprintf(fd, " File source: %s\n", config_get_string(config, INFO_SECTION,
565 static void btif_config_remove_restricted(config_t* config) {
566 assert(config != NULL);
568 const config_section_node_t *snode = config_section_begin(config
569 while (snode != config_section_end(config)) {
571 if (string_is_bdaddr(section) && config_has_key(config, section, "Restricted")) {
573 config_remove_section(config, section);