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