Loading...
Searching...
No Matches
printer_data.h File Reference

Data printers for libyang. More...

`#include <stdint.h>`
`#include <stdio.h>`
`#include "log.h"`
`#include "out.h"`
`#include "tree_data.h"`
Include dependency graph for printer_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | LYD_PRINT_KEEPEMPTYCONT 0x04
#define | LYD_PRINT_SHRINK LY_PRINT_SHRINK
#define | LYD_PRINT_WD_ALL 0x20
#define | LYD_PRINT_WD_ALL_TAG 0x40
#define | LYD_PRINT_WD_EXPLICIT 0x00
#define | LYD_PRINT_WD_IMPL_TAG 0x80
#define | LYD_PRINT_WD_MASK 0xF0
#define | LYD_PRINT_WD_TRIM 0x10
#define | LYD_PRINT_WITHSIBLINGS 0x01

## Functions

LIBYANG_API_DECL ly_bool | lyd_metadata_should_print (const struct lyd_meta *meta)
| Check whether the metadata should be printed.
LIBYANG_API_DECL ly_bool | lyd_node_should_print (const struct lyd_node *node, uint32_t options)
| Check whether the node should be printed based on the printing options.
LIBYANG_API_DECL LY_ERR | lyd_print_all (struct ly_out *out, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print the whole data tree of the root, including all the siblings.
LIBYANG_API_DECL LY_ERR | lyd_print_clb (ly_write_clb writeclb, void *user_data, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print data tree in the specified format.
LIBYANG_API_DECL LY_ERR | lyd_print_fd (int fd, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print data tree in the specified format.
LIBYANG_API_DECL LY_ERR | lyd_print_file (FILE *f, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print data tree in the specified format.
LIBYANG_API_DECL LY_ERR | lyd_print_mem (char **strp, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print data tree in the specified format.
LIBYANG_API_DECL LY_ERR | lyd_print_path (const char *path, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print data tree in the specified format.
LIBYANG_API_DECL LY_ERR | lyd_print_tree (struct ly_out *out, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
| Print the selected data subtree.

## Detailed Description

Data printers for libyang.

Author
  Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz
  Michal Vasko mvask.nosp@m.o@ce.nosp@m.snet..nosp@m.cz

Copyright (c) 2015 - 2025 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

Definition in file printer_data.h.

## Function Documentation

## lyd_metadata_should_print()

LIBYANG_API_DECL ly_bool lyd_metadata_should_print | ( | const struct lyd_meta * | meta | ) |

Check whether the metadata should be printed.

Parameters

  [in] | meta | Metadata to check.

Returns
  0 if not,
  non-0 if should be printed.

## lyd_node_should_print()

LIBYANG_API_DECL ly_bool lyd_node_should_print | ( | const struct lyd_node * | node,
|  | uint32_t | options
| ) |  |

Check whether the node should be printed based on the printing options.

Parameters

  [in] | node | Node to check.
  [in] | options | Data printer flags.

Returns
  0 if not,
  non-0 if should be printed.

## lyd_print_all()

LIBYANG_API_DECL LY_ERR lyd_print_all | ( | struct ly_out * | out,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print the whole data tree of the root, including all the siblings.

Parameters

  [in] | out | Printer handler for a specific output. Use ly_out_*() functions to create and free the handler.
  [in] | root | The root element of the tree to print, can be any sibling.
  [in] | format | Output format.
  [in] | options | Data printer flags except LYD_PRINT_WITHSIBLINGS.

Returns
  LY_ERR value.

## lyd_print_clb()

LIBYANG_API_DECL LY_ERR lyd_print_clb | ( | ly_write_clb | writeclb,
|  | void * | user_data,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print data tree in the specified format.

Parameters

  [in] | writeclb | Callback function to write the data (see write(1)).
  [in] | user_data | Optional caller-specific argument to be passed to the `writeclb` callback.
  [in] | root | The root element of the (sub)tree to print.
  [in] | format | Output format.
  [in] | options | Data printer flags.

Returns
  LY_ERR value.

## lyd_print_fd()

LIBYANG_API_DECL LY_ERR lyd_print_fd | ( | int | fd,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print data tree in the specified format.

Parameters

  [in] | fd | File descriptor where to print the data.
  [in] | root | The root element of the (sub)tree to print.
  [in] | format | Output format.
  [in] | options | Data printer flags.

Returns
  LY_ERR value.

## lyd_print_file()

LIBYANG_API_DECL LY_ERR lyd_print_file | ( | FILE * | f,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print data tree in the specified format.

Parameters

  [in] | f | File stream where to print the data.
  [in] | root | The root element of the (sub)tree to print.
  [in] | format | Output format.
  [in] | options | Data printer flags.

Returns
  LY_ERR value.

## lyd_print_mem()

LIBYANG_API_DECL LY_ERR lyd_print_mem | ( | char ** | strp,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print data tree in the specified format.

Parameters

  [out] | strp | Pointer to store the resulting dump.
  [in] | root | The root element of the (sub)tree to print.
  [in] | format | Output format.
  [in] | options | Data printer flags.

Returns
  LY_ERR value.

## lyd_print_path()

LIBYANG_API_DECL LY_ERR lyd_print_path | ( | const char * | path,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print data tree in the specified format.

Parameters

  [in] | path | File path where to print the data.
  [in] | root | The root element of the (sub)tree to print.
  [in] | format | Output format.
  [in] | options | Data printer flags.

Returns
  LY_ERR value.

## lyd_print_tree()

LIBYANG_API_DECL LY_ERR lyd_print_tree | ( | struct ly_out * | out,
|  | const struct lyd_node * | root,
|  | LYD_FORMAT | format,
|  | uint32_t | options
| ) |  |

Print the selected data subtree.

Parameters

  [in] | out | Printer handler for a specific output. Use ly_out_*() functions to create and free the handler.
  [in] | root | The root element of the subtree to print.
  [in] | format | Output format.
  [in] | options | Data printer flags except LYD_PRINT_WITHSIBLINGS.

Returns
  LY_ERR value.