コード例 #1
0
ファイル: config_test.cpp プロジェクト: morrey/bt_bcm
TEST_F(ConfigTest, config_section_begin) {
  config_t *config = config_new(CONFIG_FILE);
  const config_section_node_t *section = config_section_begin(config);
  EXPECT_TRUE(section != NULL);
  const char *section_name = config_section_name(section);
  EXPECT_TRUE(section != NULL);
  EXPECT_TRUE(!strcmp(section_name, CONFIG_DEFAULT_SECTION));
  config_free(config);
}
コード例 #2
0
ファイル: config_test.cpp プロジェクト: morrey/bt_bcm
TEST_F(ConfigTest, config_section_next) {
  config_t *config = config_new(CONFIG_FILE);
  const config_section_node_t *section = config_section_begin(config);
  EXPECT_TRUE(section != NULL);
  section = config_section_next(section);
  EXPECT_TRUE(section != NULL);
  const char *section_name = config_section_name(section);
  EXPECT_TRUE(section != NULL);
  EXPECT_TRUE(!strcmp(section_name, "DID"));
  config_free(config);
}
コード例 #3
0
ファイル: btc_config.c プロジェクト: mr-nice/esp-idf
void btc_config_save(void)
{
       assert(config != NULL);
    // Garbage collection process: the config file accumulates
    // cached information about remote devices during regular
    // inquiry scans. We remove some of these junk entries
    // so the file doesn't grow indefinitely. We have to take care
    // to make sure we don't remove information about bonded
    // devices (hence the check for link keys).
    static const size_t CACHE_MAX = 256;
    const char *keys[CACHE_MAX];
    size_t num_keys = 0;
    size_t total_candidates = 0;

    osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
    for (const config_section_node_t *snode = config_section_begin(config); snode != config_section_end(config); snode = config_section_next(snode)) {
        const char *section = config_section_name(snode);
        if (!string_is_bdaddr(section)) {
            continue;
        }

        if (config_has_key(config, section, "LinkKey") ||
                config_has_key(config, section, "LE_KEY_PENC") ||
                config_has_key(config, section, "LE_KEY_PID") ||
                config_has_key(config, section, "LE_KEY_PCSRK") ||
                config_has_key(config, section, "LE_KEY_LENC") ||
                config_has_key(config, section, "LE_KEY_LCSRK")) {
            continue;
        }

        if (num_keys < CACHE_MAX) {
            keys[num_keys++] = section;
        }

        ++total_candidates;
    }

    if (total_candidates > CACHE_MAX * 2)
        while (num_keys > 0) {
            config_remove_section(config, keys[--num_keys]);
        }
    config_save(config, CONFIG_FILE_PATH);
    osi_mutex_unlock(&lock);
}
コード例 #4
0
ファイル: btif_config.c プロジェクト: Emill/android_bluetooth
const char *btif_config_section_name(const btif_config_section_iter_t *section) {
  assert(config != NULL);
  assert(section != NULL);
  return config_section_name((const config_section_node_t *)section);
}