types.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * netlink/types.h Definition of public 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-2012 Thomas Graf <tgraf@suug.ch>
  10. */
  11. #ifndef __NETLINK_TYPES_H_
  12. #define __NETLINK_TYPES_H_
  13. #include <stdio.h>
  14. /**
  15. * @ingroup utils
  16. * Enumeration of dumping variations (dp_type)
  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_MAX,
  23. };
  24. #define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
  25. /**
  26. * @ingroup utils
  27. * Dumping parameters
  28. */
  29. struct nl_dump_params
  30. {
  31. /**
  32. * Specifies the type of dump that is requested.
  33. */
  34. enum nl_dump_type dp_type;
  35. /**
  36. * Specifies the number of whitespaces to be put in front
  37. * of every new line (indentation).
  38. */
  39. int dp_prefix;
  40. /**
  41. * Causes the cache index to be printed for each element.
  42. */
  43. int dp_print_index;
  44. /**
  45. * Causes each element to be prefixed with the message type.
  46. */
  47. int dp_dump_msgtype;
  48. /**
  49. * A callback invoked for output
  50. *
  51. * Passed arguments are:
  52. * - dumping parameters
  53. * - string to append to the output
  54. */
  55. void (*dp_cb)(struct nl_dump_params *, char *);
  56. /**
  57. * A callback invoked for every new line, can be used to
  58. * customize the indentation.
  59. *
  60. * Passed arguments are:
  61. * - dumping parameters
  62. * - line number starting from 0
  63. */
  64. void (*dp_nl_cb)(struct nl_dump_params *, int);
  65. /**
  66. * User data pointer, can be used to pass data to callbacks.
  67. */
  68. void *dp_data;
  69. /**
  70. * File descriptor the dumping output should go to
  71. */
  72. FILE * dp_fd;
  73. /**
  74. * Alternatively the output may be redirected into a buffer
  75. */
  76. char * dp_buf;
  77. /**
  78. * Length of the buffer dp_buf
  79. */
  80. size_t dp_buflen;
  81. /**
  82. * PRIVATE
  83. * Set if a dump was performed prior to the actual dump handler.
  84. */
  85. int dp_pre_dump;
  86. /**
  87. * PRIVATE
  88. * Owned by the current caller
  89. */
  90. int dp_ivar;
  91. unsigned int dp_line;
  92. };
  93. #endif