net-snmp 5.7
container_null.c
00001 /*
00002  * container_null.c
00003  * $Id$
00004  *
00005  * see comments in header file.
00006  *
00007  */
00008 
00009 #include <net-snmp/net-snmp-config.h>
00010 #include <net-snmp/net-snmp-features.h>
00011 
00012 #if HAVE_IO_H
00013 #include <io.h>
00014 #endif
00015 #include <stdio.h>
00016 #if HAVE_STDLIB_H
00017 #include <stdlib.h>
00018 #endif
00019 #if HAVE_MALLOC_H
00020 #include <malloc.h>
00021 #endif
00022 #include <sys/types.h>
00023 #if HAVE_STRING_H
00024 #include <string.h>
00025 #else
00026 #include <strings.h>
00027 #endif
00028 
00029 #include <net-snmp/net-snmp-includes.h>
00030 #include <net-snmp/types.h>
00031 #include <net-snmp/library/snmp_api.h>
00032 #include <net-snmp/library/container.h>
00033 #include <net-snmp/library/container_null.h>
00034 #include <net-snmp/library/tools.h>
00035 #include <net-snmp/library/snmp_assert.h>
00036 
00037 netsnmp_feature_child_of(container_null, container_types)
00038 
00039 
00056 #ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_NULL
00057 /**********************************************************************
00058  *
00059  * container
00060  *
00061  */
00062 static void *
00063 _null_find(netsnmp_container *container, const void *data)
00064 {
00065     DEBUGMSGTL(("container:null:find","in\n"));
00066     return NULL;
00067 }
00068 
00069 static void *
00070 _null_find_next(netsnmp_container *container, const void *data)
00071 {
00072     DEBUGMSGTL(("container:null:find_next","in\n"));
00073     return NULL;
00074 }
00075 
00076 static int
00077 _null_insert(netsnmp_container *container, const void *data)
00078 {
00079     DEBUGMSGTL(("container:null:insert","in\n"));
00080     return 0;
00081 }
00082 
00083 static int
00084 _null_remove(netsnmp_container *container, const void *data)
00085 {
00086     DEBUGMSGTL(("container:null:remove","in\n"));
00087     return 0;
00088 }
00089 
00090 static int
00091 _null_free(netsnmp_container *container)
00092 {
00093     DEBUGMSGTL(("container:null:free","in\n"));
00094     free(container);
00095     return 0;
00096 }
00097 
00098 static int
00099 _null_init(netsnmp_container *container)
00100 {
00101     DEBUGMSGTL(("container:null:","in\n"));
00102     return 0;
00103 }
00104 
00105 static size_t
00106 _null_size(netsnmp_container *container)
00107 {
00108     DEBUGMSGTL(("container:null:size","in\n"));
00109     return 0;
00110 }
00111 
00112 static void
00113 _null_for_each(netsnmp_container *container, netsnmp_container_obj_func *f,
00114              void *context)
00115 {
00116     DEBUGMSGTL(("container:null:for_each","in\n"));
00117 }
00118 
00119 static netsnmp_void_array *
00120 _null_get_subset(netsnmp_container *container, void *data)
00121 {
00122     DEBUGMSGTL(("container:null:get_subset","in\n"));
00123     return NULL;
00124 }
00125 
00126 static void
00127 _null_clear(netsnmp_container *container, netsnmp_container_obj_func *f,
00128                  void *context)
00129 {
00130     DEBUGMSGTL(("container:null:clear","in\n"));
00131 }
00132 
00133 /**********************************************************************
00134  *
00135  * factory
00136  *
00137  */
00138 
00139 netsnmp_container *
00140 netsnmp_container_get_null(void)
00141 {
00142     /*
00143      * allocate memory
00144      */
00145     netsnmp_container *c;
00146     DEBUGMSGTL(("container:null:get_null","in\n"));
00147     c = SNMP_MALLOC_TYPEDEF(netsnmp_container);
00148     if (NULL==c) {
00149         snmp_log(LOG_ERR, "couldn't allocate memory\n");
00150         return NULL;
00151     }
00152 
00153     c->container_data = NULL;
00154         
00155     c->get_size = _null_size;
00156     c->init = _null_init;
00157     c->cfree = _null_free;
00158     c->insert = _null_insert;
00159     c->remove = _null_remove;
00160     c->find = _null_find;
00161     c->find_next = _null_find_next;
00162     c->get_subset = _null_get_subset;
00163     c->get_iterator = NULL; /* _null_iterator; */
00164     c->for_each = _null_for_each;
00165     c->clear = _null_clear;
00166        
00167     return c;
00168 }
00169 
00170 netsnmp_factory *
00171 netsnmp_container_get_null_factory(void)
00172 {
00173     static netsnmp_factory f = { "null",
00174                                  (netsnmp_factory_produce_f*)
00175                                  netsnmp_container_get_null};
00176     
00177     DEBUGMSGTL(("container:null:get_null_factory","in\n"));
00178     return &f;
00179 }
00180 
00181 void
00182 netsnmp_container_null_init(void)
00183 {
00184     netsnmp_container_register("null",
00185                                netsnmp_container_get_null_factory());
00186 }
00187 #else  /* NETSNMP_FEATURE_REMOVE_CONTAINER_NULL */
00188 netsnmp_feature_unused(container_null);
00189 #endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_NULL */
00190