1d1700513SMatthias Ringwald /* 2d1700513SMatthias Ringwald * Copyright (C) 2017 BlueKitchen GmbH 3d1700513SMatthias Ringwald * 4d1700513SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5d1700513SMatthias Ringwald * modification, are permitted provided that the following conditions 6d1700513SMatthias Ringwald * are met: 7d1700513SMatthias Ringwald * 8d1700513SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9d1700513SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10d1700513SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11d1700513SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12d1700513SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13d1700513SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14d1700513SMatthias Ringwald * contributors may be used to endorse or promote products derived 15d1700513SMatthias Ringwald * from this software without specific prior written permission. 16d1700513SMatthias Ringwald * 172fca4dadSMilanka Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 18d1700513SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19d1700513SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 202fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 212fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22d1700513SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23d1700513SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 24d1700513SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25d1700513SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26d1700513SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27d1700513SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28d1700513SMatthias Ringwald * SUCH DAMAGE. 29d1700513SMatthias Ringwald * 30d1700513SMatthias Ringwald */ 31d1700513SMatthias Ringwald 32d1700513SMatthias Ringwald /* 33d1700513SMatthias Ringwald * btstack_tlv_posix.h 34d1700513SMatthias Ringwald * 35d1700513SMatthias Ringwald * Implementation for BTstack's Tag Value Length Persistent Storage implementations 36d1700513SMatthias Ringwald * using in-memory storage (RAM & malloc) and append-only log files on disc 37d1700513SMatthias Ringwald */ 38d1700513SMatthias Ringwald 3980e33422SMatthias Ringwald #ifndef BTSTACK_TLV_POSIX_H 4080e33422SMatthias Ringwald #define BTSTACK_TLV_POSIX_H 41d1700513SMatthias Ringwald 42d1700513SMatthias Ringwald #include <stdint.h> 43d1700513SMatthias Ringwald #include <stdio.h> 44d1700513SMatthias Ringwald #include "btstack_tlv.h" 45d1700513SMatthias Ringwald #include "btstack_linked_list.h" 46d1700513SMatthias Ringwald 47d1700513SMatthias Ringwald #if defined __cplusplus 48d1700513SMatthias Ringwald extern "C" { 49d1700513SMatthias Ringwald #endif 50d1700513SMatthias Ringwald 51d1700513SMatthias Ringwald typedef struct { 52d1700513SMatthias Ringwald btstack_linked_list_t entry_list; 53d1700513SMatthias Ringwald const char * db_path; 54d1700513SMatthias Ringwald FILE * file; 55d1700513SMatthias Ringwald } btstack_tlv_posix_t; 56d1700513SMatthias Ringwald 57d1700513SMatthias Ringwald /** 58d1700513SMatthias Ringwald * Init Tag Length Value Store 59d1700513SMatthias Ringwald * @param context btstack_tlv_posix_t 60d1700513SMatthias Ringwald * @param db_path on disc 61d1700513SMatthias Ringwald */ 62d1700513SMatthias Ringwald const btstack_tlv_t * btstack_tlv_posix_init_instance(btstack_tlv_posix_t * context, const char * db_path); 63d1700513SMatthias Ringwald 644129d206SMatthias Ringwald /** 65*6314722eSMatthias Ringwald * Disable writing to TLV file 66*6314722eSMatthias Ringwald * @note must be called before btstack_tlv_posix_init_instance 674c7f8b03SMatthias Ringwald */ 68*6314722eSMatthias Ringwald void btstack_tlv_posix_set_read_only(void); 694c7f8b03SMatthias Ringwald 704c7f8b03SMatthias Ringwald /** 714129d206SMatthias Ringwald * Free TLV entries 724129d206SMatthias Ringwald * @param self 734129d206SMatthias Ringwald */ 744129d206SMatthias Ringwald void btstack_tlv_posix_deinit(btstack_tlv_posix_t * self); 754129d206SMatthias Ringwald 76d1700513SMatthias Ringwald #if defined __cplusplus 77d1700513SMatthias Ringwald } 78d1700513SMatthias Ringwald #endif 7980e33422SMatthias Ringwald #endif // BTSTACK_TLV_POSIX_H 80