libyang  2.0.112
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
out.h
Go to the documentation of this file.
1 
15 #ifndef LY_OUT_H_
16 #define LY_OUT_H_
17 
18 #include <stdio.h>
19 #include <unistd.h>
20 
21 #include "log.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
81 struct ly_out;
82 
86 #define LY_PRINT_SHRINK 0x02
87 
91 typedef enum LY_OUT_TYPE {
92  LY_OUT_ERROR = -1,
99 } LY_OUT_TYPE;
100 
107 LY_OUT_TYPE ly_out_type(const struct ly_out *out);
108 
122 LY_ERR ly_out_reset(struct ly_out *out);
123 
133 typedef ssize_t (*ly_write_clb)(void *user_data, const void *buf, size_t count);
134 
144 LY_ERR ly_out_new_clb(ly_write_clb writeclb, void *user_data, struct ly_out **out);
145 
154 ly_write_clb ly_out_clb(struct ly_out *out, ly_write_clb writeclb);
155 
164 void *ly_out_clb_arg(struct ly_out *out, void *arg);
165 
174 LY_ERR ly_out_new_fd(int fd, struct ly_out **out);
175 
184 int ly_out_fd(struct ly_out *out, int fd);
185 
194 LY_ERR ly_out_new_file(FILE *f, struct ly_out **out);
195 
203 FILE *ly_out_file(struct ly_out *out, FILE *f);
204 
216 LY_ERR ly_out_new_memory(char **strp, size_t size, struct ly_out **out);
217 
228 char *ly_out_memory(struct ly_out *out, char **strp, size_t size);
229 
238 LY_ERR ly_out_new_filepath(const char *filepath, struct ly_out **out);
239 
252 const char *ly_out_filepath(struct ly_out *out, const char *filepath);
253 
263 LY_ERR ly_print(struct ly_out *out, const char *format, ...);
264 
269 void ly_print_flush(struct ly_out *out);
270 
281 LY_ERR ly_write(struct ly_out *out, const char *buf, size_t len);
282 
289 size_t ly_out_printed(const struct ly_out *out);
290 
298 void ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), ly_bool destroy);
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* LY_OUT_H_ */
Printer output structure specifying where the data are printed.
FILE * ly_out_file(struct ly_out *out, FILE *f)
Get or reset file stream printer handler.
LY_ERR ly_out_new_clb(ly_write_clb writeclb, void *user_data, struct ly_out **out)
Create printer handler using callback printer function.
const char * ly_out_filepath(struct ly_out *out, const char *filepath)
Get or change the filepath of the file where the printer prints the data.
ssize_t(* ly_write_clb)(void *user_data, const void *buf, size_t count)
Generic write callback for data printed by libyang.
Definition: out.h:133
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:25
LY_ERR ly_out_new_filepath(const char *filepath, struct ly_out **out)
Create printer handler file of the given filename.
char * ly_out_memory(struct ly_out *out, char **strp, size_t size)
Get or change memory where the data are dumped.
LY_ERR ly_write(struct ly_out *out, const char *buf, size_t len)
Generic printer of the given string buffer into the specified output.
ly_write_clb ly_out_clb(struct ly_out *out, ly_write_clb writeclb)
Get or reset callback function associated with a callback printer handler.
int ly_out_fd(struct ly_out *out, int fd)
Get or reset file descriptor printer handler.
LY_ERR ly_out_new_memory(char **strp, size_t size, struct ly_out **out)
Create printer handler using memory to dump data.
LY_ERR ly_out_reset(struct ly_out *out)
Reset the output medium to write from its beginning, so the following printer function will rewrite t...
LY_ERR ly_out_new_fd(int fd, struct ly_out **out)
Create printer handler using file descriptor.
LY_OUT_TYPE
Types of the printer&#39;s output.
Definition: out.h:91
LY_ERR ly_out_new_file(FILE *f, struct ly_out **out)
Create printer handler using file stream.
size_t ly_out_printed(const struct ly_out *out)
Get the number of printed bytes by the last function.
LY_OUT_TYPE ly_out_type(const struct ly_out *out)
Get output type of the printer handler.
void ly_print_flush(struct ly_out *out)
Flush the output from any internal buffers and clean any auxiliary data.
void * ly_out_clb_arg(struct ly_out *out, void *arg)
Get or reset callback function&#39;s argument associated with a callback printer handler.
void ly_out_free(struct ly_out *out, void(*clb_arg_destructor)(void *arg), ly_bool destroy)
Free the printer handler.
LY_ERR ly_print(struct ly_out *out, const char *format,...)
Generic printer of the given format string into the specified output.
Definition: out.h:93
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:245
Logger manipulation routines and error definitions.