2 * Copyright (c) 2022 OpenLuat & AirM2M
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of
5 * this software and associated documentation files (the "Software"), to deal in
6 * the Software without restriction, including without limitation the rights to
7 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 * the Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 * @defgroup luatos_fskv 持久化数据存储接口
37 * @return int == 0 正常 != 0失败
39 int luat_fskv_init(void);
43 * @param key[IN] 待删除的key值
44 * @return int == 0 正常 != 0失败
46 int luat_fskv_del(const char* key
);
50 * @param key[IN] 待写入的key值,不能为NULL,必须是\0结尾,最大长度64字节
51 * @param data[IN] 待写入的数据, 不需要\0结尾
52 * @param len[IN] 待写入的数据长度, 不含\0,当前支持最大长度255字节
55 int luat_fskv_set(const char* key
, void* data
, size_t len
);
59 * @param key key值,不能为NULL,必须是\0结尾,最大长度64字节
63 int luat_fskv_size(const char* key
, char buff
[4]);
67 * @param key[IN] 待读取的key值,不能为NULL,必须是\0结尾
68 * @param data[IN] 待读取的数据, 可写入空间必须大于等于len值
69 * @param len[IN] 待读取的数据长度最大长度, 不含\0
70 * @return int > 0 实际读取的长度, <=0 失败
72 int luat_fskv_get(const char* key
, void* data
, size_t len
);
76 * @return int == 0 正常 != 0失败
78 int luat_fskv_clear(void);
81 * @param using_sz 已使用的空间,单位字节
82 * @param max_sz 总可用空间, 单位字节
83 * @param kv_count 总kv键值对数量, 单位个
86 int luat_fskv_stat(size_t *using_sz
, size_t *max_sz
, size_t *kv_count
);
93 int luat_fskv_next(char* buff
, size_t offset
);