11673e404SJohn Birrell /*
21673e404SJohn Birrell  * CDDL HEADER START
31673e404SJohn Birrell  *
41673e404SJohn Birrell  * The contents of this file are subject to the terms of the
51673e404SJohn Birrell  * Common Development and Distribution License, Version 1.0 only
61673e404SJohn Birrell  * (the "License").  You may not use this file except in compliance
71673e404SJohn Birrell  * with the License.
81673e404SJohn Birrell  *
91673e404SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
101673e404SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
111673e404SJohn Birrell  * See the License for the specific language governing permissions
121673e404SJohn Birrell  * and limitations under the License.
131673e404SJohn Birrell  *
141673e404SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
151673e404SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
161673e404SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
171673e404SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
181673e404SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
191673e404SJohn Birrell  *
201673e404SJohn Birrell  * CDDL HEADER END
211673e404SJohn Birrell  */
221673e404SJohn Birrell /*
231673e404SJohn Birrell  * Copyright (c) 2001 by Sun Microsystems, Inc.
241673e404SJohn Birrell  * All rights reserved.
251673e404SJohn Birrell  */
261673e404SJohn Birrell 
271673e404SJohn Birrell #ifndef	_STRTAB_H
281673e404SJohn Birrell #define	_STRTAB_H
291673e404SJohn Birrell 
301673e404SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
311673e404SJohn Birrell 
321673e404SJohn Birrell #include <sys/types.h>
331673e404SJohn Birrell 
341673e404SJohn Birrell #ifdef	__cplusplus
351673e404SJohn Birrell extern "C" {
361673e404SJohn Birrell #endif
371673e404SJohn Birrell 
381673e404SJohn Birrell typedef struct strhash {
391673e404SJohn Birrell 	const char *str_data;		/* pointer to actual string data */
401673e404SJohn Birrell 	ulong_t str_buf;		/* index of string data buffer */
411673e404SJohn Birrell 	size_t str_off;			/* offset in bytes of this string */
421673e404SJohn Birrell 	size_t str_len;			/* length in bytes of this string */
431673e404SJohn Birrell 	struct strhash *str_next;	/* next string in hash chain */
441673e404SJohn Birrell } strhash_t;
451673e404SJohn Birrell 
461673e404SJohn Birrell typedef struct strtab {
471673e404SJohn Birrell 	strhash_t **str_hash;		/* array of hash buckets */
481673e404SJohn Birrell 	ulong_t str_hashsz;		/* size of hash bucket array */
491673e404SJohn Birrell 	char **str_bufs;		/* array of buffer pointers */
501673e404SJohn Birrell 	char *str_ptr;			/* pointer to current buffer location */
511673e404SJohn Birrell 	ulong_t str_nbufs;		/* size of buffer pointer array */
521673e404SJohn Birrell 	size_t str_bufsz;		/* size of individual buffer */
531673e404SJohn Birrell 	ulong_t str_nstrs;		/* total number of strings in strtab */
541673e404SJohn Birrell 	size_t str_size;		/* total size of strings in bytes */
551673e404SJohn Birrell } strtab_t;
561673e404SJohn Birrell 
571673e404SJohn Birrell extern void strtab_create(strtab_t *);
581673e404SJohn Birrell extern void strtab_destroy(strtab_t *);
591673e404SJohn Birrell extern size_t strtab_insert(strtab_t *, const char *);
601673e404SJohn Birrell extern size_t strtab_size(const strtab_t *);
611673e404SJohn Birrell extern ssize_t strtab_write(const strtab_t *,
624cc75139SJohn Birrell     ssize_t (*)(void *, size_t, void *), void *);
631673e404SJohn Birrell extern void strtab_print(const strtab_t *);
641673e404SJohn Birrell 
651673e404SJohn Birrell #ifdef	__cplusplus
661673e404SJohn Birrell }
671673e404SJohn Birrell #endif
681673e404SJohn Birrell 
691673e404SJohn Birrell #endif	/* _STRTAB_H */
70