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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2006 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 "@(#)dt_strtab.h 1.4 06/09/19 SMI" 31 32#if !defined(__APPLE__) 33#include <sys/types.h> 34#else /* is Apple Mac OS X */ 35#include <sys/types.h> 36#include "darwin_shim.h" 37#endif /* __APPLE__ */ 38 39#ifdef __cplusplus 40extern "C" { 41#endif 42 43typedef struct dt_strhash { 44 const char *str_data; /* pointer to actual string data */ 45 ulong_t str_buf; /* index of string data buffer */ 46 size_t str_off; /* offset in bytes of this string */ 47 size_t str_len; /* length in bytes of this string */ 48 struct dt_strhash *str_next; /* next string in hash chain */ 49} dt_strhash_t; 50 51typedef struct dt_strtab { 52 dt_strhash_t **str_hash; /* array of hash buckets */ 53 ulong_t str_hashsz; /* size of hash bucket array */ 54 char **str_bufs; /* array of buffer pointers */ 55 char *str_ptr; /* pointer to current buffer location */ 56 ulong_t str_nbufs; /* size of buffer pointer array */ 57 size_t str_bufsz; /* size of individual buffer */ 58 ulong_t str_nstrs; /* total number of strings in strtab */ 59 size_t str_size; /* total size of strings in bytes */ 60} dt_strtab_t; 61 62typedef ssize_t dt_strtab_write_f(const char *, size_t, size_t, void *); 63 64extern dt_strtab_t *dt_strtab_create(size_t); 65extern void dt_strtab_destroy(dt_strtab_t *); 66extern ssize_t dt_strtab_index(dt_strtab_t *, const char *); 67extern ssize_t dt_strtab_insert(dt_strtab_t *, const char *); 68extern size_t dt_strtab_size(const dt_strtab_t *); 69extern ssize_t dt_strtab_write(const dt_strtab_t *, 70 dt_strtab_write_f *, void *); 71extern ulong_t dt_strtab_hash(const char *, size_t *); 72 73#ifdef __cplusplus 74} 75#endif 76 77#endif /* _DT_STRTAB_H */ 78