libwebsockets
Lightweight C library for HTML5 websockets
lws-settings.h
1
/*
2
* Generic Settings storage
3
*
4
* Copyright (C) 2020 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*
24
*
25
* This is like an abstract class for non-volatile storage, whether in a file-
26
* system or flash-backed blocks, etc. Named blobs of variable size are stored
27
* in nonvolatile media of some sort. Typically, these are JSON objects under
28
* a naming scheme like, eg, "network".
29
*
30
* There's a platform-specific storage identifier opaque_plat provided when the
31
* storage object is instantiated, this describes eg the storage device or
32
* partition in instantiation-specific terms.
33
*
34
* Blobs have a further "filename" associated with them.
35
*/
36
37
#define LSOOPEN_FLAG_WRITEABLE (1 << 0)
38
39
struct
lws_settings_ops
;
40
41
typedef
struct
{
42
void
*handle_plat;
43
const
struct
lws_settings_ops
*so;
44
uint8_t refcount;
45
void
*opaque_plat;
46
}
lws_settings_instance_t
;
47
48
typedef
struct
lws_settings_ops
{
49
int (*
get
)(
lws_settings_instance_t
*si,
const
char
*name,
50
uint8_t *dest,
size_t
*max_actual);
53
int (*set)(
lws_settings_instance_t
*si,
const
char
*name,
54
const
uint8_t *src,
size_t
len);
55
}
lws_settings_ops_t
;
56
70
LWS_VISIBLE LWS_EXTERN
int
71
lws_settings_plat_get(
lws_settings_instance_t
*si,
const
char
*name,
72
uint8_t *dest,
size_t
*max_actual);
73
85
LWS_VISIBLE LWS_EXTERN
int
86
lws_settings_plat_set(
lws_settings_instance_t
*si,
const
char
*name,
87
const
uint8_t *src,
size_t
len);
88
100
LWS_VISIBLE LWS_EXTERN
int
101
lws_settings_plat_printf(
lws_settings_instance_t
*si,
const
char
*name,
102
const
char
*format, ...) LWS_FORMAT(3);
103
104
#define lws_settings_ops_plat \
105
.get = lws_settings_plat_get, \
106
.set = lws_settings_plat_set,
107
108
LWS_VISIBLE LWS_EXTERN
lws_settings_instance_t
*
109
lws_settings_init(
const
lws_settings_ops_t
*so,
void
*opaque_plat);
110
111
LWS_VISIBLE LWS_EXTERN
void
112
lws_settings_deinit(
lws_settings_instance_t
**si);
lws_settings_instance_t
Definition:
lws-settings.h:41
lws_settings_ops
Definition:
lws-settings.h:48
lws_settings_ops::get
int(* get)(lws_settings_instance_t *si, const char *name, uint8_t *dest, size_t *max_actual)
Definition:
lws-settings.h:49
include
libwebsockets
lws-settings.h
Generated by
1.9.1