libwebsockets
Lightweight C library for HTML5 websockets
lws-settings.h
Go to the documentation of this file.
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;
45  void *opaque_plat;
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);
56 
72  uint8_t *dest, size_t *max_actual);
73 
87  const uint8_t *src, size_t len);
88 
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 
109 lws_settings_init(const lws_settings_ops_t *so, void *opaque_plat);
110 
#define LWS_FORMAT(string_index)
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE
struct lws_settings_ops lws_settings_ops_t
LWS_VISIBLE LWS_EXTERN int lws_settings_plat_get(lws_settings_instance_t *si, const char *name, uint8_t *dest, size_t *max_actual)
LWS_VISIBLE LWS_EXTERN lws_settings_instance_t * lws_settings_init(const lws_settings_ops_t *so, void *opaque_plat)
const struct lws_settings_ops * so
Definition: lws-settings.h:43
LWS_VISIBLE LWS_EXTERN int lws_settings_plat_printf(lws_settings_instance_t *si, const char *name, const char *format,...) LWS_FORMAT(3)
LWS_VISIBLE LWS_EXTERN void lws_settings_deinit(lws_settings_instance_t **si)
LWS_VISIBLE LWS_EXTERN int lws_settings_plat_set(lws_settings_instance_t *si, const char *name, const uint8_t *src, size_t len)
int(* set)(lws_settings_instance_t *si, const char *name, const uint8_t *src, size_t len)
Definition: lws-settings.h:53
int(* get)(lws_settings_instance_t *si, const char *name, uint8_t *dest, size_t *max_actual)
Definition: lws-settings.h:49