AM263Px MCU+ SDK  10.01.00
simpledb.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
50 #ifndef SIMPLEDB_H_
51 #define SIMPLEDB_H_
52 
53 #include "tsn_unibase/unibase.h"
54 
55 #define MAX_NUM_DBLIST 20
56 
57 typedef struct simpledb_data simpledb_data_t;
58 
59 typedef struct simpledb_range simpledb_range_t;
60 
61 typedef struct keydata{
62  uint32_t ksize;
63  void *kdata;
65 
66 typedef struct key_range{
70 
74 simpledb_data_t *simpledb_open(const char *pfname);
75 
80 
86 
92 #define SIMPLEDB_FLAG_CREATE (1u<<0u)
93 #define SIMPLEDB_FLAG_APPEND (1u<<1u)
94 int simpledb_put(simpledb_data_t *sdbd, simpledb_keydata_t *kd, void *value,
95  uint32_t vlen, uint8_t flags);
96 
102  void **value, uint32_t *vlen);
103 
105 
110 
117  key_range_t *krange);
118 
120 
125 #define SIMPLEDB_FORWARD 1
126 #define SIMPLEDB_BACKWARD -1
127 #define SIMPLEDB_NOMOVE 0
129  void **kdata, uint32_t *ksize, void **vdata, uint32_t *vsize,
130  int direction);
131 
133 
135 
137  int direction);
138 
140  int direction);
141 
142 int simpledb_wait_release(simpledb_data_t *sdbd, int toutms);
143 
144 #endif
simpledb_get_from_range
int simpledb_get_from_range(simpledb_data_t *sdbd, simpledb_range_t *rangedp, void **kdata, uint32_t *ksize, void **vdata, uint32_t *vsize, int direction)
simpledb_get_range_release
void simpledb_get_range_release(simpledb_data_t *sdbd, simpledb_range_t *rangedp)
simpledb_range_t
struct simpledb_range simpledb_range_t
Definition: simpledb.h:59
simpledb_del
int simpledb_del(simpledb_data_t *sdbd, simpledb_keydata_t *kd)
delete the key item. need to be unlocked status.
key_range_t::kd1
simpledb_keydata_t * kd1
Definition: simpledb.h:67
simpledb_put
int simpledb_put(simpledb_data_t *sdbd, simpledb_keydata_t *kd, void *value, uint32_t vlen, uint8_t flags)
simpledb_move_top_range
void simpledb_move_top_range(simpledb_data_t *sdbd, simpledb_range_t *rangedp)
simpledb_move_in_range
int simpledb_move_in_range(simpledb_data_t *sdbd, simpledb_range_t *rangedp, int direction)
simpledb_del_in_range
int simpledb_del_in_range(simpledb_data_t *sdbd, simpledb_range_t *rangedp, int direction)
simpledb_keydata_t
Definition: simpledb.h:61
unibase.h
unibase general global header
simpledb_keydata_t::ksize
uint32_t ksize
Definition: simpledb.h:62
flags
uint8_t flags
Definition: hsmclient_msg.h:2
simpledb_close
void simpledb_close(simpledb_data_t *sdbd)
close the db. if pfname is set at the open, the config(rw) data is saved.
simpledb_get_range
simpledb_range_t * simpledb_get_range(simpledb_data_t *sdbd, key_range_t *krange)
get datarange pointer which the keys are between (key1, key2)
simpledb_open
simpledb_data_t * simpledb_open(const char *pfname)
open the db. if pfname is set, the config(rw) data is restored from the file.
simpledb_savedata
int simpledb_savedata(simpledb_data_t *sdbd, key_range_t **keyranges)
save data to a file
simpledb_move_bottom_range
void simpledb_move_bottom_range(simpledb_data_t *sdbd, simpledb_range_t *rangedp)
simpledb_get
int simpledb_get(simpledb_data_t *sdbd, simpledb_keydata_t *kd, void **value, uint32_t *vlen)
get data from the db
simpledb_get_release
int simpledb_get_release(simpledb_data_t *sdbd, simpledb_keydata_t *kd)
simpledb_data_t
struct simpledb_data simpledb_data_t
Definition: simpledb.h:57
key_range_t::kd2
simpledb_keydata_t * kd2
Definition: simpledb.h:68
key_range_t
Definition: simpledb.h:66
simpledb_keydata_t::kdata
void * kdata
Definition: simpledb.h:63
simpledb_wait_release
int simpledb_wait_release(simpledb_data_t *sdbd, int toutms)