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