1178479Sjb/*
2178479Sjb * CDDL HEADER START
3178479Sjb *
4178479Sjb * The contents of this file are subject to the terms of the
5178479Sjb * Common Development and Distribution License (the "License").
6178479Sjb * You may not use this file except in compliance with the License.
7178479Sjb *
8178479Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9178479Sjb * or http://www.opensolaris.org/os/licensing.
10178479Sjb * See the License for the specific language governing permissions
11178479Sjb * and limitations under the License.
12178479Sjb *
13178479Sjb * When distributing Covered Code, include this CDDL HEADER in each
14178479Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15178479Sjb * If applicable, add the following below this CDDL HEADER, with the
16178479Sjb * fields enclosed by brackets "[]" replaced with your own identifying
17178479Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
18178479Sjb *
19178479Sjb * CDDL HEADER END
20178479Sjb */
21178479Sjb
22178479Sjb/*
23178479Sjb * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24178479Sjb * Use is subject to license terms.
25178479Sjb */
26178479Sjb
27178479Sjb#ifndef	_DT_STRTAB_H
28178479Sjb#define	_DT_STRTAB_H
29178479Sjb
30178479Sjb#pragma ident	"%Z%%M%	%I%	%E% SMI"
31178479Sjb
32178479Sjb#include <sys/types.h>
33178479Sjb
34178479Sjb#ifdef	__cplusplus
35178479Sjbextern "C" {
36178479Sjb#endif
37178479Sjb
38178479Sjbtypedef struct dt_strhash {
39178479Sjb	const char *str_data;		/* pointer to actual string data */
40178479Sjb	ulong_t str_buf;		/* index of string data buffer */
41178479Sjb	size_t str_off;			/* offset in bytes of this string */
42178479Sjb	size_t str_len;			/* length in bytes of this string */
43178479Sjb	struct dt_strhash *str_next;	/* next string in hash chain */
44178479Sjb} dt_strhash_t;
45178479Sjb
46178479Sjbtypedef struct dt_strtab {
47178479Sjb	dt_strhash_t **str_hash;	/* array of hash buckets */
48178479Sjb	ulong_t str_hashsz;		/* size of hash bucket array */
49178479Sjb	char **str_bufs;		/* array of buffer pointers */
50178479Sjb	char *str_ptr;			/* pointer to current buffer location */
51178479Sjb	ulong_t str_nbufs;		/* size of buffer pointer array */
52178479Sjb	size_t str_bufsz;		/* size of individual buffer */
53178479Sjb	ulong_t str_nstrs;		/* total number of strings in strtab */
54178479Sjb	size_t str_size;		/* total size of strings in bytes */
55178479Sjb} dt_strtab_t;
56178479Sjb
57178479Sjbtypedef ssize_t dt_strtab_write_f(const char *, size_t, size_t, void *);
58178479Sjb
59178479Sjbextern dt_strtab_t *dt_strtab_create(size_t);
60178479Sjbextern void dt_strtab_destroy(dt_strtab_t *);
61178479Sjbextern ssize_t dt_strtab_index(dt_strtab_t *, const char *);
62178479Sjbextern ssize_t dt_strtab_insert(dt_strtab_t *, const char *);
63178479Sjbextern size_t dt_strtab_size(const dt_strtab_t *);
64178479Sjbextern ssize_t dt_strtab_write(const dt_strtab_t *,
65178479Sjb    dt_strtab_write_f *, void *);
66178479Sjbextern ulong_t dt_strtab_hash(const char *, size_t *);
67178479Sjb
68178479Sjb#ifdef	__cplusplus
69178479Sjb}
70178479Sjb#endif
71178479Sjb
72178479Sjb#endif	/* _DT_STRTAB_H */
73