| 1 | /* $OpenBSD: icdb.h,v 1.4 2016/09/04 14:51:39 nicm Exp $ */ |
| 2 | /* |
| 3 | * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> |
| 4 | * |
| 5 | * Permission to use, copy, modify, and distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #ifndef _ICDB_H_ |
| 19 | #define _ICDB_H_ |
| 20 | |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | __BEGIN_DECLS |
| 24 | |
| 25 | struct icdb; |
| 26 | |
| 27 | struct icdb *icdb_new(uint32_t version, uint32_t nentries, uint32_t entrysize, |
| 28 | uint32_t nkeys, const uint32_t *keysizes, const uint32_t *keyoffsets); |
| 29 | |
| 30 | struct icdb *icdb_open(const char *name, int flags, uint32_t version); |
| 31 | int icdb_get(struct icdb *db, void *entry, uint32_t idx); |
| 32 | int icdb_lookup(struct icdb *db, int keynum, const void *key, void *entry, |
| 33 | uint32_t *idxp); |
| 34 | int icdb_nentries(struct icdb *db); |
| 35 | const void *icdb_entries(struct icdb *db); |
| 36 | int icdb_update(struct icdb *db, const void *entry, int offset); |
| 37 | int icdb_add(struct icdb *db, const void *entry); |
| 38 | int icdb_rehash(struct icdb *db); |
| 39 | int icdb_save(struct icdb *db, int fd); |
| 40 | int icdb_close(struct icdb *db); |
| 41 | |
| 42 | __END_DECLS |
| 43 | |
| 44 | #endif /* !_ICDB_H_ */ |