xref: /freebsd-src/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h (revision 1673e4046da975ab0e2bf67d45499930ebab0dbe)
1*1673e404SJohn Birrell /*
2*1673e404SJohn Birrell  * CDDL HEADER START
3*1673e404SJohn Birrell  *
4*1673e404SJohn Birrell  * The contents of this file are subject to the terms of the
5*1673e404SJohn Birrell  * Common Development and Distribution License, Version 1.0 only
6*1673e404SJohn Birrell  * (the "License").  You may not use this file except in compliance
7*1673e404SJohn Birrell  * with the License.
8*1673e404SJohn Birrell  *
9*1673e404SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*1673e404SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
11*1673e404SJohn Birrell  * See the License for the specific language governing permissions
12*1673e404SJohn Birrell  * and limitations under the License.
13*1673e404SJohn Birrell  *
14*1673e404SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
15*1673e404SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*1673e404SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
17*1673e404SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
18*1673e404SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
19*1673e404SJohn Birrell  *
20*1673e404SJohn Birrell  * CDDL HEADER END
21*1673e404SJohn Birrell  */
22*1673e404SJohn Birrell /*
23*1673e404SJohn Birrell  * Copyright (c) 2001 by Sun Microsystems, Inc.
24*1673e404SJohn Birrell  * All rights reserved.
25*1673e404SJohn Birrell  */
26*1673e404SJohn Birrell 
27*1673e404SJohn Birrell #ifndef	_STRTAB_H
28*1673e404SJohn Birrell #define	_STRTAB_H
29*1673e404SJohn Birrell 
30*1673e404SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1673e404SJohn Birrell 
32*1673e404SJohn Birrell #include <sys/types.h>
33*1673e404SJohn Birrell 
34*1673e404SJohn Birrell #ifdef	__cplusplus
35*1673e404SJohn Birrell extern "C" {
36*1673e404SJohn Birrell #endif
37*1673e404SJohn Birrell 
38*1673e404SJohn Birrell typedef struct strhash {
39*1673e404SJohn Birrell 	const char *str_data;		/* pointer to actual string data */
40*1673e404SJohn Birrell 	ulong_t str_buf;		/* index of string data buffer */
41*1673e404SJohn Birrell 	size_t str_off;			/* offset in bytes of this string */
42*1673e404SJohn Birrell 	size_t str_len;			/* length in bytes of this string */
43*1673e404SJohn Birrell 	struct strhash *str_next;	/* next string in hash chain */
44*1673e404SJohn Birrell } strhash_t;
45*1673e404SJohn Birrell 
46*1673e404SJohn Birrell typedef struct strtab {
47*1673e404SJohn Birrell 	strhash_t **str_hash;		/* array of hash buckets */
48*1673e404SJohn Birrell 	ulong_t str_hashsz;		/* size of hash bucket array */
49*1673e404SJohn Birrell 	char **str_bufs;		/* array of buffer pointers */
50*1673e404SJohn Birrell 	char *str_ptr;			/* pointer to current buffer location */
51*1673e404SJohn Birrell 	ulong_t str_nbufs;		/* size of buffer pointer array */
52*1673e404SJohn Birrell 	size_t str_bufsz;		/* size of individual buffer */
53*1673e404SJohn Birrell 	ulong_t str_nstrs;		/* total number of strings in strtab */
54*1673e404SJohn Birrell 	size_t str_size;		/* total size of strings in bytes */
55*1673e404SJohn Birrell } strtab_t;
56*1673e404SJohn Birrell 
57*1673e404SJohn Birrell extern void strtab_create(strtab_t *);
58*1673e404SJohn Birrell extern void strtab_destroy(strtab_t *);
59*1673e404SJohn Birrell extern size_t strtab_insert(strtab_t *, const char *);
60*1673e404SJohn Birrell extern size_t strtab_size(const strtab_t *);
61*1673e404SJohn Birrell extern ssize_t strtab_write(const strtab_t *,
62*1673e404SJohn Birrell     ssize_t (*)(void *, size_t, void *), void *);
63*1673e404SJohn Birrell extern void strtab_print(const strtab_t *);
64*1673e404SJohn Birrell 
65*1673e404SJohn Birrell #ifdef	__cplusplus
66*1673e404SJohn Birrell }
67*1673e404SJohn Birrell #endif
68*1673e404SJohn Birrell 
69*1673e404SJohn Birrell #endif	/* _STRTAB_H */
70