hash_ops.h File Reference

Hash operations header file. More...

#include "global.h"
#include <db.h>
Include dependency graph for hash_ops.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hash_s
 The abstract hash type. More...

Defines

#define HASH_TEMPORARY
 Only a temporary hash; not available in gdbm.
#define HASH_REMEMBER_FILENAME   (0x40000000)
 This flag tells hsh__new() to remember the filename, for later cleaning-up.

Typedefs

typedef struct hash_shash_t
 A convenience type.

Functions

int hsh__new (char *wcfile, char *name, int gdbm_mode, hash_t *hash)
 Create a new hash for wcfile with the given name.



#define HASH__LIST_MAX   (32)
 Number of slots reserved.
int hsh__insert_pointer (hash_t hash, datum key, void *value)
 For short-time storage (single program run): Insert the pointer value into the hash at key.
int hsh__list_get (hash_t hash, datum current_key, datum *next_key, struct estat **arr[], int *found)
 Get an list of found entries from hash addressed by current_key into the (statically allocated) arr.
int hsh__store_charp (hash_t db, char *key, char *value)
 Store character strings in the hash table.
int hsh__store (hash_t db, datum key, datum value)
 Store some value in the hash table.
int hsh__fetch (hash_t db, datum key, datum *value)
 Read value associated with some key in db.
int hsh__first (hash_t db, datum *key)
 Find first key.
int hsh__next (hash_t db, datum *key, const datum *oldkey)
 Find next key.
int hsh__register_delete (hash_t db, datum key)
 Registers some key for deletion on database close.
int hsh__close (hash_t db, int has_failed)
 Close a property file.
int hsh__collect_garbage (hash_t db, int *did_remove)
 Collect garbage in the hash table.

Detailed Description

Hash operations header file.

Similar to the property operations; but these here work on a hash of lists, to be able to store multiple files with the same name.

Definition in file hash_ops.h.


Define Documentation

#define HASH__LIST_MAX   (32)

Number of slots reserved.

Lists addressed by some hash.

Definition at line 61 of file hash_ops.h.

Referenced by cm___match_children(), hsh__insert_pointer(), and hsh__list_get().

#define HASH_REMEMBER_FILENAME   (0x40000000)

This flag tells hsh__new() to remember the filename, for later cleaning-up.

Definition at line 56 of file hash_ops.h.

Referenced by cm___get_base_source(), hsh__new(), ops__apply_group(), and prp__set_from_aprhash().

#define HASH_TEMPORARY
Value:
((GDBM_NEWDB | GDBM_READER | \
            GDBM_WRCREAT | GDBM_WRITER) +1)

Only a temporary hash; not available in gdbm.

Unless the predefined constants include the value 0, and ORed together give -1, this is a distinct value.

Definition at line 52 of file hash_ops.h.

Referenced by cm__detect(), hsh___new_bare(), and hsh__register_delete().


Typedef Documentation

typedef struct hash_s* hash_t

A convenience type.

Definition at line 25 of file hash_ops.h.


Function Documentation

int hsh__close ( hash_t  db,
int  has_failed 
)

Close a property file.

Close a property file.

If has_failed is set, some error has happened, and the registered keys are not used for deletion (like a ROLLBACK).

Definition at line 326 of file hash_ops.c.

References hash_s::db, DEBUGP, hash_s::filename, hsh__collect_garbage(), hsh__first(), IF_FREE, STOPIF, hash_s::to_delete, and waa__delete_byext().

Referenced by ci___send_user_props(), cm___dump_list(), cm___get_base_source(), cm___make_copy(), cm__detect(), prp__g_work(), prp__l_work(), prp__open_get_close(), prp__s_work(), prp__set_from_aprhash(), and up__fetch_decoder().

Here is the call graph for this function:

Here is the caller graph for this function:

int hsh__collect_garbage ( hash_t  db,
int *  did_remove 
)

Collect garbage in the hash table.

Collect garbage in the hash table.

The previously marked keys in the hash table are removed; it is not checked for empty-ness nor reorganized.

Definition at line 287 of file hash_ops.c.

References hash_s::db, DEBUGP, STOPIF_CODE_ERR, and hash_s::to_delete.

Referenced by hsh__close().

Here is the caller graph for this function:

int hsh__fetch ( hash_t  db,
datum  key,
datum *  value 
)

Read value associated with some key in db.

Memory of datum::dptr is malloc()ed.

Definition at line 378 of file hash_ops.c.

References hash_s::db, and IF_FREE.

Referenced by cm___dump_list(), cm___get_base_source(), hsh__insert_pointer(), hsh__list_get(), and prp__fetch().

Here is the caller graph for this function:

int hsh__first ( hash_t  db,
datum *  key 
)

Find first key.

Definition at line 394 of file hash_ops.c.

References hash_s::db.

Referenced by cm___dump_list(), hsh__close(), and prp__first().

Here is the caller graph for this function:

int hsh__insert_pointer ( hash_t  hash,
datum  key,
void *  value 
)

For short-time storage (single program run): Insert the pointer value into the hash at key.

Definition at line 494 of file hash_ops.c.

References BUG_ON, hsh___list::count, hsh___list::entries, HASH__LIST_MAX, hsh__fetch(), hsh__store(), and STOPIF.

Referenced by cm___hash_register().

Here is the call graph for this function:

Here is the caller graph for this function:

int hsh__list_get ( hash_t  hash,
datum  current_key,
datum *  next_key,
struct estat **  arr[],
int *  found 
)

Get an list of found entries from hash addressed by current_key into the (statically allocated) arr.

Get an list of found entries from hash addressed by current_key into the (statically allocated) arr.

If next_key is not NULL, it is set so that the next query can use this key for the next element. If *next_key==NULL, no next element is there; everything has been returned. If no (more) entry could be found, ENOENT is returned, and *found==0.

In case of storage via an array hsh__list must store some internal state; therefore only a single loop is (currently) possible.

Definition at line 563 of file hash_ops.c.

References BUG_ON, hsh___list::count, hsh___list::entries, HASH__LIST_MAX, hsh__fetch(), and STOPIF.

Referenced by cm___hash_list(), and cm___match_children().

Here is the call graph for this function:

Here is the caller graph for this function:

int hsh__new ( char *  wcfile,
char *  name,
int  gdbm_mode,
hash_t output 
)

Create a new hash for wcfile with the given name.

Create a new hash for wcfile with the given name.

If flags is GDBM_NEWDB, the file gets deleted immediately; there's no need to keep it around any longer, and it's not defined where it gets located. If another open mode is used, the entry is always created in the WAA or CONF base directory for wcfile, ie. the hashed path for the working copy root.

Definition at line 258 of file hash_ops.c.

References hash_s::db, hash_s::filename, HASH_REMEMBER_FILENAME, hlp__calloc(), hsh___new_bare(), IF_FREE, and STOPIF.

Referenced by cm___dump_list(), cm___get_base_source(), cm___make_copy(), cm__detect(), and prp__open_byname().

Here is the call graph for this function:

Here is the caller graph for this function:

int hsh__next ( hash_t  db,
datum *  key,
const datum *  oldkey 
)

Find next key.

Find next key.

If oldkey==key the ->dptr is free()d; else the caller has to do that.

Definition at line 410 of file hash_ops.c.

References hash_s::db, and IF_FREE.

Referenced by cm___dump_list(), and prp__next().

Here is the caller graph for this function:

int hsh__register_delete ( hash_t  db,
datum  key 
)

Registers some key for deletion on database close.

Definition at line 609 of file hash_ops.c.

References DEBUGP, HASH_TEMPORARY, hsh___new_bare(), STOPIF, STOPIF_CODE_ERR, and hash_s::to_delete.

Referenced by ci___send_user_props(), and cm___get_base_source().

Here is the call graph for this function:

Here is the caller graph for this function:

int hsh__store ( hash_t  db,
datum  key,
datum  value 
)

Store some value in the hash table.

Definition at line 432 of file hash_ops.c.

References hash_s::db, and STOPIF_CODE_ERR.

Referenced by hsh__insert_pointer(), hsh__store_charp(), and prp__store().

Here is the caller graph for this function:

int hsh__store_charp ( hash_t  db,
char *  keyp,
char *  valuep 
)

Store character strings in the hash table.

Simple hash operations.

These are just wrappers, and are incompatible to the other hash functions - they don't store any links to other elements.

Store character strings in the hash table.

The delimiting \0 is stored, too.

Definition at line 451 of file hash_ops.c.

References hsh__store().

Referenced by cm___make_copy().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated for fsvs by  doxygen 1.6.1