aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libfyaml/src/lib/fy-dump.h
blob: 13b1c9a8236c4968c0d5c00a11fa74c112716a80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * fy-dump.h - dumps for various internal structures
 *
 * Copyright (c) 2019 Pantelis Antoniou <pantelis.antoniou@konsulko.com>
 *
 * SPDX-License-Identifier: MIT
 */
#ifndef FY_DUMP_H
#define FY_DUMP_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>

#include <libfyaml.h>

#include "fy-list.h"
#include "fy-diag.h"

struct fy_parser;
struct fy_token;
struct fy_token_list;
struct fy_simple_key;
struct fy_simple_key_list;
struct fy_input_cfg;

extern const char *fy_token_type_txt[];

char *fy_token_dump_format(struct fy_token *fyt, char *buf, size_t bufsz);
char *fy_token_list_dump_format(struct fy_token_list *fytl,
		struct fy_token *fyt_highlight, char *buf, size_t bufsz);

char *fy_simple_key_dump_format(struct fy_parser *fyp, struct fy_simple_key *fysk, char *buf, size_t bufsz);
char *fy_simple_key_list_dump_format(struct fy_parser *fyp, struct fy_simple_key_list *fyskl,
		struct fy_simple_key *fysk_highlight, char *buf, size_t bufsz);

#ifdef FY_DEVMODE

void fyp_debug_dump_token_list(struct fy_parser *fyp, struct fy_token_list *fytl,
			       struct fy_token *fyt_highlight, const char *banner);
void fyp_debug_dump_token(struct fy_parser *fyp, struct fy_token *fyt, const char *banner);

void fyp_debug_dump_simple_key_list(struct fy_parser *fyp, struct fy_simple_key_list *fyskl,
				    struct fy_simple_key *fysk_highlight, const char *banner);
void fyp_debug_dump_simple_key(struct fy_parser *fyp, struct fy_simple_key *fysk, const char *banner);

void fyp_debug_dump_input(struct fy_parser *fyp, const struct fy_input_cfg *fyic,
			  const char *banner);

#else

static inline void
fyp_debug_dump_token_list(struct fy_parser *fyp, struct fy_token_list *fytl,
			  struct fy_token *fyt_highlight, const char *banner)
{
	/* nothing */
}

static inline void
fyp_debug_dump_token(struct fy_parser *fyp, struct fy_token *fyt, const char *banner)
{
	/* nothing */
}

static inline void
fyp_debug_dump_simple_key_list(struct fy_parser *fyp, struct fy_simple_key_list *fyskl,
			       struct fy_simple_key *fysk_highlight, const char *banner)
{
	/* nothing */
}

static inline void
fyp_debug_dump_simple_key(struct fy_parser *fyp, struct fy_simple_key *fysk, const char *banner)
{
	/* nothing */
}

static inline void
fy_debug_dump_input(struct fy_parser *fyp, const struct fy_input_cfg *fyic,
		    const char *banner)
{
	/* nothing */
}

#endif

#endif