Tune up test feature macros for glibc 2.30
[platform/upstream/ltrace.git] / lens.h
1 /*
2  * This file is part of ltrace.
3  * Copyright (C) 2011 Petr Machata, Red Hat Inc.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA
19  */
20
21 #ifndef LENS_H
22 #define LENS_H
23
24 #include <stdio.h>
25 #include "forward.h"
26
27 struct lens {
28         /* Format VALUE into STREAM.  The dictionary of all arguments
29          * is given for purposes of evaluating array lengths and other
30          * dynamic expressions.  Returns number of characters
31          * outputted, -1 in case of failure.  */
32         int (*format_cb)(struct lens *lens, FILE *stream, struct value *value,
33                          struct value_dict *arguments);
34
35         /* Erase any memory allocated for LENS.  Keep the LENS pointer
36          * itself intact.  */
37         void (*destroy_cb)(struct lens *lens);
38 };
39
40 /* Extracts a lens from VALUE and calls lens_format on that.  */
41 int format_argument(FILE *stream, struct value *value,
42                     struct value_dict *arguments);
43
44 /* Calls format callback associated with LENS.  */
45 int lens_format(struct lens *lens, FILE *stream, struct value *value,
46                 struct value_dict *arguments);
47
48 /* Calls destroy callback associated with LENS.  */
49 void lens_destroy(struct lens *lens);
50
51 #endif /* LENS_H */