1.\" $OpenBSD: ohash_interval.3,v 1.11 2007/05/31 19:19:30 jmc Exp $ 2.\" Copyright (c) 2001 Marc Espie <espie@openbsd.org> 3.\" 4.\" Permission to use, copy, modify, and distribute this software for any 5.\" purpose with or without fee is hereby granted, provided that the above 6.\" copyright notice and this permission notice appear in all copies. 7.\" 8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" 16.Dd $Mdocdate: May 31 2007 $ 17.Dt OPEN_HASH_HELPER 3 18.Os 19.Sh NAME 20.Nm ohash_interval , 21.Nm ohash_create_entry , 22.Nm ohash_qlookup , 23.Nm ohash_qlookupi 24.Nd helper functions for open hashing 25.Sh SYNOPSIS 26.Fd #include <stdint.h> 27.Fd #include <stddef.h> 28.Fd #include <ohash.h> 29.Ft u_int32_t 30.Fn ohash_interval "const char *start" "const char **pend" 31.Ft "void *" 32.Fn ohash_create_entry "struct ohash_info *info" "const char *start" "const char **pend" 33.Ft "unsigned int" 34.Fn ohash_qlookupi "struct ohash *h" "const char *start" "const char **pend" 35.Ft "unsigned int" 36.Fn ohash_qlookup "struct ohash *h" "const char *start" 37.Sh DESCRIPTION 38These functions are commonly used to simplify open hashing usage, and use 39similar conventions. 40They operate indifferently on NUL-terminated strings 41.Po 42by setting 43.Fa *pend 44= 45.Dv NULL 46.Pc 47or memory ranges 48.Po 49delimited by 50.Fa start 51and 52.Fa *pend 53.Pc . 54For NUL-terminated strings, as a side effect, those functions 55set 56.Fa *pend 57to the terminating NUL byte. 58.Pp 59.Fn ohash_interval 60is a simple hashing function that yields good results on common data sets. 61.Pp 62.Fn ohash_create_entry 63can be used to create a new record with a given key. 64In that case, 65the alloc field of 66.Fa info 67should point to a 68.Xr malloc 3 Ns -like 69function to allocate the storage. 70.Pp 71.Fn ohash_qlookupi 72is a wrapper function that simply calls 73.Fn ohash_interval 74and 75.Fn ohash_lookup_interval . 76.Pp 77.Fn ohash_qlookup 78is a variation on 79.Fn ohash_qlookupi 80designed for NUL-terminated strings. 81.Sh SEE ALSO 82.Xr ohash_init 3 83.Sh STANDARDS 84Those functions are completely non-standard and should be avoided in 85portable programs. 86.Sh HISTORY 87Those functions were designed and written for 88.Ox 89.Xr make 1 90by Marc Espie in 1999. 91