blob: cbc56daae17ca22bcdd1a9ee65c0f1e369c8f162 [file] [log] [blame]
Michal Vaskoafac7822020-10-20 14:22:26 +02001/**
2 * @file in_internal.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
Michal Vasko62c37262023-01-11 11:12:46 +01004 * @author Michal Vasko <mvasko@cesnet.cz>
Michal Vaskoafac7822020-10-20 14:22:26 +02005 * @brief Internal structures and functions for libyang parsers
6 *
Michal Vasko62c37262023-01-11 11:12:46 +01007 * Copyright (c) 2020 - 2023 CESNET, z.s.p.o.
Michal Vaskoafac7822020-10-20 14:22:26 +02008 *
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 Vaskoafac7822020-10-20 14:22:26 +020020
21/**
22 * @brief Parser input structure specifying where the data are read.
23 */
24struct 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 Vasko26bbb272022-08-02 14:54:33 +020030
Michal Vaskoafac7822020-10-20 14:22:26 +020031 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 Vasko26bbb272022-08-02 14:54:33 +020034
Michal Vaskoafac7822020-10-20 14:22:26 +020035 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 Krejcid54412f2020-12-17 20:25:35 +010040 uint64_t line; /**< current line of the input */
Michal Vaskoafac7822020-10-20 14:22:26 +020041};
42
43/**
Radek Krejcid54412f2020-12-17 20:25:35 +010044 * @brief Increment line counter.
45 * @param[in] IN The input handler.
46 */
47#define LY_IN_NEW_LINE(IN) \
48 (IN)->line++
49
Michal Vaskoafac7822020-10-20 14:22:26 +020050#endif /* LY_IN_INTERNAL_H_ */