blob: 1162cc23a288f28409bafc4aa04ac661d6059246 [file] [log] [blame]
Radek Krejcid3ca0632019-04-16 16:54:54 +02001/**
2 * @file printer_schema.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief Schema printers for libyang
5 *
6 * Copyright (c) 2015-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#ifndef LY_PRINTER_SCHEMA_H_
16#define LY_PRINTER_SCHEMA_H_
17
Radek Krejcie7b95092019-05-15 11:03:07 +020018#include <stdio.h>
Radek Krejcid3ca0632019-04-16 16:54:54 +020019#include <unistd.h>
20
Radek Krejcia5bba312020-01-09 15:41:20 +010021#include "printer.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020022#include "tree_schema.h"
23
Radek Krejci2ff0d572020-05-21 15:27:28 +020024/**
25 * @addtogroup schematree
26 * @{
27 */
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080028
29/**
30 * @defgroup schemaprinterflags Schema output options
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080031 * @{
32 */
Radek Krejci4fa6ebf2019-11-21 13:34:35 +080033#define LYS_OUTPUT_NO_SUBSTMT 0x10 /**< Print only top-level/referede node information,
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080034 do not print information from the substatements */
35//#define LYS_OUTOPT_TREE_RFC 0x01 /**< Conform to the RFC TODO tree output (only for tree format) */
36//#define LYS_OUTOPT_TREE_GROUPING 0x02 /**< Print groupings separately (only for tree format) */
37//#define LYS_OUTOPT_TREE_USES 0x04 /**< Print only uses instead the resolved grouping nodes (only for tree format) */
38//#define LYS_OUTOPT_TREE_NO_LEAFREF 0x08 /**< Do not print the target of leafrefs (only for tree format) */
39
Radek Krejci2ff0d572020-05-21 15:27:28 +020040/** @} schemaprinterflags */
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080041
Radek Krejcid3ca0632019-04-16 16:54:54 +020042/**
Radek Krejcia5bba312020-01-09 15:41:20 +010043 * @brief Schema module printer.
Radek Krejcid3ca0632019-04-16 16:54:54 +020044 *
Radek Krejcia5bba312020-01-09 15:41:20 +010045 * @param[in] out Printer handler for a specific output. Use lyp_*() functions to create the handler and lyp_free() to remove the handler.
46 * @param[in] module Schema to print.
47 * @param[in] format Output format.
Radek Krejcid3ca0632019-04-16 16:54:54 +020048 * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE printer.
49 * @param[in] options Schema output options (see @ref schemaprinterflags).
Radek Krejci897ad2e2019-04-29 16:43:07 +020050 * @return Number of printed bytes in case of success.
51 * @return Negative value failure (absolute value corresponds to LY_ERR values).
Radek Krejcid3ca0632019-04-16 16:54:54 +020052 */
Radek Krejcia5bba312020-01-09 15:41:20 +010053ssize_t lys_print(struct lyp_out *out, const struct lys_module *module, LYS_OUTFORMAT format, int line_length, int options);
Radek Krejcid3ca0632019-04-16 16:54:54 +020054
55/**
Radek Krejcia5bba312020-01-09 15:41:20 +010056 * @brief Schema node printer.
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080057 *
Radek Krejcia5bba312020-01-09 15:41:20 +010058 * @param[in] out Printer handler for a specific output. Use lyp_*() functions to create the handler and lyp_free() to remove the handler.
59 * @param[in] node Schema node to print, lys_find_node() can be used to get it from a path string.
60 * @param[in] format Output format.
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080061 * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE printer.
62 * @param[in] options Schema output options (see @ref schemaprinterflags).
63 * @return Number of printed bytes in case of success.
64 * @return Negative value failure (absolute value corresponds to LY_ERR values).
65 */
Radek Krejcia5bba312020-01-09 15:41:20 +010066ssize_t lys_print_node(struct lyp_out *out, const struct lysc_node *node, LYS_OUTFORMAT format, int line_length, int options);
Radek Krejcid8c0f5e2019-11-17 12:18:34 +080067
Radek Krejci2ff0d572020-05-21 15:27:28 +020068/** @} schematree */
69
Radek Krejcid3ca0632019-04-16 16:54:54 +020070#endif /* LY_PRINTER_SCHEMA_H_ */