net-snmp 5.7
data_list.h
00001 /* Portions of this file are subject to the following copyright(s).  See
00002  * the Net-SNMP's COPYING file for more details and other copyrights
00003  * that may apply:
00004  */
00005 /*
00006  * Portions of this file are copyrighted by:
00007  * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
00008  * Use is subject to license terms specified in the COPYING file
00009  * distributed with the Net-SNMP package.
00010  */
00011 /*
00012  * @file netsnmp_data_list.h
00013  *
00014  * @addtogroup agent
00015  * @addtogroup library *
00016  *
00017  * $Id$
00018  *
00019  * External definitions for functions and variables in netsnmp_data_list.c.
00020  *
00021  * @{
00022  */
00023 
00024 #ifndef DATA_LIST_H
00025 #define DATA_LIST_H
00026 
00027 #ifdef __cplusplus
00028 extern          "C" {
00029 #endif
00030 
00031 #include <net-snmp/library/snmp_impl.h>
00032 #include <net-snmp/library/tools.h>
00033 
00034     typedef void    (Netsnmp_Free_List_Data) (void *);
00035     typedef int     (Netsnmp_Save_List_Data) (char *buf, size_t buf_len, void *);
00036     typedef void *  (Netsnmp_Read_List_Data) (char *buf, size_t buf_len);
00037 
00041     typedef struct netsnmp_data_list_s {
00042         struct netsnmp_data_list_s *next;
00043         char           *name;
00045         void           *data;
00047         Netsnmp_Free_List_Data *free_func;
00048     } netsnmp_data_list;
00049 
00050     typedef struct netsnmp_data_list_saveinfo_s {
00051        netsnmp_data_list **datalist;
00052        const char *type;
00053        const char *token;
00054        Netsnmp_Save_List_Data *data_list_save_ptr;
00055        Netsnmp_Read_List_Data *data_list_read_ptr;
00056        Netsnmp_Free_List_Data *data_list_free_ptr;
00057     } netsnmp_data_list_saveinfo;
00058 
00059     NETSNMP_IMPORT
00060     netsnmp_data_list *
00061       netsnmp_create_data_list(const char *, void *, Netsnmp_Free_List_Data* );
00062     void            netsnmp_data_list_add_node(netsnmp_data_list **head,
00063                                                netsnmp_data_list *node);
00064     netsnmp_data_list *
00065       netsnmp_data_list_add_data(netsnmp_data_list **head,
00066                                  const char *name, void *data,
00067                                  Netsnmp_Free_List_Data * beer);
00068     NETSNMP_IMPORT
00069     void           *netsnmp_get_list_data(netsnmp_data_list *head,
00070                                           const char *node);
00071     NETSNMP_IMPORT
00072     void            netsnmp_free_list_data(netsnmp_data_list *head);    /* single */
00073     NETSNMP_IMPORT
00074     void            netsnmp_free_all_list_data(netsnmp_data_list *head);        /* multiple */
00075     NETSNMP_IMPORT
00076     int             netsnmp_remove_list_node(netsnmp_data_list **realhead,
00077                                              const char *name);
00078     NETSNMP_IMPORT
00079     netsnmp_data_list *
00080     netsnmp_get_list_node(netsnmp_data_list *head,
00081                           const char *name);
00082 
00084     NETSNMP_IMPORT
00085     void            netsnmp_add_list_data(netsnmp_data_list **head,
00086                                           netsnmp_data_list *node);
00087 
00088 
00089     void
00090     netsnmp_register_save_list(netsnmp_data_list **datalist,
00091                                const char *type, const char *token,
00092                                Netsnmp_Save_List_Data *data_list_save_ptr,
00093                                Netsnmp_Read_List_Data *data_list_read_ptr,
00094                                Netsnmp_Free_List_Data *data_list_free_ptr);
00095     int
00096     netsnmp_save_all_data(netsnmp_data_list *head,
00097                           const char *type, const char *token,
00098                           Netsnmp_Save_List_Data * data_list_save_ptr);
00099     SNMPCallback netsnmp_save_all_data_callback;
00100     void netsnmp_read_data_callback(const char *token, char *line);
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104 #endif
00105