Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file in_internal.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
Michal Vasko | 62c3726 | 2023-01-11 11:12:46 +0100 | [diff] [blame] | 4 | * @author Michal Vasko <mvasko@cesnet.cz> |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 5 | * @brief Internal structures and functions for libyang parsers |
| 6 | * |
Michal Vasko | 62c3726 | 2023-01-11 11:12:46 +0100 | [diff] [blame] | 7 | * Copyright (c) 2020 - 2023 CESNET, z.s.p.o. |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 8 | * |
| 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
| 14 | */ |
| 15 | |
| 16 | #ifndef LY_IN_INTERNAL_H_ |
| 17 | #define LY_IN_INTERNAL_H_ |
| 18 | |
| 19 | #include "in.h" |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * @brief Parser input structure specifying where the data are read. |
| 23 | */ |
| 24 | struct ly_in { |
| 25 | LY_IN_TYPE type; /**< type of the output to select the output method */ |
| 26 | const char *current; /**< Current position in the input data */ |
| 27 | const char *func_start; /**< Input data position when the last parser function was executed */ |
| 28 | const char *start; /**< Input data start */ |
| 29 | size_t length; /**< mmap() length (if used) */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 30 | |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 31 | union { |
| 32 | int fd; /**< file descriptor for LY_IN_FD type */ |
| 33 | FILE *f; /**< file structure for LY_IN_FILE and LY_IN_FILEPATH types */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 34 | |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 35 | struct { |
| 36 | int fd; /**< file descriptor for LY_IN_FILEPATH */ |
| 37 | char *filepath; /**< stored original filepath */ |
| 38 | } fpath; /**< filepath structure for LY_IN_FILEPATH */ |
| 39 | } method; /**< type-specific information about the output */ |
Radek Krejci | d54412f | 2020-12-17 20:25:35 +0100 | [diff] [blame] | 40 | uint64_t line; /**< current line of the input */ |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /** |
Radek Krejci | d54412f | 2020-12-17 20:25:35 +0100 | [diff] [blame] | 44 | * @brief Increment line counter. |
| 45 | * @param[in] IN The input handler. |
| 46 | */ |
| 47 | #define LY_IN_NEW_LINE(IN) \ |
| 48 | (IN)->line++ |
| 49 | |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 50 | #endif /* LY_IN_INTERNAL_H_ */ |