1178481Sjb/*
2178481Sjb * CDDL HEADER START
3178481Sjb *
4178481Sjb * The contents of this file are subject to the terms of the
5178481Sjb * Common Development and Distribution License, Version 1.0 only
6178481Sjb * (the "License").  You may not use this file except in compliance
7178481Sjb * with the License.
8178481Sjb *
9178481Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10178481Sjb * or http://www.opensolaris.org/os/licensing.
11178481Sjb * See the License for the specific language governing permissions
12178481Sjb * and limitations under the License.
13178481Sjb *
14178481Sjb * When distributing Covered Code, include this CDDL HEADER in each
15178481Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16178481Sjb * If applicable, add the following below this CDDL HEADER, with the
17178481Sjb * fields enclosed by brackets "[]" replaced with your own identifying
18178481Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
19178481Sjb *
20178481Sjb * CDDL HEADER END
21178481Sjb */
22178481Sjb/*
23178481Sjb * Copyright (c) 2001 by Sun Microsystems, Inc.
24178481Sjb * All rights reserved.
25178481Sjb */
26178481Sjb
27178481Sjb#ifndef	_STRTAB_H
28178481Sjb#define	_STRTAB_H
29178481Sjb
30178481Sjb#pragma ident	"%Z%%M%	%I%	%E% SMI"
31178481Sjb
32178481Sjb#include <sys/types.h>
33178481Sjb
34178481Sjb#ifdef	__cplusplus
35178481Sjbextern "C" {
36178481Sjb#endif
37178481Sjb
38178481Sjbtypedef struct strhash {
39178481Sjb	const char *str_data;		/* pointer to actual string data */
40178481Sjb	ulong_t str_buf;		/* index of string data buffer */
41178481Sjb	size_t str_off;			/* offset in bytes of this string */
42178481Sjb	size_t str_len;			/* length in bytes of this string */
43178481Sjb	struct strhash *str_next;	/* next string in hash chain */
44178481Sjb} strhash_t;
45178481Sjb
46178481Sjbtypedef struct strtab {
47178481Sjb	strhash_t **str_hash;		/* array of hash buckets */
48178481Sjb	ulong_t str_hashsz;		/* size of hash bucket array */
49178481Sjb	char **str_bufs;		/* array of buffer pointers */
50178481Sjb	char *str_ptr;			/* pointer to current buffer location */
51178481Sjb	ulong_t str_nbufs;		/* size of buffer pointer array */
52178481Sjb	size_t str_bufsz;		/* size of individual buffer */
53178481Sjb	ulong_t str_nstrs;		/* total number of strings in strtab */
54178481Sjb	size_t str_size;		/* total size of strings in bytes */
55178481Sjb} strtab_t;
56178481Sjb
57178481Sjbextern void strtab_create(strtab_t *);
58178481Sjbextern void strtab_destroy(strtab_t *);
59178481Sjbextern size_t strtab_insert(strtab_t *, const char *);
60178481Sjbextern size_t strtab_size(const strtab_t *);
61178481Sjbextern ssize_t strtab_write(const strtab_t *,
62178546Sjb    ssize_t (*)(void *, size_t, void *), void *);
63178481Sjbextern void strtab_print(const strtab_t *);
64178481Sjb
65178481Sjb#ifdef	__cplusplus
66178481Sjb}
67178481Sjb#endif
68178481Sjb
69178481Sjb#endif	/* _STRTAB_H */
70