Skip to content

Commit eca60ef

Browse files
committed
ADD CBOR support
1 parent a71131e commit eca60ef

10 files changed

Lines changed: 262 additions & 459 deletions

File tree

src/lcbor.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,14 @@ lydcbor_detect_format(struct ly_in *in, enum lyd_cbor_format *format)
7777
LY_ERR
7878
lycbor_ctx_new(const struct ly_ctx *ctx, struct ly_in *in, struct lycbor_ctx **cborctx_p)
7979
{
80-
/* TODO : Need to restructure error handling here */
8180
LY_ERR ret = LY_SUCCESS;
8281
struct lycbor_ctx *cborctx;
8382
struct cbor_load_result result = {0};
8483
enum lyd_cbor_format format;
8584

8685
assert(ctx && in && cborctx_p);
8786

88-
/* TODO : error handling after the detect_format function call */
89-
ret = lydcbor_detect_format(in, &format);
87+
LY_CHECK_RET(lydcbor_detect_format(in, &format));
9088

9189
/* Allocate and initialize CBOR context */
9290
cborctx = calloc(1, sizeof *cborctx);
@@ -95,7 +93,7 @@ lycbor_ctx_new(const struct ly_ctx *ctx, struct ly_in *in, struct lycbor_ctx **c
9593
cborctx->in = in;
9694
cborctx->format = format;
9795

98-
/* input line logging */
96+
/* input line logging */
9997
ly_log_location(NULL, NULL, in);
10098

10199
/* load and parse CBOR data */

src/lcbor.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
/* using libcbor as the low-level parser */
2121
#include <cbor.h>
2222

23-
2423
#include "log.h"
2524
#include "set.h"
2625

@@ -30,8 +29,7 @@ struct ly_in;
3029
/**
3130
* @brief CBOR format variants for different encoding schemes
3231
*/
33-
enum lyd_cbor_format
34-
{
32+
enum lyd_cbor_format {
3533
LYD_CBOR_NAMED, /**< CBOR with named identifiers (JSON-like) */
3634
LYD_CBOR_SID /**< CBOR with Schema Item identifiers (future implementation) */
3735
};

0 commit comments

Comments
 (0)