Radek Krejci | f0e1ba5 | 2020-05-22 15:14:35 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file parser_internal.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief Internal structures and functions for libyang parsers |
| 5 | * |
| 6 | * Copyright (c) 2020 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 | #ifndef LY_PARSER_INTERNAL_H_ |
| 16 | #define LY_PARSER_INTERNAL_H_ |
| 17 | |
| 18 | #include "parser.h" |
| 19 | #include "tree_schema_internal.h" |
| 20 | |
| 21 | /** |
Radek Krejci | 7931b19 | 2020-06-25 17:05:03 +0200 | [diff] [blame] | 22 | * @brief Mask for checking LYD_PARSE_ options (@ref dataparseroptions) |
| 23 | */ |
| 24 | #define LYD_PARSE_OPTS_MASK 0xFFFF0000 |
| 25 | |
| 26 | /** |
| 27 | * @brief Mask for checking LYD_VALIDATEP_ options (@ref datavalidationoptions) |
| 28 | */ |
| 29 | #define LYD_VALIDATE_OPTS_MASK 0x0000FFFF |
| 30 | |
| 31 | /** |
Radek Krejci | f0e1ba5 | 2020-05-22 15:14:35 +0200 | [diff] [blame] | 32 | * @brief Parser input structure specifying where the data are read. |
| 33 | */ |
| 34 | struct ly_in { |
| 35 | LY_IN_TYPE type; /**< type of the output to select the output method */ |
| 36 | const char *current; |
| 37 | const char *start; |
| 38 | size_t length; |
| 39 | union { |
| 40 | int fd; /**< file descriptor for LY_IN_FD type */ |
| 41 | FILE *f; /**< file structure for LY_IN_FILE and LY_IN_FILEPATH types */ |
| 42 | struct { |
| 43 | int fd; /**< file descriptor for LY_IN_FILEPATH */ |
| 44 | char *filepath; /**< stored original filepath */ |
| 45 | } fpath; /**< filepath structure for LY_IN_FILEPATH */ |
| 46 | } method; /**< type-specific information about the output */ |
| 47 | }; |
| 48 | |
| 49 | /** |
| 50 | * @brief Parse submodule from YANG data. |
| 51 | * @param[in,out] ctx Parser context. |
| 52 | * @param[in] ly_ctx Context of YANG schemas. |
| 53 | * @param[in] main_ctx Parser context of main module. |
| 54 | * @param[in] data Input data to be parsed. |
| 55 | * @param[out] submod Pointer to the parsed submodule structure. |
| 56 | * @return LY_ERR value - LY_SUCCESS, LY_EINVAL or LY_EVALID. |
| 57 | */ |
| 58 | LY_ERR yang_parse_submodule(struct lys_yang_parser_ctx **context, struct ly_ctx *ly_ctx, struct lys_parser_ctx *main_ctx, |
| 59 | const char *data, struct lysp_submodule **submod); |
| 60 | |
| 61 | /** |
| 62 | * @brief Parse module from YANG data. |
| 63 | * @param[in] ctx Parser context. |
| 64 | * @param[in] data Input data to be parsed. |
| 65 | * @param[in, out] mod Prepared module structure where the parsed information, including the parsed |
| 66 | * module structure, will be filled in. |
| 67 | * @return LY_ERR value - LY_SUCCESS, LY_EINVAL or LY_EVALID. |
| 68 | */ |
| 69 | LY_ERR yang_parse_module(struct lys_yang_parser_ctx **context, const char *data, struct lys_module *mod); |
| 70 | |
| 71 | /** |
| 72 | * @brief Parse module from YIN data. |
| 73 | * |
| 74 | * @param[in,out] yin_ctx Context created during parsing, is used to finalize lysp_model after it's completly parsed. |
| 75 | * @param[in] data Input data to be parsed. |
| 76 | * @param[in,out] mod Prepared module structure where the parsed information, including the parsed |
| 77 | * module structure, will be filled in. |
| 78 | * |
| 79 | * @return LY_ERR values. |
| 80 | */ |
| 81 | LY_ERR yin_parse_module(struct lys_yin_parser_ctx **yin_ctx, const char *data, struct lys_module *mod); |
| 82 | |
| 83 | /** |
| 84 | * @brief Parse submodule from YIN data. |
| 85 | * |
| 86 | * @param[in,out] yin_ctx Context created during parsing, is used to finalize lysp_model after it's completly parsed. |
| 87 | * @param[in] ctx Libyang context. |
| 88 | * @param[in] main_ctx Parser context of main module. |
| 89 | * @param[in,out] data Input data to be parsed. |
| 90 | * @param[in,out] submod Submodule structure where the parsed information, will be filled in. |
| 91 | * @return LY_ERR values. |
| 92 | */ |
| 93 | LY_ERR yin_parse_submodule(struct lys_yin_parser_ctx **yin_ctx, struct ly_ctx *ctx, struct lys_parser_ctx *main_ctx, |
| 94 | const char *data, struct lysp_submodule **submod); |
| 95 | |
| 96 | #endif /* LY_PARSER_INTERNAL_H_ */ |