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 
26 static const char BTIF_CONFIG_MODULE[] = "btif_config_module";
27 
28 typedef struct btif_config_section_iter_t btif_config_section_iter_t;
29 
30 bool btif_config_has_section(const char* section);
31 bool btif_config_exist(const char* section, const char* key);
32 bool btif_config_get_int(const char* section, const char* key, int* value);
33 bool btif_config_set_int(const char* section, const char* key, int value);
34 bool btif_config_get_str(const char* section, const char* key, char* value,
35                          int* size_bytes);
36 bool btif_config_set_str(const char* section, const char* key,
37                          const char* value);
38 bool btif_config_get_bin(const char* section, const char* key, uint8_t* value,
39                          size_t* length);
40 bool btif_config_set_bin(const char* section, const char* key,
41                          const uint8_t* value, size_t length);
42 bool btif_config_remove(const char* section, const char* key);
43 
44 size_t btif_config_get_bin_length(const char* section, const char* key);
45 
46 const btif_config_section_iter_t* btif_config_section_begin(void);
47 const btif_config_section_iter_t* btif_config_section_end(void);
48 const btif_config_section_iter_t* btif_config_section_next(
49     const btif_config_section_iter_t* section);
50 const char* btif_config_section_name(const btif_config_section_iter_t* section);
51 
52 void btif_config_save(void);
53 void btif_config_flush(void);
54 bool btif_config_clear(void);
55 
56 // TODO(zachoverflow): Eww...we need to move these out. These are peer specific,
57 // not config general.
58 bool btif_get_address_type(const BD_ADDR bd_addr, int* p_addr_type);
59 bool btif_get_device_type(const BD_ADDR bd_addr, int* p_device_type);
60 
61 void btif_debug_config_dump(int fd);
62