10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2769Sahl * Common Development and Distribution License (the "License"). 6*2769Sahl * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*2769Sahl 220Sstevel@tonic-gate /* 23*2769Sahl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _DT_STRTAB_H 280Sstevel@tonic-gate #define _DT_STRTAB_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate typedef struct dt_strhash { 390Sstevel@tonic-gate const char *str_data; /* pointer to actual string data */ 400Sstevel@tonic-gate ulong_t str_buf; /* index of string data buffer */ 410Sstevel@tonic-gate size_t str_off; /* offset in bytes of this string */ 420Sstevel@tonic-gate size_t str_len; /* length in bytes of this string */ 430Sstevel@tonic-gate struct dt_strhash *str_next; /* next string in hash chain */ 440Sstevel@tonic-gate } dt_strhash_t; 450Sstevel@tonic-gate 460Sstevel@tonic-gate typedef struct dt_strtab { 470Sstevel@tonic-gate dt_strhash_t **str_hash; /* array of hash buckets */ 480Sstevel@tonic-gate ulong_t str_hashsz; /* size of hash bucket array */ 490Sstevel@tonic-gate char **str_bufs; /* array of buffer pointers */ 500Sstevel@tonic-gate char *str_ptr; /* pointer to current buffer location */ 510Sstevel@tonic-gate ulong_t str_nbufs; /* size of buffer pointer array */ 520Sstevel@tonic-gate size_t str_bufsz; /* size of individual buffer */ 530Sstevel@tonic-gate ulong_t str_nstrs; /* total number of strings in strtab */ 540Sstevel@tonic-gate size_t str_size; /* total size of strings in bytes */ 550Sstevel@tonic-gate } dt_strtab_t; 560Sstevel@tonic-gate 570Sstevel@tonic-gate typedef ssize_t dt_strtab_write_f(const char *, size_t, size_t, void *); 580Sstevel@tonic-gate 590Sstevel@tonic-gate extern dt_strtab_t *dt_strtab_create(size_t); 600Sstevel@tonic-gate extern void dt_strtab_destroy(dt_strtab_t *); 61*2769Sahl extern ssize_t dt_strtab_index(dt_strtab_t *, const char *); 620Sstevel@tonic-gate extern ssize_t dt_strtab_insert(dt_strtab_t *, const char *); 630Sstevel@tonic-gate extern size_t dt_strtab_size(const dt_strtab_t *); 640Sstevel@tonic-gate extern ssize_t dt_strtab_write(const dt_strtab_t *, 650Sstevel@tonic-gate dt_strtab_write_f *, void *); 660Sstevel@tonic-gate extern ulong_t dt_strtab_hash(const char *, size_t *); 670Sstevel@tonic-gate 680Sstevel@tonic-gate #ifdef __cplusplus 690Sstevel@tonic-gate } 700Sstevel@tonic-gate #endif 710Sstevel@tonic-gate 720Sstevel@tonic-gate #endif /* _DT_STRTAB_H */ 73