blob: 9ce7dd86c739a01e7d49dfcea05ae0ccb65bf757 [file] [log] [blame]
/**
* @file printer.h
* @author Radek Krejci <rkrejci@cesnet.cz>
* @brief Printers for libyang
*
* Copyright (c) 2015 CESNET, z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Company nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*/
#ifndef LY_PRINTER_H_
#define LY_PRINTER_H_
#include "libyang.h"
#include "tree_schema.h"
#include "tree_internal.h"
typedef enum LYOUT_TYPE {
LYOUT_FD, /**< file descriptor */
LYOUT_STREAM, /**< FILE stream */
LYOUT_CALLBACK /**< print via provided callback */
} LYOUT_TYPE;
struct lyout {
LYOUT_TYPE type;
union {
int fd;
FILE *f;
ssize_t (*writeclb)(const void *buf, size_t count);
} method;
};
/**
* @brief Generic printer, replacement for printf() / write() / etc
*/
int ly_print(struct lyout *out, const char *format, ...);
int ly_write(struct lyout *out, const char *buf, size_t count);
int yang_print_model(struct lyout *out, struct lys_module *module);
int tree_print_model(struct lyout *out, struct lys_module *module);
int info_print_model(struct lyout *out, struct lys_module *module, const char *target_node);
int json_print_data(struct lyout *out, struct lyd_node *root);
int xml_print_data(struct lyout *out, struct lyd_node *root, int format);
#endif /* LY_PRINTER_H_ */