⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 container.h

📁 net_snmp应用程序示例
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef NETSNMP_CONTAINER_H#define NETSNMP_CONTAINER_H/* * $Id: container.h,v 1.32 2005/12/04 18:43:04 rstory Exp $ * * WARNING: This is a recently created file, and all of it's contents are *          subject to change at any time. * * A basic container template. A generic way for code to store and * retrieve data. Allows for interchangable storage algorithms. */#ifndef NET_SNMP_CONFIG_H#error "Please include <net-snmp/net-snmp-config.h> before this file"#endif#include <net-snmp/types.h>#include <net-snmp/library/factory.h>#include <net-snmp/library/snmp_logging.h>#ifdef  __cplusplusextern "C" {#endif    /*************************************************************************     *     * function pointer definitions     *     *************************************************************************/    struct netsnmp_iterator_s; /** forward declare */    struct netsnmp_container_s; /** forward declare */    /*     * function returning an int for an operation on a container     */    typedef int (netsnmp_container_option)(struct netsnmp_container_s *,                                           int set, u_int flags);    /*     * function returning an int for an operation on a container     */    typedef int (netsnmp_container_rc)(struct netsnmp_container_s *);    /*     * function returning an iterator for a container     */    typedef struct netsnmp_iterator_s * (netsnmp_container_it)        (struct netsnmp_container_s *);    /*     * function returning a size_t for an operation on a container     */    typedef size_t (netsnmp_container_size)(struct netsnmp_container_s *);    /*     * function returning an int for an operation on an object and     * a container     */    typedef int (netsnmp_container_op)(struct netsnmp_container_s *,                                       const void *data);    /*     * function returning an oject for an operation on an object and a     * container     */    typedef void * (netsnmp_container_rtn)(struct netsnmp_container_s *,                                           const void *data);    /*     * function with no return which acts on an object     */    typedef void (netsnmp_container_obj_func)(void *data, void *context);    /*     * function with no return which calls a function on an object     */    typedef void (netsnmp_container_func)(struct netsnmp_container_s *,                                          netsnmp_container_obj_func *,                                          void *context);    /*     * function returning an array of objects for an operation on an     * ojbect and a container     */    typedef netsnmp_void_array * (netsnmp_container_set)        (struct netsnmp_container_s *, void *data);    /*     * function returning an int for a comparison between two objects     */    typedef int (netsnmp_container_compare)(const void *lhs,                                            const void *rhs);    /*************************************************************************     *     * Basic container     *     *************************************************************************/    typedef struct netsnmp_container_s {              /*        * pointer for container implementation        */       void *         container_data;       /*        * returns the number of items in a container        */       netsnmp_container_size  *get_size;              /*        * initialize a container        */       netsnmp_container_rc    *init;       /*        * release memory used by a container.        *        * Note: if your data structures contained allocated        * memory, you are responsible for releasing that        * memory before calling this function!        */       netsnmp_container_rc    *cfree;       /*        * add an entry to the container        */       netsnmp_container_op    *insert;       /*        * remove an entry from the container        */       netsnmp_container_op    *remove;       /*        * release memory for an entry from the container        */       netsnmp_container_op    *release;       /*        * Note: do not change the key!  If you need to        * change a key, remove the entry, change the key,        * and the re-add the entry.        */       /*        * find the entry in the container with the same key        *        */       netsnmp_container_rtn   *find;       /*        * find the entry in the container with the next highest key        *        * If the key is NULL, return the first item in the container.        */       netsnmp_container_rtn   *find_next;       /*        * find all entries in the container which match the partial key        * returns allocated memory (netsnmp_void_array). User is responsible        * for releasing this memory (free(array->array), free(array)).        * DO NOT FREE ELEMENTS OF THE ARRAY, because they are the same pointers        * stored in the container.        */       netsnmp_container_set            *get_subset;       /*        * function to return an iterator for the container        */       netsnmp_container_it           *get_iterator;       /*        * function to call another function for each object in the container        */       netsnmp_container_func         *for_each;       /*        * specialized version of for_each used to optimize cleanup.        * clear the container, optionally calling a function for each item.        */       netsnmp_container_func         *clear;       /*        * OPTIONAL function to filter inserts to the container        *  (intended for a secondary container, which only wants        *   a sub-set of the objects in the primary/parent container)        * Returns:        *   1 : filter matched (don't insert)        *   0 : no match (insert)        */       netsnmp_container_op    *insert_filter;       /*        * function to compare two object stored in the container.        *        * Returns:        *        *   -1  LHS < RHS        *    0  LHS = RHS        *    1  LHS > RHS        */       netsnmp_container_compare        *compare;       /*        * same as compare, but RHS will be a partial key        */       netsnmp_container_compare        *ncompare;       /*        * function to set container options        */       netsnmp_container_option         *options;       /*        * unique name for finding a particular container in a list        */       char *container_name;       /*        * sort count, for iterators to track (insert/delete        * bumps coutner, invalidates iterator        */       u_long                          sync;       /*        * containers can contain other containers (additional indexes)        */       struct netsnmp_container_s *next, *prev;    } netsnmp_container;    /*     * initialize/free a container of container factories. used by     * netsnmp_container_find* functions.     */    void netsnmp_container_init_list(void);    void netsnmp_container_free_list(void);    /*     * register a new container factory     */    int netsnmp_container_register_with_compare(const char* name,                                                netsnmp_factory *f,                                                netsnmp_container_compare *c);    int netsnmp_container_register(const char* name, netsnmp_factory *f);    /*     * search for and create a container from a list of types or a     * specific type.     */    netsnmp_container * netsnmp_container_find(const char *type_list);    netsnmp_container * netsnmp_container_get(const char *type);    /*     * utility routines     */    void netsnmp_container_add_index(netsnmp_container *primary,                                     netsnmp_container *new_index);    netsnmp_factory *netsnmp_container_get_factory(const char *type);    /*     * common comparison routines     */    /** first data element is a 'netsnmp_index' */    int netsnmp_compare_netsnmp_index(const void *lhs, const void *rhs);    int netsnmp_ncompare_netsnmp_index(const void *lhs, const void *rhs);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -