~ubuntu-branches/debian/lenny/net-snmp/lenny

« back to all changes in this revision

Viewing changes to agent/mibgroup/snmp-usm-dh-objects-mib/usmDHUserKeyTable/usmDHUserKeyTable_data_access.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • 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
 * Note: this file originally auto-generated by mib2c using
3
 
 *       version : 1.12 $ of : mfd-data-access.m2c,v $ 
 
3
 *       version : 1.17 $ of : mfd-data-access.m2c,v $ 
4
4
 *
5
 
 * $Id: usmDHUserKeyTable_data_access.c,v 1.6.2.3 2005/01/31 06:06:08 rstory Exp $
 
5
 * $Id: usmDHUserKeyTable_data_access.c,v 1.9.2.1 2006/01/25 16:26:39 dts12 Exp $
6
6
 */
7
7
/*
8
8
 * standard Net-SNMP includes 
19
19
 
20
20
#include "usmDHUserKeyTable_data_access.h"
21
21
 
22
 
/** @defgroup data_access data_access: Routines to access data
 
22
/** @ingroup interface 
 
23
 * @addtogroup data_access data_access: Routines to access data
23
24
 *
24
25
 * These routines are used to locate the data used to satisfy
25
26
 * requests.
34
35
 **********************************************************************
35
36
 **********************************************************************/
36
37
/*
37
 
 * usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
 
38
 * SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
38
39
 * Its status is Current.
39
40
 * OID: .1.3.6.1.3.101.1.1.2, length: 9
40
41
 */
52
53
 * @retval MFD_ERROR   : unrecoverable error.
53
54
 */
54
55
int
55
 
usmDHUserKeyTable_init_data(usmDHUserKeyTable_registration_ptr
 
56
usmDHUserKeyTable_init_data(usmDHUserKeyTable_registration *
56
57
                            usmDHUserKeyTable_reg)
57
58
{
58
59
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_init_data",
66
67
}                               /* usmDHUserKeyTable_init_data */
67
68
 
68
69
/**
69
 
 * container-cached overview
 
70
 * container overview
70
71
 *
71
72
 */
72
73
 
73
 
/***********************************************************************
74
 
 *
75
 
 * cache
76
 
 *
77
 
 ***********************************************************************/
78
74
/**
79
75
 * container initialization
80
76
 *
107
103
{
108
104
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_init", "called\n"));
109
105
 
110
 
    if ((NULL == cache) || (NULL == container_ptr_ptr)) {
 
106
    if (NULL == container_ptr_ptr) {
111
107
        snmp_log(LOG_ERR,
112
 
                 "bad params to usmDHUserKeyTable_container_init\n");
 
108
                 "bad container param to usmDHUserKeyTable_container_init\n");
113
109
        return;
114
110
    }
115
111
 
119
115
     */
120
116
    *container_ptr_ptr = NULL;
121
117
 
 
118
    if (NULL == cache) {
 
119
        snmp_log(LOG_ERR,
 
120
                 "bad cache param to usmDHUserKeyTable_container_init\n");
 
121
        return;
 
122
    }
 
123
 
122
124
    /*
123
125
     * TODO:345:A: Set up usmDHUserKeyTable cache properties.
124
126
     *
132
134
     * callback when the list is changed, or a last changed object to
133
135
     * verify the list hasn't changed. Until then, reload the cache for
134
136
     * every request.
135
 
     */
 
137
       */
136
138
    cache->timeout = -1;   /* seconds */
137
139
}                               /* usmDHUserKeyTable_container_init */
138
140
 
139
141
/**
140
 
 * load cache data
141
 
 *
142
 
 * TODO:350:M: Implement usmDHUserKeyTable cache load
 
142
 * container shutdown
 
143
 *
 
144
 * @param container_ptr A pointer to the container.
 
145
 *
 
146
 *  This function is called at shutdown to allow you to customize certain
 
147
 *  aspects of the access method. For the most part, it is for advanced
 
148
 *  users. The default code should suffice for most cases.
 
149
 *
 
150
 *  This function is called before usmDHUserKeyTable_container_free().
 
151
 *
 
152
 * @remark
 
153
 *  This would also be a good place to do any cleanup needed
 
154
 *  for you data source. For example, closing a connection to another
 
155
 *  process that supplied the data, closing a database, etc.
 
156
 */
 
157
void
 
158
usmDHUserKeyTable_container_shutdown(netsnmp_container * container_ptr)
 
159
{
 
160
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_shutdown", "called\n"));
 
161
 
 
162
    if (NULL == container_ptr) {
 
163
        snmp_log(LOG_ERR,
 
164
                 "bad params to usmDHUserKeyTable_container_shutdown\n");
 
165
        return;
 
166
    }
 
167
 
 
168
}                               /* usmDHUserKeyTable_container_shutdown */
 
169
 
 
170
/**
 
171
 * load initial data
 
172
 *
 
173
 * TODO:350:M: Implement usmDHUserKeyTable data load
 
174
 * This function will also be called by the cache helper to load
 
175
 * the container again (after the container free function has been
 
176
 * called to free the previous contents).
143
177
 *
144
178
 * @param container container to which items should be inserted
145
179
 *
147
181
 * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
148
182
 * @retval MFD_ERROR                : other error.
149
183
 *
150
 
 *  This function is called to cache the index(es) (and data, optionally)
 
184
 *  This function is called to load the index(es) (and data, optionally)
151
185
 *  for the every row in the data set.
152
186
 *
153
187
 * @remark
154
 
 *  While loading the cache, the only important thing is the indexes.
 
188
 *  While loading the data, the only important thing is the indexes.
155
189
 *  If access to your data is cheap/fast (e.g. you have a pointer to a
156
190
 *  structure in memory), it would make sense to update the data here.
157
191
 *  If, however, the accessing the data invovles more work (e.g. parsing
167
201
 *
168
202
 */
169
203
int
170
 
usmDHUserKeyTable_cache_load(netsnmp_container * container)
 
204
usmDHUserKeyTable_container_load(netsnmp_container * container)
171
205
{
172
206
    usmDHUserKeyTable_rowreq_ctx *rowreq_ctx;
173
207
    struct usmUser *usmuser;
174
208
    size_t          count = 0;
175
209
 
176
 
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_cache_load",
177
 
                "called\n"));
 
210
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_load", "called\n"));
178
211
 
179
212
    /*
180
213
     * TODO:351:M: |-> Load/update data in the usmDHUserKeyTable container.
182
215
     * set the index(es) [and data, optionally] and insert into
183
216
     * the container.
184
217
     */
185
 
    /*
 
218
          /*
186
219
     * Retrieve the first user from the USM DB
187
 
     */
 
220
           */
188
221
    usmuser = usm_get_userList();
189
222
    if (NULL == usmuser) {
190
223
        return MFD_SUCCESS;
191
224
    }
192
 
 
 
225
  
193
226
    for (; usmuser; usmuser = usmuser->next) {
 
227
 
194
228
        /*
195
229
         * TODO:352:M: |   |-> set indexes in new usmDHUserKeyTable rowreq context.
196
 
         * data context will be set from the param (unless NULL,
 
230
         * data context will be set from the first param (unless NULL,
197
231
         *      in which case a new data context will be allocated)
 
232
         * the second param will be passed, with the row context, to
 
233
         *      usmDHUserKeyTablerowreq_ctx_init.
198
234
         */
199
 
        rowreq_ctx = usmDHUserKeyTable_allocate_rowreq_ctx(usmuser);
 
235
        rowreq_ctx = usmDHUserKeyTable_allocate_rowreq_ctx(usmuser, NULL);
200
236
        if (NULL == rowreq_ctx) {
201
237
            snmp_log(LOG_ERR, "memory allocation failed\n");
202
238
            return MFD_RESOURCE_UNAVAILABLE;
209
245
                                          strlen(usmuser->name))) {
210
246
            snmp_log(LOG_ERR,
211
247
                     "error setting index while loading "
212
 
                     "usmDHUserKeyTable cache.\n");
 
248
                     "usmDHUserKeyTable data.\n");
213
249
            usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
214
250
            continue;
215
251
        }
229
265
        ++count;
230
266
    }
231
267
 
232
 
    DEBUGMSGT(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_cache_load",
233
 
               "inserted %d records\n", count));
 
268
    DEBUGMSGT(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_load", "inserted %d records\n", count));
234
269
 
235
270
    return MFD_SUCCESS;
236
 
}                               /* usmDHUserKeyTable_cache_load */
 
271
}                               /* usmDHUserKeyTable_container_load */
237
272
 
238
273
/**
239
 
 * cache clean up
 
274
 * container clean up
240
275
 *
241
276
 * @param container container with all current items
242
277
 *
253
288
 *
254
289
 */
255
290
void
256
 
usmDHUserKeyTable_cache_free(netsnmp_container * container)
 
291
usmDHUserKeyTable_container_free(netsnmp_container * container)
257
292
{
258
 
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_cache_free",
259
 
                "called\n"));
 
293
    DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_free", "called\n"));
260
294
 
261
295
    /*
262
 
     * TODO:380:M: Free usmDHUserKeyTable cache.
 
296
     * TODO:380:M: Free usmDHUserKeyTable container data.
263
297
     */
264
 
}                               /* usmDHUserKeyTable_cache_free */
 
298
}                               /* usmDHUserKeyTable_container_free */
265
299
 
266
300
/**
267
301
 * prepare row for processing.