Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Enumerations | Functions
search.h File Reference

Go to the source code of this file.

Classes

struct  entry

Typedefs

typedef struct entry ENTRY

Enumerations

enum  ACTION {
  HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE,
  HASH_FIRST, HASH_NEXT, FIND, ENTER,
  FIND, ENTER
}

Functions

int hcreate (unsigned int)
void hdestroy (void)
ENTRYhsearch (ENTRY, ACTION)

Class Documentation

struct entry

Definition at line 38 of file hsearch.h.

Class Members
char * data
char * key

Typedef Documentation

typedef struct entry ENTRY

Enumeration Type Documentation

enum ACTION
Enumerator:
HASH_GET 
HASH_PUT 
HASH_PUTNEW 
HASH_DELETE 
HASH_FIRST 
HASH_NEXT 
FIND 
ENTER 
FIND 
ENTER 

Definition at line 43 of file search.h.

             {
       FIND, ENTER
} ACTION;

Function Documentation

int hcreate ( unsigned  int)

Definition at line 100 of file hsearch.c.

{
       if (dbp) {
              (void)(dbp->close)(dbp);
              dbp = NULL;
       }
}
ENTRY* hsearch ( ENTRY  ,
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);
}