summaryrefslogtreecommitdiffstats
path: root/src/in_internal.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:20:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:20:26 +0000
commit044203039cebe3c05161f8f104a039d4744ca6d0 (patch)
tree1073c2308492e6aea4c66cb7436ee92db2abfd42 /src/in_internal.h
parentInitial commit. (diff)
downloadlibyang2-044203039cebe3c05161f8f104a039d4744ca6d0.tar.xz
libyang2-044203039cebe3c05161f8f104a039d4744ca6d0.zip
Adding upstream version 2.1.30.upstream/2.1.30
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/in_internal.h')
-rw-r--r--src/in_internal.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/in_internal.h b/src/in_internal.h
new file mode 100644
index 0000000..cbc56da
--- /dev/null
+++ b/src/in_internal.h
@@ -0,0 +1,50 @@
+/**
+ * @file in_internal.h
+ * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
+ * @brief Internal structures and functions for libyang parsers
+ *
+ * Copyright (c) 2020 - 2023 CESNET, z.s.p.o.
+ *
+ * This source code is licensed under BSD 3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#ifndef LY_IN_INTERNAL_H_
+#define LY_IN_INTERNAL_H_
+
+#include "in.h"
+
+/**
+ * @brief Parser input structure specifying where the data are read.
+ */
+struct ly_in {
+ LY_IN_TYPE type; /**< type of the output to select the output method */
+ const char *current; /**< Current position in the input data */
+ const char *func_start; /**< Input data position when the last parser function was executed */
+ const char *start; /**< Input data start */
+ size_t length; /**< mmap() length (if used) */
+
+ union {
+ int fd; /**< file descriptor for LY_IN_FD type */
+ FILE *f; /**< file structure for LY_IN_FILE and LY_IN_FILEPATH types */
+
+ struct {
+ int fd; /**< file descriptor for LY_IN_FILEPATH */
+ char *filepath; /**< stored original filepath */
+ } fpath; /**< filepath structure for LY_IN_FILEPATH */
+ } method; /**< type-specific information about the output */
+ uint64_t line; /**< current line of the input */
+};
+
+/**
+ * @brief Increment line counter.
+ * @param[in] IN The input handler.
+ */
+#define LY_IN_NEW_LINE(IN) \
+ (IN)->line++
+
+#endif /* LY_IN_INTERNAL_H_ */