types.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #ifndef __NETLINK_TYPES_H_
  12. #define __NETLINK_TYPES_H_
  13. #include <stdio.h>
  14. /**
  15. * Dumping types (dp_type)
  16. * @ingroup utils
  17. */
  18. enum nl_dump_type {
  19. NL_DUMP_LINE, /**< Dump object briefly on one line */
  20. NL_DUMP_DETAILS, /**< Dump all attributes but no statistics */
  21. NL_DUMP_STATS, /**< Dump all attributes including statistics */
  22. NL_DUMP_ENV, /**< Dump all attribtues as env variables */
  23. __NL_DUMP_MAX,
  24. };
  25. #define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
  26. /**
  27. * Dumping parameters
  28. * @ingroup utils
  29. */
  30. struct nl_dump_params
  31. {
  32. /**
  33. * Specifies the type of dump that is requested.
  34. */
  35. enum nl_dump_type dp_type;
  36. /**
  37. * Specifies the number of whitespaces to be put in front
  38. * of every new line (indentation).
  39. */
  40. int dp_prefix;
  41. /**
  42. * Causes the cache index to be printed for each element.
  43. */
  44. int dp_print_index;
  45. /**
  46. * Causes each element to be prefixed with the message type.
  47. */
  48. int dp_dump_msgtype;
  49. /**
  50. * A callback invoked for output
  51. *
  52. * Passed arguments are:
  53. * - dumping parameters
  54. * - string to append to the output
  55. */
  56. void (*dp_cb)(struct nl_dump_params *, char *);
  57. /**
  58. * A callback invoked for every new line, can be used to
  59. * customize the indentation.
  60. *
  61. * Passed arguments are:
  62. * - dumping parameters
  63. * - line number starting from 0
  64. */
  65. void (*dp_nl_cb)(struct nl_dump_params *, int);
  66. /**
  67. * User data pointer, can be used to pass data to callbacks.
  68. */
  69. void *dp_data;
  70. /**
  71. * File descriptor the dumping output should go to
  72. */
  73. FILE * dp_fd;
  74. /**
  75. * Alternatively the output may be redirected into a buffer
  76. */
  77. char * dp_buf;
  78. /**
  79. * Length of the buffer dp_buf
  80. */
  81. size_t dp_buflen;
  82. /**
  83. * PRIVATE
  84. * Set if a dump was performed prior to the actual dump handler.
  85. */
  86. int dp_pre_dump;
  87. /**
  88. * PRIVATE
  89. * Owned by the current caller
  90. */
  91. int dp_ivar;
  92. unsigned int dp_line;
  93. };
  94. #ifndef __GNUC__
  95. #define __extension__
  96. #endif
  97. #define min_t(type,x,y) \
  98. __extension__({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
  99. #define max_t(type,x,y) \
  100. __extension__({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
  101. #endif