Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
hsearch.c File Reference
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include "../include/db.h"
#include "search.h"
Include dependency graph for hsearch.c:

Go to the source code of this file.

Functions

int hcreate (u_int nel)
 
void hdestroy ()
 
ENTRYhsearch (ENTRY item, ACTION action)
 

Variables

static DBdbp = NULL
 
static ENTRY retval
 

Function Documentation

◆ hcreate()

int hcreate ( u_int  nel)

Definition at line 53 of file hsearch.c.

55{
57
58 info.nelem = nel;
59 info.bsize = 256;
60 info.ffactor = 8;
61 info.cachesize = 0;
62 info.hash = NULL;
63 info.lorder = 0;
64 dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
65 return ((int)dbp);
66}
DB * __hash_open(char *file, int flags, int mode, const HASHINFO *info, int dflags) const
Definition: hash.c:96
static DB * dbp
Definition: hsearch.c:49
def info(msg)
#define NULL
Definition: resample.c:96
Definition: db.h:163
Definition: db.h:129

References __hash_open(), dbp, sip_to_pjsip::info(), and NULL.

◆ hdestroy()

void hdestroy ( )

Definition at line 101 of file hsearch.c.

102{
103 if (dbp) {
104 (void)(dbp->close)(dbp);
105 dbp = NULL;
106 }
107}

References dbp, and NULL.

◆ hsearch()

ENTRY * hsearch ( ENTRY  item,
ACTION  action 
)

Definition at line 69 of file hsearch.c.

72{
73 DBT key, val;
74 int status;
75
76 if (!dbp)
77 return (NULL);
78 key.data = (u_char *)item.key;
79 key.size = strlen(item.key) + 1;
80
81 if (action == ENTER) {
82 val.data = (u_char *)item.data;
83 val.size = strlen(item.data) + 1;
84 status = (dbp->put)(dbp, &key, &val, R_NOOVERWRITE);
85 if (status)
86 return (NULL);
87 } else {
88 /* FIND */
89 status = (dbp->get)(dbp, &key, &val, 0);
90 if (status)
91 return (NULL);
92 else
93 item.data = (char *)val.data;
94 }
95 retval.key = item.key;
96 retval.data = item.data;
97 return (&retval);
98}
jack_status_t status
Definition: app_jack.c:146
@ ENTER
Definition: app_meetme.c:684
#define R_NOOVERWRITE
Definition: db.h:98
static ENTRY retval
Definition: hsearch.c:50
Definition: db.h:85
void * data
Definition: db.h:86
size_t size
Definition: db.h:87
char * key
Definition: search.h:41
char * data
Definition: search.h:42
Definition: ast_expr2.c:325
static struct aco_type item
Definition: test_config.c:1463

References entry::data, DBT::data, dbp, ENTER, item, entry::key, NULL, R_NOOVERWRITE, retval, DBT::size, and status.

Variable Documentation

◆ dbp

DB* dbp = NULL
static

◆ retval

ENTRY retval
static