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