btif_config.h revision c2276b06572ab6fc1f900fbb1f41087e77d47e2a
1/******************************************************************************
2 *
3 *  Copyright (C) 2014 Google, Inc.
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19#pragma once
20
21#include <stdbool.h>
22#include <stddef.h>
23
24#include "bt_types.h"
25
26static const char BTIF_CONFIG_MODULE[] = "btif_config_module";
27
28typedef struct btif_config_section_iter_t btif_config_section_iter_t;
29
30bool btif_config_has_section(const char* section);
31bool btif_config_exist(const char* section, const char* key);
32bool btif_config_get_int(const char* section, const char* key, int* value);
33bool btif_config_set_int(const char* section, const char* key, int value);
34bool btif_config_get_str(const char* section, const char* key, char* value,
35                         int* size_bytes);
36bool btif_config_set_str(const char* section, const char* key,
37                         const char* value);
38bool btif_config_get_bin(const char* section, const char* key, uint8_t* value,
39                         size_t* length);
40bool btif_config_set_bin(const char* section, const char* key,
41                         const uint8_t* value, size_t length);
42bool btif_config_remove(const char* section, const char* key);
43
44size_t btif_config_get_bin_length(const char* section, const char* key);
45
46const btif_config_section_iter_t* btif_config_section_begin(void);
47const btif_config_section_iter_t* btif_config_section_end(void);
48const btif_config_section_iter_t* btif_config_section_next(
49    const btif_config_section_iter_t* section);
50const char* btif_config_section_name(const btif_config_section_iter_t* section);
51
52void btif_config_save(void);
53void btif_config_flush(void);
54bool btif_config_clear(void);
55
56// TODO(zachoverflow): Eww...we need to move these out. These are peer specific,
57// not config general.
58bool btif_get_address_type(const bt_bdaddr_t& bd_addr, int* p_addr_type);
59bool btif_get_device_type(const bt_bdaddr_t& bd_addr, int* p_device_type);
60
61void btif_debug_config_dump(int fd);
62