Lines Matching defs:db
195 char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
200 if (idx >= db->num_fields)
202 db->error=DB_ERROR_INDEX_OUT_OF_RANGE;
205 lh=db->index[idx];
208 db->error=DB_ERROR_NO_INDEX;
212 db->error=DB_ERROR_OK;
216 int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(char **),
223 if (field >= db->num_fields)
225 db->error=DB_ERROR_INDEX_OUT_OF_RANGE;
230 db->error=DB_ERROR_MALLOC;
233 n=sk_num(db->data);
236 r=(char **)sk_value(db->data,i);
240 db->error=DB_ERROR_INDEX_CLASH;
241 db->arg1=sk_find(db->data,(char *)r);
242 db->arg2=i;
247 if (db->index[field] != NULL) lh_free(db->index[field]);
248 db->index[field]=idx;
249 db->qual[field]=qual;
253 long TXT_DB_write(BIO *out, TXT_DB *db)
262 n=sk_num(db->data);
263 nn=db->num_fields;
266 pp=(char **)sk_value(db->data,i);
301 int TXT_DB_insert(TXT_DB *db, char **row)
306 for (i=0; i<db->num_fields; i++)
308 if (db->index[i] != NULL)
310 if ((db->qual[i] != NULL) &&
311 (db->qual[i](row) == 0)) continue;
312 r=(char **)lh_retrieve(db->index[i],row);
315 db->error=DB_ERROR_INDEX_CLASH;
316 db->arg1=i;
317 db->arg_row=r;
323 if (!sk_push(db->data,(char *)row))
325 db->error=DB_ERROR_MALLOC;
329 for (i=0; i<db->num_fields; i++)
331 if (db->index[i] != NULL)
333 if ((db->qual[i] != NULL) &&
334 (db->qual[i](row) == 0)) continue;
335 lh_insert(db->index[i],row);
343 void TXT_DB_free(TXT_DB *db)
348 if(db == NULL)
351 if (db->index != NULL)
353 for (i=db->num_fields-1; i>=0; i--)
354 if (db->index[i] != NULL) lh_free(db->index[i]);
355 OPENSSL_free(db->index);
357 if (db->qual != NULL)
358 OPENSSL_free(db->qual);
359 if (db->data != NULL)
361 for (i=sk_num(db->data)-1; i>=0; i--)
365 p=(char **)sk_value(db->data,i);
366 max=p[db->num_fields]; /* last address */
369 for (n=0; n<db->num_fields; n++)
374 for (n=0; n<db->num_fields; n++)
381 OPENSSL_free(sk_value(db->data,i));
383 sk_free(db->data);
385 OPENSSL_free(db);