firmware-utils: move bcm_tag.h here
[openwrt.git] / package / libnl-tiny / src / include / netlink / types.h
1 /*
2  * netlink/netlink-types.h      Netlink Types
3  *
4  *      This library is free software; you can redistribute it and/or
5  *      modify it under the terms of the GNU Lesser General Public
6  *      License as published by the Free Software Foundation version 2.1
7  *      of the License.
8  *
9  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
10  */
11
12 #ifndef __NETLINK_TYPES_H_
13 #define __NETLINK_TYPES_H_
14
15 #include <stdio.h>
16
17 /**
18  * Dumping types (dp_type)
19  * @ingroup utils
20  */
21 enum nl_dump_type {
22         NL_DUMP_LINE,           /**< Dump object briefly on one line */
23         NL_DUMP_DETAILS,        /**< Dump all attributes but no statistics */
24         NL_DUMP_STATS,          /**< Dump all attributes including statistics */
25         NL_DUMP_ENV,            /**< Dump all attribtues as env variables */
26         __NL_DUMP_MAX,
27 };
28 #define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
29
30 /**
31  * Dumping parameters
32  * @ingroup utils
33  */
34 struct nl_dump_params
35 {
36         /**
37          * Specifies the type of dump that is requested.
38          */
39         enum nl_dump_type       dp_type;
40
41         /**
42          * Specifies the number of whitespaces to be put in front
43          * of every new line (indentation).
44          */
45         int                     dp_prefix;
46
47         /**
48          * Causes the cache index to be printed for each element.
49          */
50         int                     dp_print_index;
51
52         /**
53          * Causes each element to be prefixed with the message type.
54          */
55         int                     dp_dump_msgtype;
56
57         /**
58          * A callback invoked for output
59          *
60          * Passed arguments are:
61          *  - dumping parameters
62          *  - string to append to the output
63          */
64         void                    (*dp_cb)(struct nl_dump_params *, char *);
65
66         /**
67          * A callback invoked for every new line, can be used to
68          * customize the indentation.
69          *
70          * Passed arguments are:
71          *  - dumping parameters
72          *  - line number starting from 0
73          */
74         void                    (*dp_nl_cb)(struct nl_dump_params *, int);
75
76         /**
77          * User data pointer, can be used to pass data to callbacks.
78          */
79         void                    *dp_data;
80
81         /**
82          * File descriptor the dumping output should go to
83          */
84         FILE *                  dp_fd;
85
86         /**
87          * Alternatively the output may be redirected into a buffer
88          */
89         char *                  dp_buf;
90
91         /**
92          * Length of the buffer dp_buf
93          */
94         size_t                  dp_buflen;
95
96         /**
97          * PRIVATE
98          * Set if a dump was performed prior to the actual dump handler.
99          */
100         int                     dp_pre_dump;
101
102         /**
103          * PRIVATE
104          * Owned by the current caller
105          */
106         int                     dp_ivar;
107
108         unsigned int            dp_line;
109 };
110
111 #ifndef __GNUC__
112 #define __extension__
113 #endif
114
115 #define min_t(type,x,y) \
116         __extension__({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
117 #define max_t(type,x,y) \
118         __extension__({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
119
120
121 #endif