Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1 | /** |
| 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 Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 18 | #include <stdio.h> |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 19 | #include <unistd.h> |
| 20 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 21 | #include "tree_schema.h" |
| 22 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 23 | /** |
| 24 | * @brief Print schema tree in the specified format into a memory block. |
| 25 | * It is up to caller to free the returned string by free(). |
| 26 | * |
| 27 | * @param[out] strp Pointer to store the resulting dump. |
| 28 | * @param[in] module Schema tree to print. |
| 29 | * @param[in] format Schema output format. |
| 30 | * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE printer. |
| 31 | * @param[in] options Schema output options (see @ref schemaprinterflags). |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 32 | * @return Number of printed bytes in case of success. |
| 33 | * @return Negative value failure (absolute value corresponds to LY_ERR values). |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 34 | */ |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 35 | ssize_t lys_print_mem(char **strp, const struct lys_module *module, LYS_OUTFORMAT format, int line_length, int options); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * @brief Print schema tree in the specified format into a file descriptor. |
| 39 | * |
| 40 | * @param[in] module Schema tree to print. |
| 41 | * @param[in] fd File descriptor where to print the data. |
| 42 | * @param[in] format Schema output format. |
| 43 | * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE format. |
| 44 | * @param[in] options Schema output options (see @ref schemaprinterflags). |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 45 | * @return Number of printed bytes in case of success. |
| 46 | * @return Negative value failure (absolute value corresponds to LY_ERR values). |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 47 | */ |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 48 | ssize_t lys_print_fd(int fd, const struct lys_module *module, LYS_OUTFORMAT format, int line_length, int options); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * @brief Print schema tree in the specified format into a file stream. |
| 52 | * |
| 53 | * @param[in] module Schema tree to print. |
| 54 | * @param[in] f File stream where to print the schema. |
| 55 | * @param[in] format Schema output format. |
| 56 | * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE printer. |
| 57 | * @param[in] options Schema output options (see @ref schemaprinterflags). |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 58 | * @return Number of printed bytes in case of success. |
| 59 | * @return Negative value failure (absolute value corresponds to LY_ERR values). |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 60 | */ |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 61 | ssize_t lys_print_file(FILE *f, const struct lys_module *module, LYS_OUTFORMAT format, int line_length, int options); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * @brief Print schema tree in the specified format into a file. |
| 65 | * |
| 66 | * @param[in] path File where to print the schema. |
| 67 | * @param[in] module Schema tree to print. |
| 68 | * @param[in] format Schema output format. |
| 69 | * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE printer. |
| 70 | * @param[in] options Schema output options (see @ref schemaprinterflags). |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 71 | * @return Number of printed bytes in case of success. |
| 72 | * @return Negative value failure (absolute value corresponds to LY_ERR values). |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 73 | */ |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 74 | ssize_t lys_print_path(const char *path, const struct lys_module *module, LYS_OUTFORMAT format, int line_length, int options); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * @brief Print schema tree in the specified format using a provided callback. |
| 78 | * |
| 79 | * @param[in] module Schema tree to print. |
| 80 | * @param[in] writeclb Callback function to write the data (see write(1)). |
| 81 | * @param[in] arg Optional caller-specific argument to be passed to the \p writeclb callback. |
| 82 | * @param[in] format Schema output format. |
| 83 | * @param[in] line_length Maximum characters to be printed on a line, 0 for unlimited. Only for #LYS_OUT_TREE printer. |
| 84 | * @param[in] options Schema output options (see @ref schemaprinterflags). |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 85 | * @return Number of printed bytes in case of success. |
| 86 | * @return Negative value failure (absolute value corresponds to LY_ERR values). |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 87 | */ |
Radek Krejci | 897ad2e | 2019-04-29 16:43:07 +0200 | [diff] [blame] | 88 | ssize_t lys_print_clb(ssize_t (*writeclb)(void *arg, const void *buf, size_t count), void *arg, |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 89 | const struct lys_module *module, LYS_OUTFORMAT format, int line_length, int options); |
| 90 | |
| 91 | #endif /* LY_PRINTER_SCHEMA_H_ */ |