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 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#ifndef _NSCD_DB_H 27#define _NSCD_DB_H 28 29#pragma ident "%Z%%M% %I% %E% SMI" 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35#include <nss_dbdefs.h> /* nssuint_t */ 36#include "nscd_common.h" 37 38/* make a pointer 8-byte aligned, or an integer a multiple of 8 */ 39#define roundup(x) (((unsigned long)(x)+7) & ~7) 40 41/* 42 * type of nscd data 43 */ 44#define NSCD_DATA_UNKNOWN 0 45#define NSCD_DATA_NSW_CONFIG 1 46#define NSCD_DATA_NSW_STATE_BASE 2 47#define NSCD_DATA_GETENT_CTX_BASE 3 48#define NSCD_DATA_BACKEND_INFO 4 49#define NSCD_DATA_BACKEND_INFO_DB 5 50#define NSCD_DATA_CFG_NSW_DB_INDEX 6 51#define NSCD_DATA_CFG_NSW_SRC_INDEX 7 52#define NSCD_DATA_CFG_PARAM_INDEX 8 53#define NSCD_DATA_CFG_STAT_INDEX 9 54#define NSCD_DATA_ADDR 127 55#define NSCD_DATA_CTX_ADDR 128 56 57/* 58 * database operation options 59 */ 60typedef enum { 61 NSCD_GET_FIRST_DB_ENTRY = 1, 62 NSCD_GET_NEXT_DB_ENTRY = 2, 63 NSCD_GET_EXACT_DB_ENTRY = 3, 64 NSCD_ADD_DB_ENTRY_FIRST = 4, 65 NSCD_ADD_DB_ENTRY_LAST = 5, 66 NSCD_ADD_DB_ENTRY_REPLACE = 6, 67 NSCD_ADD_DB_ENTRY_IF_NONE = 7, 68 NSCD_DEL_FIRST_DB_ENTRY = 8, 69 NSCD_DEL_ALL_DB_ENTRY = 9, 70 NSCD_DEL_EXACT_DB_ENTRY = 10 71} nscd_db_option_t; 72 73/* 74 * This structure defines an instance of the 75 * nscd database entry. 76 */ 77typedef struct nscd_db_entry { 78 int type; 79 int id_num; 80 int num_data; 81 int num_array; 82 char *name; 83 void **data_array; 84} nscd_db_entry_t; 85 86/* 87 * sequence number attached to nscd data 88 */ 89typedef nssuint_t nscd_seq_num_t; 90typedef nssuint_t nscd_cookie_num_t; 91 92/* 93 * The nscd_access_s datatype represents a nscd 94 * access data structure. It is an opaque structure. 95 */ 96struct nscd_access_s; 97typedef struct nscd_access_s nscd_access_t; 98struct nscd_acc_data_s; 99typedef struct nscd_acc_data_s nscd_acc_data_t; 100 101/* 102 * The nscd_db_t datatype represents a nscd 103 * database. It is also an opaque structure. 104 */ 105struct nscd_db_s; 106typedef struct nscd_db_s nscd_db_t; 107 108/* 109 * four sizes for a nscd database: 110 * large, medium, small, tiny 111 */ 112#define NSCD_DB_SIZE_LARGE 1 113#define NSCD_DB_SIZE_MEDIUM 2 114#define NSCD_DB_SIZE_SMALL 3 115#define NSCD_DB_SIZE_TINY 4 116 117/* 118 * options for _nscd_alloc() 119 */ 120#define NSCD_ALLOC_MUTEX 0x0001 121#define NSCD_ALLOC_RWLOCK 0x0002 122#define NSCD_ALLOC_COND 0x0004 123 124/* 125 * prototypes 126 */ 127nscd_seq_num_t 128_nscd_get_seq_num(); 129 130nscd_cookie_num_t 131_nscd_get_cookie_num(); 132 133nscd_acc_data_t * 134_nscd_get( 135 nscd_acc_data_t *data); 136 137nscd_acc_data_t 138*_nscd_set( 139 nscd_acc_data_t *old, 140 nscd_acc_data_t *new); 141 142void 143_nscd_release( 144 nscd_acc_data_t *data); 145 146nscd_acc_data_t 147*_nscd_rdlock( 148 nscd_acc_data_t *data); 149 150nscd_acc_data_t 151*_nscd_wrlock( 152 nscd_acc_data_t *data); 153 154void 155_nscd_rw_unlock( 156 nscd_acc_data_t *data); 157 158void 159_nscd_rw_unlock_no_release( 160 nscd_acc_data_t *data); 161 162nscd_acc_data_t 163*_nscd_mutex_lock( 164 nscd_acc_data_t *data); 165 166void 167_nscd_mutex_unlock( 168 nscd_acc_data_t *data); 169 170void 171_nscd_cond_signal( 172 nscd_acc_data_t *data); 173 174void 175_nscd_cond_wait( 176 nscd_acc_data_t *data, 177 cond_t *cond); 178 179nscd_acc_data_t * 180_nscd_alloc( 181 int type, 182 size_t size, 183 void (*data_free)( 184 nscd_acc_data_t *data), 185 int option); 186 187nscd_rc_t 188_nscd_add_int_addr( 189 void *ptr, 190 int type, 191 nscd_seq_num_t seq_num); 192 193rwlock_t * 194_nscd_is_int_addr( 195 void *ptr, 196 nscd_seq_num_t seq_num); 197 198void 199_nscd_del_int_addr( 200 void *ptr, 201 nscd_seq_num_t seq_num); 202 203nscd_db_t * 204_nscd_alloc_db( 205 int size); 206 207void 208_nscd_free_db( 209 nscd_db_t *db); 210 211nscd_db_entry_t * 212_nscd_alloc_db_entry( 213 int type, 214 const char *name, 215 int dataSize, 216 int num_data, 217 int num_array); 218 219const nscd_db_entry_t * 220_nscd_get_db_entry( 221 const nscd_db_t *db, 222 int type, 223 const char *str, 224 nscd_db_option_t option, 225 int id_num); 226 227nscd_rc_t 228_nscd_add_db_entry( 229 nscd_db_t *db, 230 const char *str, 231 nscd_db_entry_t *entry, 232 nscd_db_option_t option); 233 234nscd_rc_t 235_nscd_delete_db_entry( 236 nscd_db_t *db, 237 int type, 238 const char *str, 239 nscd_db_option_t option, 240 int id_num); 241 242 243void * 244_nscd_create_int_addrDB(); 245 246void 247_nscd_destroy_int_addrDB(); 248 249#ifdef __cplusplus 250} 251#endif 252 253#endif /* _NSCD_DB_H */ 254