libnl 1.1
include/netlink/types.h
00001 /*
00002  * netlink/netlink-types.h      Netlink Types
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef __NETLINK_TYPES_H_
00013 #define __NETLINK_TYPES_H_
00014 
00015 #include <stdio.h>
00016 
00017 /**
00018  * Dumping types (dp_type)
00019  * @ingroup utils
00020  */
00021 enum nl_dump_type {
00022         NL_DUMP_BRIEF,          /**< Dump object in a brief one-liner */
00023         NL_DUMP_FULL,           /**< Dump all attributes but no statistics */
00024         NL_DUMP_STATS,          /**< Dump all attributes including statistics */
00025         NL_DUMP_XML,            /**< Dump all attribtes in XML format */
00026         NL_DUMP_ENV,            /**< Dump all attribtues as env variables */
00027         NL_DUMP_EVENTS,         /**< Dump event */
00028         __NL_DUMP_MAX,
00029 };
00030 #define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
00031 
00032 /**
00033  * Dumping parameters
00034  * @ingroup utils
00035  */
00036 struct nl_dump_params
00037 {
00038         /**
00039          * Specifies the type of dump that is requested.
00040          */
00041         enum nl_dump_type       dp_type;
00042 
00043         /**
00044          * Specifies the number of whitespaces to be put in front
00045          * of every new line (indentation).
00046          */
00047         int                     dp_prefix;
00048 
00049         /**
00050          * Causes the cache index to be printed for each element.
00051          */
00052         int                     dp_print_index;
00053 
00054         /**
00055          * Causes each element to be prefixed with the message type.
00056          */
00057         int                     dp_dump_msgtype;
00058 
00059         /**
00060          * A callback invoked for output
00061          *
00062          * Passed arguments are:
00063          *  - dumping parameters
00064          *  - string to append to the output
00065          */
00066         void                    (*dp_cb)(struct nl_dump_params *, char *);
00067 
00068         /**
00069          * A callback invoked for every new line, can be used to
00070          * customize the indentation.
00071          *
00072          * Passed arguments are:
00073          *  - dumping parameters
00074          *  - line number starting from 0
00075          */
00076         void                    (*dp_nl_cb)(struct nl_dump_params *, int);
00077 
00078         /**
00079          * User data pointer, can be used to pass data to callbacks.
00080          */
00081         void                    *dp_data;
00082 
00083         /**
00084          * File descriptor the dumping output should go to
00085          */
00086         FILE *                  dp_fd;
00087 
00088         /**
00089          * Alternatively the output may be redirected into a buffer
00090          */
00091         char *                  dp_buf;
00092 
00093         /**
00094          * Length of the buffer dp_buf
00095          */
00096         size_t                  dp_buflen;
00097 
00098         /**
00099          * PRIVATE
00100          * Set if a dump was performed prior to the actual dump handler.
00101          */
00102         int                     dp_pre_dump;
00103 };
00104 
00105 #endif