2005-11-30 13:36:58 +00:00
|
|
|
/*
|
|
|
|
* Summary: Chained hash tables
|
|
|
|
* Description: This module implements the hash table support used in
|
|
|
|
* various places in the library.
|
|
|
|
*
|
|
|
|
* Copy: See Copyright for the status of this software.
|
|
|
|
*
|
|
|
|
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
|
|
|
|
*/
|
|
|
|
|
2005-12-05 11:16:07 +00:00
|
|
|
#ifndef __VIR_HASH_H__
|
|
|
|
#define __VIR_HASH_H__
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The hash table.
|
|
|
|
*/
|
2005-12-05 11:16:07 +00:00
|
|
|
typedef struct _virHashTable virHashTable;
|
|
|
|
typedef virHashTable *virHashTablePtr;
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* function types:
|
|
|
|
*/
|
|
|
|
/**
|
2005-12-05 11:16:07 +00:00
|
|
|
* virHashDeallocator:
|
2005-11-30 13:36:58 +00:00
|
|
|
* @payload: the data in the hash
|
|
|
|
* @name: the name associated
|
|
|
|
*
|
|
|
|
* Callback to free data from a hash.
|
|
|
|
*/
|
2005-12-05 11:16:07 +00:00
|
|
|
typedef void (*virHashDeallocator)(void *payload, char *name);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Constructor and destructor.
|
|
|
|
*/
|
2005-12-05 11:16:07 +00:00
|
|
|
virHashTablePtr virHashCreate (int size);
|
2005-11-30 13:36:58 +00:00
|
|
|
void
|
2005-12-05 11:16:07 +00:00
|
|
|
virHashFree (virHashTablePtr table,
|
|
|
|
virHashDeallocator f);
|
|
|
|
int virHashSize (virHashTablePtr table);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a new entry to the hash table.
|
|
|
|
*/
|
2005-12-05 11:16:07 +00:00
|
|
|
int virHashAddEntry (virHashTablePtr table,
|
2005-11-30 13:36:58 +00:00
|
|
|
const char *name,
|
|
|
|
void *userdata);
|
2005-12-05 11:16:07 +00:00
|
|
|
int virHashUpdateEntry(virHashTablePtr table,
|
2005-11-30 13:36:58 +00:00
|
|
|
const char *name,
|
|
|
|
void *userdata,
|
2005-12-05 11:16:07 +00:00
|
|
|
virHashDeallocator f);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove an entry from the hash table.
|
|
|
|
*/
|
2005-12-05 11:16:07 +00:00
|
|
|
int virHashRemoveEntry(virHashTablePtr table,
|
2005-11-30 13:36:58 +00:00
|
|
|
const char *name,
|
2005-12-05 11:16:07 +00:00
|
|
|
virHashDeallocator f);
|
2005-11-30 13:36:58 +00:00
|
|
|
/*
|
|
|
|
* Retrieve the userdata.
|
|
|
|
*/
|
2005-12-05 11:16:07 +00:00
|
|
|
void * virHashLookup (virHashTablePtr table,
|
2005-11-30 13:36:58 +00:00
|
|
|
const char *name);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2005-12-05 11:16:07 +00:00
|
|
|
#endif /* ! __VIR_HASH_H__ */
|