Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
hsearch.c File Reference
#include "watcomfx.h"
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include "mcom_db.h"
#include "hsearch.h"

Go to the source code of this file.

Functions

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

Variables

static DBdbp = NULL
static ENTRY retval

Function Documentation

int hcreate ( uint  nel)

Definition at line 55 of file hsearch.c.

{
       HASHINFO info;

       info.nelem = nel;
       info.bsize = 256;
       info.ffactor = 8;
       info.cachesize = 0;
       info.hash = NULL;
       info.lorder = 0;
       dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
       return ((int)dbp);
}

Here is the call graph for this function:

Definition at line 100 of file hsearch.c.

{
       if (dbp) {
              (void)(dbp->close)(dbp);
              dbp = NULL;
       }
}

Here is the caller graph for this function:

ENTRY* hsearch ( ENTRY  item,
ACTION  action 
)

Definition at line 70 of file hsearch.c.

{
       DBT key, val;
       int status;

       if (!dbp)
              return (NULL);
       key.data = (uint8 *)item.key;
       key.size = strlen(item.key) + 1;

       if (action == ENTER) {
              val.data = (uint8 *)item.data;
              val.size = strlen(item.data) + 1;
              status = (dbp->put)(dbp, &key, &val, R_NOOVERWRITE);
              if (status)
                     return (NULL);
       } else {
              /* FIND */
              status = (dbp->get)(dbp, &key, &val, 0);
              if (status)
                     return (NULL);
              else
                     item.data = (char *)val.data;
       }
       retval.key = item.key;
       retval.data = item.data;
       return (&retval);
}

Variable Documentation

DB* dbp = NULL [static]

Definition at line 51 of file hsearch.c.

ENTRY retval [static]

Definition at line 52 of file hsearch.c.