blob: 400b078896dc2b097ea7da6afd096ce6a330488a [file] [log] [blame]
Michal Vasko90932a92020-02-12 14:33:03 +01001/**
2 * @file parser_json.c
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief JSON data parser for libyang
5 *
6 * Copyright (c) 2019 CESNET, z.s.p.o.
7 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
14
15#include "common.h"
16
17#include <stdint.h>
18#include <stdlib.h>
19#include <string.h>
20
21#include "context.h"
22#include "dict.h"
23#include "log.h"
24#include "plugins_types.h"
25#include "set.h"
26#include "tree_data.h"
27#include "tree_data_internal.h"
28#include "tree_schema.h"
29#include "xml.h"
30#include "validation.h"
31
32/**
33 * @brief JSON-parser's implementation of ly_type_resolve_prefix() callback to provide mapping between prefixes used
34 * in the values to the schema via context module names.
35 */
36const struct lys_module *
37lydjson_resolve_prefix(struct ly_ctx *ctx, const char *prefix, size_t prefix_len, void *UNUSED(parser))
38{
39 const struct lys_module *mod;
40 char *name;
41
42 name = strndup(prefix, prefix_len);
43 if (!name) {
44 return NULL;
45 }
46
47 mod = ly_ctx_get_module_implemented(ctx, name);
48 free(name);
49 return mod;
50}