2005-11-30 13:36:58 +00:00
|
|
|
/*
|
2006-04-09 13:11:22 +00:00
|
|
|
* Summary: Chained hash tables and domain/connections handling
|
|
|
|
* Description: This module implements the hash table and allocation and
|
|
|
|
* deallocation of domains and connections
|
2005-11-30 13:36:58 +00:00
|
|
|
*
|
2011-02-18 21:30:24 +00:00
|
|
|
* Copy: Copyright (C) 2005, 2011 Red Hat, Inc.
|
2005-11-30 13:36:58 +00:00
|
|
|
*
|
|
|
|
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
|
2006-04-09 13:11:22 +00:00
|
|
|
* Daniel Veillard <veillard@redhat.com>
|
2005-11-30 13:36:58 +00:00
|
|
|
*/
|
|
|
|
|
2005-12-05 11:16:07 +00:00
|
|
|
#ifndef __VIR_HASH_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_HASH_H__
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The hash table.
|
|
|
|
*/
|
2006-04-09 13:11:22 +00:00
|
|
|
typedef struct _virHashTable virHashTable;
|
|
|
|
typedef virHashTable *virHashTablePtr;
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* function types:
|
|
|
|
*/
|
2006-03-15 12:13:25 +00:00
|
|
|
|
2005-11-30 13:36:58 +00:00
|
|
|
/**
|
2011-02-22 15:11:59 +00:00
|
|
|
* virHashDataFree:
|
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.
|
|
|
|
*/
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
typedef void (*virHashDataFree) (void *payload, const void *name);
|
2006-11-15 20:11:56 +00:00
|
|
|
/**
|
|
|
|
* virHashIterator:
|
|
|
|
* @payload: the data in the hash
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
* @name: the hash key
|
2006-11-15 20:11:56 +00:00
|
|
|
* @data: user supplied data blob
|
|
|
|
*
|
|
|
|
* Callback to process a hash entry during iteration
|
|
|
|
*/
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
typedef void (*virHashIterator) (void *payload, const void *name, void *data);
|
2006-11-15 20:11:56 +00:00
|
|
|
/**
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
* virHashSearcher:
|
2006-11-15 20:11:56 +00:00
|
|
|
* @payload: the data in the hash
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
* @name: the hash key
|
2006-11-15 20:11:56 +00:00
|
|
|
* @data: user supplied data blob
|
|
|
|
*
|
|
|
|
* Callback to identify hash entry desired
|
|
|
|
* Returns 1 if the hash entry is desired, 0 to move
|
|
|
|
* to next entry
|
|
|
|
*/
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
typedef int (*virHashSearcher) (const void *payload, const void *name,
|
2011-02-18 21:30:24 +00:00
|
|
|
const void *data);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
/**
|
|
|
|
* virHashKeyCode:
|
|
|
|
* @name: the hash key
|
|
|
|
*
|
|
|
|
* Compute the hash code corresponding to the key @name
|
|
|
|
*
|
|
|
|
* Returns the hash code
|
|
|
|
*/
|
|
|
|
typedef unsigned long (*virHashKeyCode)(const void *name);
|
|
|
|
/**
|
|
|
|
* virHashKeyEqual:
|
|
|
|
* @namea: the first hash key
|
|
|
|
* @nameb: the second hash key
|
|
|
|
*
|
|
|
|
* Compare two hash keys for equality
|
|
|
|
*
|
|
|
|
* Returns true if the keys are equal, false otherwise
|
|
|
|
*/
|
|
|
|
typedef bool (*virHashKeyEqual)(const void *namea, const void *nameb);
|
|
|
|
/**
|
|
|
|
* virHashKeyCopy:
|
|
|
|
* @name: the hash key
|
|
|
|
*
|
|
|
|
* Create a copy of the hash key, duplicating
|
|
|
|
* memory allocation where applicable
|
|
|
|
*
|
|
|
|
* Returns a newly allocated copy of @name
|
|
|
|
*/
|
|
|
|
typedef void *(*virHashKeyCopy)(const void *name);
|
|
|
|
/**
|
|
|
|
* virHashKeyFree:
|
|
|
|
* @name: the hash key
|
|
|
|
*
|
|
|
|
* Free any memory associated with the hash
|
|
|
|
* key @name
|
|
|
|
*/
|
|
|
|
typedef void (*virHashKeyFree)(void *name);
|
|
|
|
|
2005-11-30 13:36:58 +00:00
|
|
|
/*
|
|
|
|
* Constructor and destructor.
|
|
|
|
*/
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
virHashTablePtr virHashCreate(int size,
|
|
|
|
virHashDataFree dataFree);
|
|
|
|
virHashTablePtr virHashCreateFull(int size,
|
|
|
|
virHashDataFree dataFree,
|
|
|
|
virHashKeyCode keyCode,
|
|
|
|
virHashKeyEqual keyEqual,
|
|
|
|
virHashKeyCopy keyCopy,
|
|
|
|
virHashKeyFree keyFree);
|
2011-02-18 21:30:24 +00:00
|
|
|
void virHashFree(virHashTablePtr table);
|
2006-04-09 13:11:22 +00:00
|
|
|
int virHashSize(virHashTablePtr table);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a new entry to the hash table.
|
|
|
|
*/
|
2006-04-09 13:11:22 +00:00
|
|
|
int virHashAddEntry(virHashTablePtr table,
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
const void *name, void *userdata);
|
2006-04-09 13:11:22 +00:00
|
|
|
int virHashUpdateEntry(virHashTablePtr table,
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
const void *name,
|
2011-02-22 15:11:59 +00:00
|
|
|
void *userdata);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove an entry from the hash table.
|
|
|
|
*/
|
2006-04-09 13:11:22 +00:00
|
|
|
int virHashRemoveEntry(virHashTablePtr table,
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
const void *name);
|
2006-03-15 12:13:25 +00:00
|
|
|
|
2005-11-30 13:36:58 +00:00
|
|
|
/*
|
|
|
|
* Retrieve the userdata.
|
|
|
|
*/
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
void *virHashLookup(virHashTablePtr table, const void *name);
|
2005-11-30 13:36:58 +00:00
|
|
|
|
2011-02-22 15:11:59 +00:00
|
|
|
/*
|
|
|
|
* Retrieve & remove the userdata.
|
|
|
|
*/
|
Allow hash tables to use generic pointers as keys
Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided
* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
qemu/qemu_command.c, qemu/qemu_driver.c,
qemu/qemu_process.c, uml/uml_driver.c,
xen/xm_internal.c: s/char */void */ in hash callbacks
2011-02-22 15:11:59 +00:00
|
|
|
void *virHashSteal(virHashTablePtr table, const void *name);
|
2011-02-22 15:11:59 +00:00
|
|
|
|
2006-11-15 20:11:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterators
|
|
|
|
*/
|
2009-10-14 10:17:24 +00:00
|
|
|
int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data);
|
2011-02-22 15:11:59 +00:00
|
|
|
int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data);
|
2006-11-15 20:11:56 +00:00
|
|
|
void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data);
|
|
|
|
|
2006-03-15 12:13:25 +00:00
|
|
|
#endif /* ! __VIR_HASH_H__ */
|