data_list.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Portions of this file are subject to the following copyright(s). See
  2. * the Net-SNMP's COPYING file for more details and other copyrights
  3. * that may apply:
  4. */
  5. /*
  6. * Portions of this file are copyrighted by:
  7. * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
  8. * Use is subject to license terms specified in the COPYING file
  9. * distributed with the Net-SNMP package.
  10. *
  11. * Portions of this file are copyrighted by:
  12. * Copyright (c) 2016 VMware, Inc. All rights reserved.
  13. * Use is subject to license terms specified in the COPYING file
  14. * distributed with the Net-SNMP package.
  15. */
  16. /**
  17. * @file data_list.h
  18. *
  19. * @addtogroup agent
  20. * @addtogroup library
  21. *
  22. * External definitions for functions and variables in netsnmp_data_list.c.
  23. *
  24. * @{
  25. */
  26. #ifndef DATA_LIST_H
  27. #define DATA_LIST_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #include <net-snmp/library/snmp_impl.h>
  32. #include <net-snmp/library/tools.h>
  33. typedef void (Netsnmp_Free_List_Data) (void *);
  34. typedef int (Netsnmp_Save_List_Data) (char *buf, size_t buf_len, void *);
  35. typedef void * (Netsnmp_Read_List_Data) (char *buf, size_t buf_len);
  36. /** @struct netsnmp_data_list_s
  37. * used to iterate through lists of data
  38. */
  39. typedef struct netsnmp_data_list_s {
  40. struct netsnmp_data_list_s *next;
  41. char *name;
  42. /** The pointer to the data passed on. */
  43. void *data;
  44. /** must know how to free netsnmp_data_list->data */
  45. Netsnmp_Free_List_Data *free_func;
  46. } netsnmp_data_list;
  47. typedef struct netsnmp_data_list_saveinfo_s {
  48. netsnmp_data_list **datalist;
  49. const char *type;
  50. const char *token;
  51. Netsnmp_Save_List_Data *data_list_save_ptr;
  52. Netsnmp_Read_List_Data *data_list_read_ptr;
  53. Netsnmp_Free_List_Data *data_list_free_ptr;
  54. } netsnmp_data_list_saveinfo;
  55. NETSNMP_IMPORT
  56. netsnmp_data_list *
  57. netsnmp_create_data_list(const char *, void *, Netsnmp_Free_List_Data* );
  58. void netsnmp_data_list_add_node(netsnmp_data_list **head,
  59. netsnmp_data_list *node);
  60. netsnmp_data_list *
  61. netsnmp_data_list_add_data(netsnmp_data_list **head,
  62. const char *name, void *data,
  63. Netsnmp_Free_List_Data * beer);
  64. NETSNMP_IMPORT
  65. void *netsnmp_get_list_data(netsnmp_data_list *head,
  66. const char *node);
  67. NETSNMP_IMPORT
  68. void netsnmp_free_list_data(netsnmp_data_list *head); /* single */
  69. NETSNMP_IMPORT
  70. void netsnmp_free_all_list_data(netsnmp_data_list *head); /* multiple */
  71. NETSNMP_IMPORT
  72. int netsnmp_remove_list_node(netsnmp_data_list **realhead,
  73. const char *name);
  74. NETSNMP_IMPORT
  75. netsnmp_data_list *
  76. netsnmp_get_list_node(netsnmp_data_list *head,
  77. const char *name);
  78. /** depreciated: use netsnmp_data_list_add_node() */
  79. NETSNMP_IMPORT
  80. void netsnmp_add_list_data(netsnmp_data_list **head,
  81. netsnmp_data_list *node);
  82. void
  83. netsnmp_register_save_list(netsnmp_data_list **datalist,
  84. const char *type, const char *token,
  85. Netsnmp_Save_List_Data *data_list_save_ptr,
  86. Netsnmp_Read_List_Data *data_list_read_ptr,
  87. Netsnmp_Free_List_Data *data_list_free_ptr);
  88. int
  89. netsnmp_save_all_data(netsnmp_data_list *head,
  90. const char *type, const char *token,
  91. Netsnmp_Save_List_Data * data_list_save_ptr);
  92. SNMPCallback netsnmp_save_all_data_callback;
  93. void netsnmp_read_data_callback(const char *token, char *line);
  94. void shutdown_data_list(void);
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif
  99. /** @} */