libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-struct.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lejp_collation
 
struct  lws_struct_map
 
struct  lws_struct_args
 
struct  lws_struct_serialize_st
 
struct  lws_struct_serialize
 

Macros

#define LSM_SIGNED(type, name, qname)
 
#define LSM_UNSIGNED(type, name, qname)
 
#define LSM_BOOLEAN(type, name, qname)
 
#define LSM_CARRAY(type, name, qname)
 
#define LSM_STRING_PTR(type, name, qname)
 
#define LSM_LIST(ptype, pname, ctype, cname, lejp_cb, cmap, qname)
 
#define LSM_CHILD_PTR(ptype, pname, ctype, lejp_cb, cmap, qname)
 
#define LSM_SCHEMA(ctype, lejp_cb, map, schema_name)
 
#define LSM_SCHEMA_DLL2(ctype, cdll2mem, lejp_cb, map, schema_name)
 
#define LSM_JO_SIGNED(type, name, qname)
 
#define LSM_JO_UNSIGNED(type, name, qname)
 
#define LSM_JO_BOOLEAN(type, name, qname)
 
#define LSM_JO_CARRAY(type, name, qname)
 
#define LSM_JO_STRING_PTR(type, name, qname)
 
#define LSM_JO_LIST(ptype, pname, ctype, cname, lejp_cb, cmap, qname)
 
#define LSM_JO_CHILD_PTR(ptype, pname, ctype, lejp_cb, cmap, qname)
 
#define LSM_JO_SCHEMA(ctype, lejp_cb, map, schema_name)
 
#define LSM_JO_SCHEMA_DLL2(ctype, cdll2mem, lejp_cb, map, schema_name)
 
#define LSM_BLOB_PTR(type, blobptr_name, qname)
 

Typedefs

typedef struct lejp_collation lejp_collation_t
 
typedef struct lws_struct_map lws_struct_map_t
 
typedef int(* lws_struct_args_cb) (void *obj, void *cb_arg)
 
typedef struct lws_struct_args lws_struct_args_t
 
typedef struct lws_struct_serialize_st lws_struct_serialize_st_t
 
typedef struct lws_struct_serialize lws_struct_serialize_t
 
typedef struct sqlite3 sqlite3
 

Enumerations

enum  lws_struct_map_type_eum {
  LSMT_SIGNED , LSMT_UNSIGNED , LSMT_BOOLEAN , LSMT_STRING_CHAR_ARRAY ,
  LSMT_STRING_PTR , LSMT_LIST , LSMT_CHILD_PTR , LSMT_SCHEMA ,
  LSMT_BLOB_PTR
}
 
enum  { LSSERJ_FLAG_PRETTY = (1 << 0) , LSSERJ_FLAG_OMIT_SCHEMA = (1 << 1) }
 
enum  lws_struct_json_serialize_result_t { LSJS_RESULT_CONTINUE , LSJS_RESULT_FINISH , LSJS_RESULT_ERROR }
 

Functions

LWS_VISIBLE LWS_EXTERN int lws_struct_json_init_parse (struct lejp_ctx *ctx, lejp_callback cb, void *user)
 
LWS_VISIBLE LWS_EXTERN signed char lws_struct_schema_only_lejp_cb (struct lejp_ctx *ctx, char reason)
 
LWS_VISIBLE LWS_EXTERN signed char lws_struct_default_lejp_cb (struct lejp_ctx *ctx, char reason)
 
LWS_VISIBLE LWS_EXTERN lws_struct_serialize_tlws_struct_json_serialize_create (const lws_struct_map_t *map, size_t map_entries, int flags, const void *ptoplevel)
 
LWS_VISIBLE LWS_EXTERN lws_struct_json_serialize_result_t lws_struct_json_serialize (lws_struct_serialize_t *js, uint8_t *buf, size_t len, size_t *written)
 
LWS_VISIBLE LWS_EXTERN void lws_struct_json_serialize_destroy (lws_struct_serialize_t **pjs)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_open (struct lws_context *context, const char *sqlite3_path, char create_if_missing, sqlite3 **pdb)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_close (sqlite3 **pdb)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_create_table (sqlite3 *pdb, const lws_struct_map_t *schema)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_serialize (sqlite3 *pdb, const lws_struct_map_t *schema, lws_dll2_owner_t *owner, uint32_t manual_idx)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_update (sqlite3 *pdb, const char *table, const lws_struct_map_t *map, size_t map_entries, const void *data, const char *where_col)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_upsert (sqlite3 *pdb, const char *table, const lws_struct_map_t *map, size_t map_entries, const void *data, const char *where_col)
 
LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_deserialize (sqlite3 *pdb, const char *filter, const char *order, const lws_struct_map_t *schema, lws_dll2_owner_t *o, struct lwsac **ac, int start, int limit)
 

Data Structure Documentation

◆ lejp_collation

struct lejp_collation

Definition at line 50 of file lws-struct.h.

+ Collaboration diagram for lejp_collation:
Data Fields
struct lws_dll2 chunks
int len
char buf[LEJP_STRING_CHUNK+1]

◆ lws_struct_map

struct lws_struct_map

Definition at line 56 of file lws-struct.h.

+ Collaboration diagram for lws_struct_map:
Data Fields
const char * colname
const struct lws_struct_map * child_map
lejp_callback lejp_cb
size_t ofs
size_t aux
size_t ofs_clist
size_t child_map_size
lws_struct_map_type_eum type
char json_only

◆ lws_struct_args

struct lws_struct_args

Definition at line 70 of file lws-struct.h.

+ Collaboration diagram for lws_struct_args:
Data Fields
const lws_struct_map_t * map_st[LEJP_MAX_PARSING_STACK_DEPTH]
lws_struct_args_cb cb
struct lwsac * ac
void * cb_arg
void * dest
size_t dest_len
size_t toplevel_dll2_ofs
size_t map_entries_st[LEJP_MAX_PARSING_STACK_DEPTH]
size_t ac_block_size
int subtype
int top_schema_index
struct lwsac * ac_chunks
struct lws_dll2_owner chunks_owner
size_t chunks_length

◆ lws_struct_serialize_st

struct lws_struct_serialize_st

Definition at line 360 of file lws-struct.h.

+ Collaboration diagram for lws_struct_serialize_st:
Data Fields
const struct lws_dll2 * dllpos
const lws_struct_map_t * map
const char * obj
size_t map_entries
size_t map_entry
size_t size
char subsequent
char idt

◆ lws_struct_serialize

struct lws_struct_serialize

Definition at line 376 of file lws-struct.h.

+ Collaboration diagram for lws_struct_serialize:
Data Fields
lws_struct_serialize_st_t st[LEJP_MAX_PARSING_STACK_DEPTH]
size_t offset
size_t remaining
int sp
int flags

Macro Definition Documentation

◆ LSM_SIGNED

#define LSM_SIGNED ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof ((type *)0)->name, \
0, \
0, \
0 \
}
@ LSMT_SIGNED
Definition lws-struct.h:38

Definition at line 98 of file lws-struct.h.

98#define LSM_SIGNED(type, name, qname) \
99 { \
100 qname, \
101 NULL, \
102 NULL, \
103 offsetof(type, name), \
104 sizeof ((type *)0)->name, \
105 0, \
106 0, \
107 LSMT_SIGNED, \
108 0 \
109 }

◆ LSM_UNSIGNED

#define LSM_UNSIGNED ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof ((type *)0)->name, \
0, \
0, \
0, \
}
@ LSMT_UNSIGNED
Definition lws-struct.h:39

Definition at line 111 of file lws-struct.h.

111#define LSM_UNSIGNED(type, name, qname) \
112 { \
113 qname, \
114 NULL, \
115 NULL, \
116 offsetof(type, name), \
117 sizeof ((type *)0)->name, \
118 0, \
119 0, \
120 LSMT_UNSIGNED, \
121 0, \
122 }

◆ LSM_BOOLEAN

#define LSM_BOOLEAN ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof ((type *)0)->name, \
0, \
0, \
0, \
}
@ LSMT_BOOLEAN
Definition lws-struct.h:40

Definition at line 124 of file lws-struct.h.

124#define LSM_BOOLEAN(type, name, qname) \
125 { \
126 qname, \
127 NULL, \
128 NULL, \
129 offsetof(type, name), \
130 sizeof ((type *)0)->name, \
131 0, \
132 0, \
133 LSMT_BOOLEAN, \
134 0, \
135 }

◆ LSM_CARRAY

#define LSM_CARRAY ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof (((type *)0)->name), \
0, \
0, \
0, \
}
@ LSMT_STRING_CHAR_ARRAY
Definition lws-struct.h:41

Definition at line 137 of file lws-struct.h.

137#define LSM_CARRAY(type, name, qname) \
138 { \
139 qname, \
140 NULL, \
141 NULL, \
142 offsetof(type, name), \
143 sizeof (((type *)0)->name), \
144 0, \
145 0, \
146 LSMT_STRING_CHAR_ARRAY, \
147 0, \
148 }

◆ LSM_STRING_PTR

#define LSM_STRING_PTR ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof (((type *)0)->name), \
0, \
0, \
0 \
}
@ LSMT_STRING_PTR
Definition lws-struct.h:42

Definition at line 150 of file lws-struct.h.

150#define LSM_STRING_PTR(type, name, qname) \
151 { \
152 qname, \
153 NULL, \
154 NULL, \
155 offsetof(type, name), \
156 sizeof (((type *)0)->name), \
157 0, \
158 0, \
159 LSMT_STRING_PTR, \
160 0 \
161 }

◆ LSM_LIST

#define LSM_LIST ( ptype,
pname,
ctype,
cname,
lejp_cb,
cmap,
qname )
Value:
{ \
qname, \
cmap, \
lejp_cb, \
offsetof(ptype, pname), \
sizeof (ctype), \
offsetof(ctype, cname), \
LWS_ARRAY_SIZE(cmap), \
0, \
}
@ LSMT_LIST
Definition lws-struct.h:43

Definition at line 163 of file lws-struct.h.

163#define LSM_LIST(ptype, pname, ctype, cname, lejp_cb, cmap, qname) \
164 { \
165 qname, \
166 cmap, \
167 lejp_cb, \
168 offsetof(ptype, pname), \
169 sizeof (ctype), \
170 offsetof(ctype, cname), \
171 LWS_ARRAY_SIZE(cmap), \
172 LSMT_LIST, \
173 0, \
174 }

◆ LSM_CHILD_PTR

#define LSM_CHILD_PTR ( ptype,
pname,
ctype,
lejp_cb,
cmap,
qname )
Value:
{ \
qname, \
cmap, \
lejp_cb, \
offsetof(ptype, pname), \
sizeof (ctype), \
0, \
LWS_ARRAY_SIZE(cmap), \
0, \
}
@ LSMT_CHILD_PTR
Definition lws-struct.h:44

Definition at line 176 of file lws-struct.h.

176#define LSM_CHILD_PTR(ptype, pname, ctype, lejp_cb, cmap, qname) \
177 { \
178 qname, \
179 cmap, \
180 lejp_cb, \
181 offsetof(ptype, pname), \
182 sizeof (ctype), \
183 0, \
184 LWS_ARRAY_SIZE(cmap), \
185 LSMT_CHILD_PTR, \
186 0, \
187 }

◆ LSM_SCHEMA

#define LSM_SCHEMA ( ctype,
lejp_cb,
map,
schema_name )
Value:
{ \
schema_name, \
map, \
lejp_cb, \
0, \
sizeof (ctype), \
0, \
LWS_ARRAY_SIZE(map), \
0, \
}
@ LSMT_SCHEMA
Definition lws-struct.h:45

Definition at line 189 of file lws-struct.h.

189#define LSM_SCHEMA(ctype, lejp_cb, map, schema_name) \
190 { \
191 schema_name, \
192 map, \
193 lejp_cb, \
194 0, \
195 sizeof (ctype), \
196 0, \
197 LWS_ARRAY_SIZE(map), \
198 LSMT_SCHEMA, \
199 0, \
200 }

◆ LSM_SCHEMA_DLL2

#define LSM_SCHEMA_DLL2 ( ctype,
cdll2mem,
lejp_cb,
map,
schema_name )
Value:
{ \
schema_name, \
map, \
lejp_cb, \
offsetof(ctype, cdll2mem), \
sizeof (ctype), \
0, \
LWS_ARRAY_SIZE(map), \
0, \
}

Definition at line 202 of file lws-struct.h.

202#define LSM_SCHEMA_DLL2(ctype, cdll2mem, lejp_cb, map, schema_name) \
203 { \
204 schema_name, \
205 map, \
206 lejp_cb, \
207 offsetof(ctype, cdll2mem), \
208 sizeof (ctype), \
209 0, \
210 LWS_ARRAY_SIZE(map), \
211 LSMT_SCHEMA, \
212 0, \
213 }

◆ LSM_JO_SIGNED

#define LSM_JO_SIGNED ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof ((type *)0)->name, \
0, \
0, \
1 \
}

Definition at line 224 of file lws-struct.h.

224#define LSM_JO_SIGNED(type, name, qname) \
225 { \
226 qname, \
227 NULL, \
228 NULL, \
229 offsetof(type, name), \
230 sizeof ((type *)0)->name, \
231 0, \
232 0, \
233 LSMT_SIGNED, \
234 1 \
235 }

◆ LSM_JO_UNSIGNED

#define LSM_JO_UNSIGNED ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof ((type *)0)->name, \
0, \
0, \
1, \
}

Definition at line 237 of file lws-struct.h.

237#define LSM_JO_UNSIGNED(type, name, qname) \
238 { \
239 qname, \
240 NULL, \
241 NULL, \
242 offsetof(type, name), \
243 sizeof ((type *)0)->name, \
244 0, \
245 0, \
246 LSMT_UNSIGNED, \
247 1, \
248 }

◆ LSM_JO_BOOLEAN

#define LSM_JO_BOOLEAN ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof ((type *)0)->name, \
0, \
0, \
1, \
}

Definition at line 250 of file lws-struct.h.

250#define LSM_JO_BOOLEAN(type, name, qname) \
251 { \
252 qname, \
253 NULL, \
254 NULL, \
255 offsetof(type, name), \
256 sizeof ((type *)0)->name, \
257 0, \
258 0, \
259 LSMT_BOOLEAN, \
260 1, \
261 }

◆ LSM_JO_CARRAY

#define LSM_JO_CARRAY ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof (((type *)0)->name), \
0, \
0, \
1, \
}

Definition at line 263 of file lws-struct.h.

263#define LSM_JO_CARRAY(type, name, qname) \
264 { \
265 qname, \
266 NULL, \
267 NULL, \
268 offsetof(type, name), \
269 sizeof (((type *)0)->name), \
270 0, \
271 0, \
272 LSMT_STRING_CHAR_ARRAY, \
273 1, \
274 }

◆ LSM_JO_STRING_PTR

#define LSM_JO_STRING_PTR ( type,
name,
qname )
Value:
{ \
qname, \
NULL, \
NULL, \
offsetof(type, name), \
sizeof (((type *)0)->name), \
0, \
0, \
1, \
}

Definition at line 276 of file lws-struct.h.

276#define LSM_JO_STRING_PTR(type, name, qname) \
277 { \
278 qname, \
279 NULL, \
280 NULL, \
281 offsetof(type, name), \
282 sizeof (((type *)0)->name), \
283 0, \
284 0, \
285 LSMT_STRING_PTR, \
286 1, \
287 }

◆ LSM_JO_LIST

#define LSM_JO_LIST ( ptype,
pname,
ctype,
cname,
lejp_cb,
cmap,
qname )
Value:
{ \
qname, \
cmap, \
lejp_cb, \
offsetof(ptype, pname), \
sizeof (ctype), \
offsetof(ctype, cname), \
LWS_ARRAY_SIZE(cmap), \
1, \
}

Definition at line 289 of file lws-struct.h.

289#define LSM_JO_LIST(ptype, pname, ctype, cname, lejp_cb, cmap, qname) \
290 { \
291 qname, \
292 cmap, \
293 lejp_cb, \
294 offsetof(ptype, pname), \
295 sizeof (ctype), \
296 offsetof(ctype, cname), \
297 LWS_ARRAY_SIZE(cmap), \
298 LSMT_LIST, \
299 1, \
300 }

◆ LSM_JO_CHILD_PTR

#define LSM_JO_CHILD_PTR ( ptype,
pname,
ctype,
lejp_cb,
cmap,
qname )
Value:
{ \
qname, \
cmap, \
lejp_cb, \
offsetof(ptype, pname), \
sizeof (ctype), \
0, \
LWS_ARRAY_SIZE(cmap), \
1, \
}

Definition at line 302 of file lws-struct.h.

302#define LSM_JO_CHILD_PTR(ptype, pname, ctype, lejp_cb, cmap, qname) \
303 { \
304 qname, \
305 cmap, \
306 lejp_cb, \
307 offsetof(ptype, pname), \
308 sizeof (ctype), \
309 0, \
310 LWS_ARRAY_SIZE(cmap), \
311 LSMT_CHILD_PTR, \
312 1, \
313 }

◆ LSM_JO_SCHEMA

#define LSM_JO_SCHEMA ( ctype,
lejp_cb,
map,
schema_name )
Value:
{ \
schema_name, \
map, \
lejp_cb, \
0, \
sizeof (ctype), \
0, \
LWS_ARRAY_SIZE(map), \
1, \
}

Definition at line 315 of file lws-struct.h.

315#define LSM_JO_SCHEMA(ctype, lejp_cb, map, schema_name) \
316 { \
317 schema_name, \
318 map, \
319 lejp_cb, \
320 0, \
321 sizeof (ctype), \
322 0, \
323 LWS_ARRAY_SIZE(map), \
324 LSMT_SCHEMA, \
325 1, \
326 }

◆ LSM_JO_SCHEMA_DLL2

#define LSM_JO_SCHEMA_DLL2 ( ctype,
cdll2mem,
lejp_cb,
map,
schema_name )
Value:
{ \
schema_name, \
map, \
lejp_cb, \
offsetof(ctype, cdll2mem), \
sizeof (ctype), \
0, \
LWS_ARRAY_SIZE(map), \
1, \
}

Definition at line 328 of file lws-struct.h.

328#define LSM_JO_SCHEMA_DLL2(ctype, cdll2mem, lejp_cb, map, schema_name) \
329 { \
330 schema_name, \
331 map, \
332 lejp_cb, \
333 offsetof(ctype, cdll2mem), \
334 sizeof (ctype), \
335 0, \
336 LWS_ARRAY_SIZE(map), \
337 LSMT_SCHEMA, \
338 1, \
339 }

◆ LSM_BLOB_PTR

#define LSM_BLOB_PTR ( type,
blobptr_name,
qname )
Value:
{ \
qname, /* JSON item, or sqlite3 column name */ \
NULL, \
NULL, \
offsetof(type, blobptr_name), /* member that points to blob */ \
sizeof (((type *)0)->blobptr_name), /* size of blob pointer */ \
0, /* member holding blob len */ \
0, /* size of blob length member */ \
0, \
}
@ LSMT_BLOB_PTR
Definition lws-struct.h:46

Definition at line 347 of file lws-struct.h.

347#define LSM_BLOB_PTR(type, blobptr_name, qname) \
348 { \
349 qname, /* JSON item, or sqlite3 column name */ \
350 NULL, \
351 NULL, \
352 offsetof(type, blobptr_name), /* member that points to blob */ \
353 sizeof (((type *)0)->blobptr_name), /* size of blob pointer */ \
354 0, /* member holding blob len */ \
355 0, /* size of blob length member */ \
356 LSMT_BLOB_PTR, \
357 0, \
358 }

Typedef Documentation

◆ lejp_collation_t

◆ lws_struct_map_t

◆ lws_struct_args_cb

typedef int(* lws_struct_args_cb) (void *obj, void *cb_arg)

Definition at line 68 of file lws-struct.h.

◆ lws_struct_args_t

◆ lws_struct_serialize_st_t

◆ lws_struct_serialize_t

◆ sqlite3

typedef struct sqlite3 sqlite3

Definition at line 476 of file lws-struct.h.

Enumeration Type Documentation

◆ lws_struct_map_type_eum

Enumerator
LSMT_SIGNED 
LSMT_UNSIGNED 
LSMT_BOOLEAN 
LSMT_STRING_CHAR_ARRAY 
LSMT_STRING_PTR 
LSMT_LIST 
LSMT_CHILD_PTR 
LSMT_SCHEMA 
LSMT_BLOB_PTR 

Definition at line 37 of file lws-struct.h.

◆ anonymous enum

anonymous enum
Enumerator
LSSERJ_FLAG_PRETTY 
LSSERJ_FLAG_OMIT_SCHEMA 

Definition at line 371 of file lws-struct.h.

371 {
372 LSSERJ_FLAG_PRETTY = (1 << 0),
373 LSSERJ_FLAG_OMIT_SCHEMA = (1 << 1)
374};
@ LSSERJ_FLAG_OMIT_SCHEMA
Definition lws-struct.h:373
@ LSSERJ_FLAG_PRETTY
Definition lws-struct.h:372

◆ lws_struct_json_serialize_result_t

Enumerator
LSJS_RESULT_CONTINUE 
LSJS_RESULT_FINISH 
LSJS_RESULT_ERROR 

Definition at line 386 of file lws-struct.h.

386 {
lws_struct_json_serialize_result_t
Definition lws-struct.h:386
@ LSJS_RESULT_CONTINUE
Definition lws-struct.h:387
@ LSJS_RESULT_FINISH
Definition lws-struct.h:388
@ LSJS_RESULT_ERROR
Definition lws-struct.h:389

Function Documentation

◆ lws_struct_json_init_parse()

LWS_VISIBLE LWS_EXTERN int lws_struct_json_init_parse ( struct lejp_ctx * ctx,
lejp_callback cb,
void * user )

lws_struct_json_init_parse(): prepare to translate JSON to C struct

ctx: JSON parse context cb: the parsing callback user: an opaque user pointer

Returns 0 if OK else nonzero for error.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_schema_only_lejp_cb()

LWS_VISIBLE LWS_EXTERN signed char lws_struct_schema_only_lejp_cb ( struct lejp_ctx * ctx,
char reason )

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_default_lejp_cb()

LWS_VISIBLE LWS_EXTERN signed char lws_struct_default_lejp_cb ( struct lejp_ctx * ctx,
char reason )

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_json_serialize_create()

LWS_VISIBLE LWS_EXTERN lws_struct_serialize_t * lws_struct_json_serialize_create ( const lws_struct_map_t * map,
size_t map_entries,
int flags,
const void * ptoplevel )

lws_struct_json_serialize_create(): create a C struct -> JSON renderer

map: the map of members and types map_entries: the count of entries in the map flags: JSON parsing options ptoplevel: the start of the C struct to render

Returns an object that manages the stateful translation of a C struct to a JSON representation.

Returns a pointer to the object, or NULL on failure.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_json_serialize()

LWS_VISIBLE LWS_EXTERN lws_struct_json_serialize_result_t lws_struct_json_serialize ( lws_struct_serialize_t * js,
uint8_t * buf,
size_t len,
size_t * written )

lws_struct_json_serialize(): output the next buffer of JSON

js: the management object buf: the output fragment buffer len: the max size of buf written: pointer to a size_t to be set to the valid about in buf on exit

This emits the next section of JSON for the object being represented by js. You must refer to the return from the function to understand what is in the buffer on exit, LSJS_RESULT_ERROR indicates the function failed and the buffer is invalid, LSJS_RESULT_CONTINUE indicates the buffer is valid, but is a fragment of the full representation and you should call this function again later to get another fragment, and LSJS_RESULT_FINISH indicates the buffer is valid and is the last part of the representation.

After seeing LSJS_RESULT_FINISH or LSJS_RESULT_ERROR you should clean up \js by calling lws_struct_json_serialize_destroy() on it

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_json_serialize_destroy()

LWS_VISIBLE LWS_EXTERN void lws_struct_json_serialize_destroy ( lws_struct_serialize_t ** pjs)

lws_struct_json_serialize_destroy(): destruct a C struct -> JSON renderer

pjs: pointer to the object to be destroyed

The object to be destroyed should have been returned originally from lws_struct_json_serialize_create()

◆ lws_struct_sq3_open()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_open ( struct lws_context * context,
const char * sqlite3_path,
char create_if_missing,
sqlite3 ** pdb )

lws_struct_sq3_open(): open an sqlite3 database

context: the lws_context sqlite3_path: the filepath to the database file create_if_missing: flag to control if the database is created or not if absent pdb: pointer to an sqlite3 * to be set to the database handle if successful

Returns 0 for success, *pdb is valid, else nonzero for failure

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_sq3_close()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_close ( sqlite3 ** pdb)

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_sq3_create_table()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_create_table ( sqlite3 * pdb,
const lws_struct_map_t * schema )

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_sq3_serialize()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_serialize ( sqlite3 * pdb,
const lws_struct_map_t * schema,
lws_dll2_owner_t * owner,
uint32_t manual_idx )

lws_struct_sq3_serialize(): store objects pointed to by owner in the db

pdb: the open sqlite3 db schema: the schema (and db table) to use owner: the list of objects to store to the db table manual_idx: the starting index for the objects

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_sq3_update()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_update ( sqlite3 * pdb,
const char * table,
const lws_struct_map_t * map,
size_t map_entries,
const void * data,
const char * where_col )

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_sq3_upsert()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_upsert ( sqlite3 * pdb,
const char * table,
const lws_struct_map_t * map,
size_t map_entries,
const void * data,
const char * where_col )

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_struct_sq3_deserialize()

LWS_VISIBLE LWS_EXTERN int lws_struct_sq3_deserialize ( sqlite3 * pdb,
const char * filter,
const char * order,
const lws_struct_map_t * schema,
lws_dll2_owner_t * o,
struct lwsac ** ac,
int start,
int limit )