|
| 1 | +/* |
| 2 | + This file is part of RIBS2.0 (Robust Infrastructure for Backend Systems). |
| 3 | + RIBS is an infrastructure for building great SaaS applications (but not |
| 4 | + limited to). |
| 5 | +
|
| 6 | + Copyright (C) 2014 Adap.tv, Inc. |
| 7 | +
|
| 8 | + RIBS is free software: you can redistribute it and/or modify |
| 9 | + it under the terms of the GNU Lesser General Public License as published by |
| 10 | + the Free Software Foundation, version 2.1 of the License. |
| 11 | +
|
| 12 | + RIBS is distributed in the hope that it will be useful, |
| 13 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + GNU Lesser General Public License for more details. |
| 16 | +
|
| 17 | + You should have received a copy of the GNU Lesser General Public License |
| 18 | + along with RIBS. If not, see <http://www.gnu.org/licenses/>. |
| 19 | +*/ |
| 20 | +#ifndef _THASHTABLE__H_ |
| 21 | +#define _THASHTABLE__H_ |
| 22 | + |
| 23 | +#include "ribs_defs.h" |
| 24 | +#include <string.h> |
| 25 | + |
| 26 | +struct thashtable; |
| 27 | +struct thashtable_internal_rec; |
| 28 | + |
| 29 | +typedef struct thashtable_internal_rec thashtable_rec_t; |
| 30 | + |
| 31 | +struct thashtable *thashtable_create(void); |
| 32 | +thashtable_rec_t *thashtable_insert(struct thashtable *tht, const void *key, size_t key_len, const void *val, size_t val_len, int *inserted); |
| 33 | +thashtable_rec_t *thashtable_put(struct thashtable *tht, const void *key, size_t key_len, const void *val, size_t val_len); |
| 34 | +thashtable_rec_t *thashtable_insert_alloc(struct thashtable *tht, const void *key, size_t key_len, size_t val_len); |
| 35 | +thashtable_rec_t *thashtable_lookup(struct thashtable *tht, const void *key, size_t key_len); |
| 36 | +thashtable_rec_t *thashtable_remove(struct thashtable *tht, const void *key, size_t key_len); |
| 37 | +int thashtable_foreach(struct thashtable *tht, int (*func)(thashtable_rec_t *rec)); |
| 38 | + |
| 39 | +static inline void *thashtable_get_key(thashtable_rec_t *rec); |
| 40 | +static inline uint32_t thashtable_get_key_size(thashtable_rec_t *rec); |
| 41 | +static inline void *thashtable_get_val(thashtable_rec_t *rec); |
| 42 | +static inline uint32_t thashtable_get_val_size(thashtable_rec_t *rec); |
| 43 | +static inline uint32_t thashtable_get_size(struct thashtable *tht); |
| 44 | +static inline const char *thashtable_lookup_str(struct thashtable *tht, const char *key, const char *default_val); |
| 45 | + |
| 46 | +#include "../src/_thashtable.c" |
| 47 | + |
| 48 | +#endif // _THASHTABLE__H_ |
0 commit comments