Asterisk - The Open Source Telephony Project GIT-master-f3e88d3
Functions
ndbm.c File Reference
#include <sys/param.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ndbm.h>
#include "hash.h"
Include dependency graph for ndbm.c:

Go to the source code of this file.

Functions

int dbm_clearerr (DBM *db)
 
void dbm_close (DBM *db)
 
int dbm_delete (DBM *db, datum key)
 
int dbm_dirfno (DBM *db)
 
int dbm_error (DBM *db)
 
datum dbm_fetch (DBM *db, datum key)
 
datum dbm_firstkey (DBM *db)
 
datum dbm_nextkey (DBM *db)
 
DBMdbm_open (char *file, int flags, int mode) const
 
int dbm_store (DBM *db, datum key, datum data, int flags)
 

Function Documentation

◆ dbm_clearerr()

int dbm_clearerr ( DBM db)

Definition at line 219 of file ndbm.c.

221{
222 HTAB *hp;
223
224 hp = (HTAB *)db->internal;
225 hp->errnum = 0;
226 return (0);
227}
static sqlite3 * db
Definition: hash.h:91
int errnum
Definition: hash.h:105

References db, and htab::errnum.

◆ dbm_close()

void dbm_close ( DBM db)

Definition at line 91 of file ndbm.c.

93{
94 (void)(db->close)(db);
95}

References db.

◆ dbm_delete()

int dbm_delete ( DBM db,
datum  key 
)

Definition at line 170 of file ndbm.c.

173{
174 int status;
175 DBT dbtkey;
176
177 dbtkey.data = key.dptr;
178 dbtkey.size = key.dsize;
179 status = (db->del)(db, &dbtkey, 0);
180 if (status)
181 return (-1);
182 else
183 return (0);
184}
jack_status_t status
Definition: app_jack.c:146
Definition: db.h:85
void * data
Definition: db.h:86
size_t size
Definition: db.h:87
char * dptr
Definition: ndbm.h:58
int dsize
Definition: ndbm.h:59

References DBT::data, db, datum::dptr, datum::dsize, DBT::size, and status.

◆ dbm_dirfno()

int dbm_dirfno ( DBM db)

Definition at line 230 of file ndbm.c.

232{
233 return(((HTAB *)db->internal)->fp);
234}

References db.

◆ dbm_error()

int dbm_error ( DBM db)

Definition at line 209 of file ndbm.c.

211{
212 HTAB *hp;
213
214 hp = (HTAB *)db->internal;
215 return (hp->errnum);
216}

References db, and htab::errnum.

◆ dbm_fetch()

datum dbm_fetch ( DBM db,
datum  key 
)

Definition at line 103 of file ndbm.c.

106{
107 datum retdata;
108 int status;
109 DBT dbtkey, dbtretdata;
110
111 dbtkey.data = key.dptr;
112 dbtkey.size = key.dsize;
113 status = (db->get)(db, &dbtkey, &dbtretdata, 0);
114 if (status) {
115 dbtretdata.data = NULL;
116 dbtretdata.size = 0;
117 }
118 retdata.dptr = dbtretdata.data;
119 retdata.dsize = dbtretdata.size;
120 return (retdata);
121}
#define NULL
Definition: resample.c:96
Definition: ndbm.h:57

References DBT::data, db, datum::dptr, datum::dsize, NULL, DBT::size, and status.

◆ dbm_firstkey()

datum dbm_firstkey ( DBM db)

Definition at line 129 of file ndbm.c.

131{
132 int status;
133 datum retkey;
134 DBT dbtretkey, dbtretdata;
135
136 status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
137 if (status)
138 dbtretkey.data = NULL;
139 retkey.dptr = dbtretkey.data;
140 retkey.dsize = dbtretkey.size;
141 return (retkey);
142}
#define R_FIRST
Definition: db.h:93

References DBT::data, db, datum::dptr, datum::dsize, NULL, R_FIRST, DBT::size, and status.

◆ dbm_nextkey()

datum dbm_nextkey ( DBM db)

Definition at line 150 of file ndbm.c.

152{
153 int status;
154 datum retkey;
155 DBT dbtretkey, dbtretdata;
156
157 status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
158 if (status)
159 dbtretkey.data = NULL;
160 retkey.dptr = dbtretkey.data;
161 retkey.dsize = dbtretkey.size;
162 return (retkey);
163}
#define R_NEXT
Definition: db.h:97

References DBT::data, db, datum::dptr, datum::dsize, NULL, R_NEXT, DBT::size, and status.

◆ dbm_open()

DBM * dbm_open ( char *  file,
int  flags,
int  mode 
) const

Definition at line 61 of file ndbm.c.

64{
65 DBM *db;
67 const size_t len = strlen(file) + sizeof (DBM_SUFFIX);
68#ifdef __GNUC__
69 char path[len];
70#else
71 char *path = malloc(len);
72 if (path == NULL)
73 return NULL;
74#endif
75
76 info.bsize = 4096;
77 info.ffactor = 40;
78 info.nelem = 1;
79 info.cachesize = 0;
80 info.hash = NULL;
81 info.lorder = 0;
82 snprintf(path, len, "%s%s", file, DBM_SUFFIX);
83 db = (DBM *)__hash_open(path, flags, mode, &info, 0);
84#ifndef __GNUC__
85 free(path);
86#endif
87 return db;
88}
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * malloc()
void free()
DB * __hash_open(char *file, int flags, int mode, const HASHINFO *info, int dflags) const
Definition: hash.c:96
def info(msg)
#define DBM_SUFFIX
Definition: ndbm.h:55
Definition: db.h:163
Definition: db.h:129

References __hash_open(), db, DBM_SUFFIX, make_ari_stubs::file, free(), sip_to_pjsip::info(), len(), malloc(), and NULL.

◆ dbm_store()

int dbm_store ( DBM db,
datum  key,
datum  data,
int  flags 
)

Definition at line 193 of file ndbm.c.

197{
198 DBT dbtkey, dbtdata;
199
200 dbtkey.data = key.dptr;
201 dbtkey.size = key.dsize;
202 dbtdata.data = data.dptr;
203 dbtdata.size = data.dsize;
204 return ((db->put)(db, &dbtkey, &dbtdata,
205 (flags == DBM_INSERT) ? R_NOOVERWRITE : 0));
206}
#define R_NOOVERWRITE
Definition: db.h:98
#define DBM_INSERT
Definition: ndbm.h:48

References DBT::data, db, DBM_INSERT, datum::dptr, datum::dsize, R_NOOVERWRITE, and DBT::size.