~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to snmplib/data_list.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20070510222023-3fr07xb9i17xvq32
Tags: upstream-5.3.1
ImportĀ upstreamĀ versionĀ 5.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * netsnmp_data_list.c
3
3
 *
4
 
 * $Id: data_list.c,v 5.7.2.1 2006/01/25 16:28:11 dts12 Exp $
 
4
 * $Id: data_list.c,v 5.11.2.1 2006/01/25 16:27:41 dts12 Exp $
5
5
 */
6
6
#include <net-snmp/net-snmp-config.h>
7
7
#include <net-snmp/net-snmp-includes.h>
8
8
 
9
 
#if HAVE_DMALLOC_H
10
 
#include <dmalloc.h>
11
 
#endif
12
 
 
13
9
/*
14
10
 * prototypes
15
11
 */
64
60
netsnmp_create_data_list(const char *name, void *data,
65
61
                         Netsnmp_Free_List_Data * beer)
66
62
{
67
 
    netsnmp_data_list *node = SNMP_MALLOC_TYPEDEF(netsnmp_data_list);
 
63
    netsnmp_data_list *node;
 
64
    
 
65
    if (!name)
 
66
        return NULL;
 
67
    node = SNMP_MALLOC_TYPEDEF(netsnmp_data_list);
68
68
    if (!node)
69
69
        return NULL;
70
70
    node->name = strdup(name);
137
137
netsnmp_data_list_add_data(netsnmp_data_list **head, const char *name,
138
138
                           void *data, Netsnmp_Free_List_Data * beer)
139
139
{
140
 
    netsnmp_data_list *node = netsnmp_create_data_list(name, data, beer);
 
140
    netsnmp_data_list *node;
 
141
    if (!name) {
 
142
        snmp_log(LOG_ERR,"no name provided.");
 
143
        return NULL;
 
144
    }
 
145
    node = netsnmp_create_data_list(name, data, beer);
141
146
    if(NULL == node) {
142
147
        snmp_log(LOG_ERR,"could not allocate memory for node.");
143
148
        return NULL;
156
161
NETSNMP_INLINE void    *
157
162
netsnmp_get_list_data(netsnmp_data_list *head, const char *name)
158
163
{
 
164
    if (!name)
 
165
        return NULL;
159
166
    for (; head; head = head->next)
160
167
        if (head->name && strcmp(head->name, name) == 0)
161
168
            break;
172
179
NETSNMP_INLINE netsnmp_data_list    *
173
180
netsnmp_get_list_node(netsnmp_data_list *head, const char *name)
174
181
{
 
182
    if (!name)
 
183
        return NULL;
175
184
    for (; head; head = head->next)
176
185
        if (head->name && strcmp(head->name, name) == 0)
177
186
            break;
189
198
netsnmp_remove_list_node(netsnmp_data_list **realhead, const char *name)
190
199
{
191
200
    netsnmp_data_list *head, *prev;
 
201
    if (!name)
 
202
        return 1;
192
203
    for (head = *realhead, prev = NULL; head;
193
204
         prev = head, head = head->next) {
194
205
        if (head->name && strcmp(head->name, name) == 0) {
207
218
/** used to store registered save/parse handlers (specifically, parsing info) */
208
219
static netsnmp_data_list *saveHead;
209
220
 
210
 
/** registers to store a data_list set of data at persistant storage time
 
221
/** registers to store a data_list set of data at persistent storage time
211
222
 *
212
223
 * @param datalist the data to be saved
213
224
 * @param type the name of the application to save the data as.  If left NULL the default application name that was registered during the init_snmp call will be used (recommended).