diff options
Diffstat (limited to 'lib/shash.h')
-rw-r--r-- | lib/shash.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/shash.h b/lib/shash.h new file mode 100644 index 000000000..ee3fb5f57 --- /dev/null +++ b/lib/shash.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2009 Nicira Networks. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef SHASH_H +#define SHASH_H 1 + +#include "hmap.h" + +struct shash_node { + struct hmap_node node; + char *name; + void *data; +}; + +struct shash { + struct hmap map; +}; + +#define SHASH_INITIALIZER(SHASH) { HMAP_INITIALIZER(&(SHASH)->map) } + +void shash_init(struct shash *); +void shash_destroy(struct shash *); +void shash_clear(struct shash *); +void shash_add(struct shash *, const char *, void *); +void shash_delete(struct shash *, struct shash_node *); +struct shash_node *shash_find(const struct shash *, const char *); +void *shash_find_data(const struct shash *, const char *); + +#endif /* shash.h */ |