5#ifndef OPENTITAN_SW_DEVICE_LIB_UJSON_UJSON_H_
6#define OPENTITAN_SW_DEVICE_LIB_UJSON_UJSON_H_
9#include "sw/device/lib/base/status.h"
21 status_t (*
putbuf)(
void *,
const char *, size_t);
31#define UJSON_INIT(context_, getc_, putbuf_) \
33 .io_context = (void*)(context_), \
34 .putbuf_ = (putbuf_), \
37 .crc32 = UINT32_MAX, \
49ujson_t ujson_init(
void *context, status_t (*getc)(
void *),
50 status_t (*putbuf)(
void *,
const char *,
size_t));
58status_t ujson_getc(ujson_t *uj);
67status_t ujson_ungetc(ujson_t *uj,
char ch);
77status_t ujson_putbuf(ujson_t *uj,
const char *buf,
size_t len);
84void ujson_crc32_reset(ujson_t *uj);
95uint32_t ujson_crc32_finish(ujson_t *uj);
104bool ujson_streq(
const char *a,
const char *b);
116status_t ujson_consume(ujson_t *uj,
char ch);
129status_t ujson_consume_maybe(ujson_t *uj,
char ch);
145status_t ujson_parse_qs(ujson_t *uj,
char *str,
size_t len);
155status_t ujson_parse_integer(ujson_t *uj,
void *result,
size_t rsz);
160status_t ujson_deserialize_uint64_t(ujson_t *uj, uint64_t *value);
161status_t ujson_deserialize_uint32_t(ujson_t *uj, uint32_t *value);
162status_t ujson_deserialize_uint16_t(ujson_t *uj, uint16_t *value);
163status_t ujson_deserialize_uint8_t(ujson_t *uj, uint8_t *value);
164status_t ujson_deserialize_size_t(ujson_t *uj,
size_t *value);
165status_t ujson_deserialize_int64_t(ujson_t *uj, int64_t *value);
166status_t ujson_deserialize_int32_t(ujson_t *uj, int32_t *value);
167status_t ujson_deserialize_int16_t(ujson_t *uj, int16_t *value);
168status_t ujson_deserialize_int8_t(ujson_t *uj, int8_t *value);
177status_t ujson_deserialize_bool(ujson_t *uj,
bool *value);
186status_t ujson_deserialize_status_t(ujson_t *uj, status_t *value);
195status_t ujson_serialize_string(ujson_t *uj,
const char *buf);
204status_t ujson_serialize_uint64_t(ujson_t *uj,
const uint64_t *value);
205status_t ujson_serialize_uint32_t(ujson_t *uj,
const uint32_t *value);
206status_t ujson_serialize_uint16_t(ujson_t *uj,
const uint16_t *value);
207status_t ujson_serialize_uint8_t(ujson_t *uj,
const uint8_t *value);
208status_t ujson_serialize_size_t(ujson_t *uj,
const size_t *value);
209status_t ujson_serialize_int64_t(ujson_t *uj,
const int64_t *value);
210status_t ujson_serialize_int32_t(ujson_t *uj,
const int32_t *value);
211status_t ujson_serialize_int16_t(ujson_t *uj,
const int16_t *value);
212status_t ujson_serialize_int8_t(ujson_t *uj,
const int8_t *value);
221status_t ujson_serialize_bool(ujson_t *uj,
const bool *value);
230status_t ujson_serialize_status_t(ujson_t *uj,
const status_t *value);