16ff6d951SJohn Birrell /* 26ff6d951SJohn Birrell * CDDL HEADER START 36ff6d951SJohn Birrell * 46ff6d951SJohn Birrell * The contents of this file are subject to the terms of the 56ff6d951SJohn Birrell * Common Development and Distribution License (the "License"). 66ff6d951SJohn Birrell * You may not use this file except in compliance with the License. 76ff6d951SJohn Birrell * 86ff6d951SJohn Birrell * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96ff6d951SJohn Birrell * or http://www.opensolaris.org/os/licensing. 106ff6d951SJohn Birrell * See the License for the specific language governing permissions 116ff6d951SJohn Birrell * and limitations under the License. 126ff6d951SJohn Birrell * 136ff6d951SJohn Birrell * When distributing Covered Code, include this CDDL HEADER in each 146ff6d951SJohn Birrell * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156ff6d951SJohn Birrell * If applicable, add the following below this CDDL HEADER, with the 166ff6d951SJohn Birrell * fields enclosed by brackets "[]" replaced with your own identifying 176ff6d951SJohn Birrell * information: Portions Copyright [yyyy] [name of copyright owner] 186ff6d951SJohn Birrell * 196ff6d951SJohn Birrell * CDDL HEADER END 206ff6d951SJohn Birrell */ 216ff6d951SJohn Birrell 226ff6d951SJohn Birrell /* 236ff6d951SJohn Birrell * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 246ff6d951SJohn Birrell * Use is subject to license terms. 256ff6d951SJohn Birrell */ 266ff6d951SJohn Birrell 276ff6d951SJohn Birrell #ifndef _DT_STRTAB_H 286ff6d951SJohn Birrell #define _DT_STRTAB_H 296ff6d951SJohn Birrell 306ff6d951SJohn Birrell #pragma ident "%Z%%M% %I% %E% SMI" 316ff6d951SJohn Birrell 326ff6d951SJohn Birrell #include <sys/types.h> 336ff6d951SJohn Birrell 346ff6d951SJohn Birrell #ifdef __cplusplus 356ff6d951SJohn Birrell extern "C" { 366ff6d951SJohn Birrell #endif 376ff6d951SJohn Birrell 386ff6d951SJohn Birrell typedef struct dt_strhash { 396ff6d951SJohn Birrell const char *str_data; /* pointer to actual string data */ 406ff6d951SJohn Birrell ulong_t str_buf; /* index of string data buffer */ 416ff6d951SJohn Birrell size_t str_off; /* offset in bytes of this string */ 426ff6d951SJohn Birrell size_t str_len; /* length in bytes of this string */ 436ff6d951SJohn Birrell struct dt_strhash *str_next; /* next string in hash chain */ 446ff6d951SJohn Birrell } dt_strhash_t; 456ff6d951SJohn Birrell 466ff6d951SJohn Birrell typedef struct dt_strtab { 476ff6d951SJohn Birrell dt_strhash_t **str_hash; /* array of hash buckets */ 486ff6d951SJohn Birrell ulong_t str_hashsz; /* size of hash bucket array */ 496ff6d951SJohn Birrell char **str_bufs; /* array of buffer pointers */ 506ff6d951SJohn Birrell char *str_ptr; /* pointer to current buffer location */ 516ff6d951SJohn Birrell ulong_t str_nbufs; /* size of buffer pointer array */ 526ff6d951SJohn Birrell size_t str_bufsz; /* size of individual buffer */ 536ff6d951SJohn Birrell ulong_t str_nstrs; /* total number of strings in strtab */ 546ff6d951SJohn Birrell size_t str_size; /* total size of strings in bytes */ 556ff6d951SJohn Birrell } dt_strtab_t; 566ff6d951SJohn Birrell 576ff6d951SJohn Birrell typedef ssize_t dt_strtab_write_f(const char *, size_t, size_t, void *); 586ff6d951SJohn Birrell 596ff6d951SJohn Birrell extern dt_strtab_t *dt_strtab_create(size_t); 606ff6d951SJohn Birrell extern void dt_strtab_destroy(dt_strtab_t *); 61*d2d16e56SMark Johnston extern boolean_t dt_strtab_empty(dt_strtab_t *); 626ff6d951SJohn Birrell extern ssize_t dt_strtab_index(dt_strtab_t *, const char *); 636ff6d951SJohn Birrell extern ssize_t dt_strtab_insert(dt_strtab_t *, const char *); 646ff6d951SJohn Birrell extern size_t dt_strtab_size(const dt_strtab_t *); 656ff6d951SJohn Birrell extern ssize_t dt_strtab_write(const dt_strtab_t *, 666ff6d951SJohn Birrell dt_strtab_write_f *, void *); 676ff6d951SJohn Birrell extern ulong_t dt_strtab_hash(const char *, size_t *); 686ff6d951SJohn Birrell 696ff6d951SJohn Birrell #ifdef __cplusplus 706ff6d951SJohn Birrell } 716ff6d951SJohn Birrell #endif 726ff6d951SJohn Birrell 736ff6d951SJohn Birrell #endif /* _DT_STRTAB_H */ 74