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
|
#ifndef NFTABLES_EREC_H
#define NFTABLES_EREC_H
#include <nftables.h>
#include <utils.h>
/**
* enum error_record_types
*
* @EREC_INFORMATIONAL: informational message
* @EREC_WARNING: warning message
* @EREC_ERROR: error message
*/
enum error_record_types {
EREC_INFORMATIONAL,
EREC_WARNING,
EREC_ERROR,
};
#define EREC_MSGBUFSIZE 1024
#define EREC_LOCATIONS_MAX 3
/**
* struct error_record
*
* @list: message queue node
* @type: error record type
* @num_locations: number of locations
* @locations: location(s) of error
* @msg: message
*/
struct error_record {
struct list_head list;
enum error_record_types type;
unsigned int num_locations;
struct location locations[EREC_LOCATIONS_MAX];
char *msg;
};
extern struct error_record *erec_vcreate(enum error_record_types type,
const struct location *loc,
const char *fmt, va_list ap)
__gmp_fmtstring(3, 0);
extern struct error_record *erec_create(enum error_record_types type,
const struct location *loc,
const char *fmt, ...) __gmp_fmtstring(3, 4);
extern void erec_add_location(struct error_record *erec,
const struct location *loc);
extern void erec_destroy(struct error_record *erec);
#define error(loc, fmt, args...) \
erec_create(EREC_ERROR, (loc), (fmt), ## args)
#define warning(loc, fmt, args...) \
erec_create(EREC_WARNING, (loc), (fmt), ## args)
static inline void erec_queue(struct error_record *erec,
struct list_head *queue)
{
list_add_tail(&erec->list, queue);
}
extern void erec_print(struct output_ctx *octx, const struct error_record *erec,
unsigned int debug_mask);
extern void erec_print_list(struct output_ctx *octx, struct list_head *list,
unsigned int debug_mask);
struct eval_ctx;
extern int __fmtstring(4, 5) __stmt_binary_error(struct eval_ctx *ctx,
const struct location *l1,
const struct location *l2,
const char *fmt, ...);
#define stmt_error(ctx, s1, fmt, args...) \
__stmt_binary_error(ctx, &(s1)->location, NULL, fmt, ## args)
#define stmt_binary_error(ctx, s1, s2, fmt, args...) \
__stmt_binary_error(ctx, &(s1)->location, &(s2)->location, fmt, ## args)
void print_location(FILE *f, const struct input_descriptor *indesc,
const struct location *loc);
const char *line_location(const struct input_descriptor *indesc,
const struct location *loc, char *buf, size_t bufsiz);
#endif /* NFTABLES_EREC_H */
|