8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / nscd / nscd_db.h
blob9695fdcee68ffb8dd65aea0402cd63c6836027dd
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _NSCD_DB_H
27 #define _NSCD_DB_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #include <nss_dbdefs.h> /* nssuint_t */
36 #include "nscd_common.h"
38 /* make a pointer 8-byte aligned, or an integer a multiple of 8 */
39 #define roundup(x) (((unsigned long)(x)+7) & ~7)
42 * type of nscd data
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
58 * database operation options
60 typedef 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;
74 * This structure defines an instance of the
75 * nscd database entry.
77 typedef 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;
87 * sequence number attached to nscd data
89 typedef nssuint_t nscd_seq_num_t;
90 typedef nssuint_t nscd_cookie_num_t;
93 * The nscd_access_s datatype represents a nscd
94 * access data structure. It is an opaque structure.
96 struct nscd_access_s;
97 typedef struct nscd_access_s nscd_access_t;
98 struct nscd_acc_data_s;
99 typedef struct nscd_acc_data_s nscd_acc_data_t;
102 * The nscd_db_t datatype represents a nscd
103 * database. It is also an opaque structure.
105 struct nscd_db_s;
106 typedef struct nscd_db_s nscd_db_t;
109 * four sizes for a nscd database:
110 * large, medium, small, tiny
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
118 * options for _nscd_alloc()
120 #define NSCD_ALLOC_MUTEX 0x0001
121 #define NSCD_ALLOC_RWLOCK 0x0002
122 #define NSCD_ALLOC_COND 0x0004
125 * prototypes
127 nscd_seq_num_t
128 _nscd_get_seq_num();
130 nscd_cookie_num_t
131 _nscd_get_cookie_num();
133 nscd_acc_data_t *
134 _nscd_get(
135 nscd_acc_data_t *data);
137 nscd_acc_data_t
138 *_nscd_set(
139 nscd_acc_data_t *old,
140 nscd_acc_data_t *new);
142 void
143 _nscd_release(
144 nscd_acc_data_t *data);
146 nscd_acc_data_t
147 *_nscd_rdlock(
148 nscd_acc_data_t *data);
150 nscd_acc_data_t
151 *_nscd_wrlock(
152 nscd_acc_data_t *data);
154 void
155 _nscd_rw_unlock(
156 nscd_acc_data_t *data);
158 void
159 _nscd_rw_unlock_no_release(
160 nscd_acc_data_t *data);
162 nscd_acc_data_t
163 *_nscd_mutex_lock(
164 nscd_acc_data_t *data);
166 void
167 _nscd_mutex_unlock(
168 nscd_acc_data_t *data);
170 void
171 _nscd_cond_signal(
172 nscd_acc_data_t *data);
174 void
175 _nscd_cond_wait(
176 nscd_acc_data_t *data,
177 cond_t *cond);
179 nscd_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);
187 nscd_rc_t
188 _nscd_add_int_addr(
189 void *ptr,
190 int type,
191 nscd_seq_num_t seq_num);
193 rwlock_t *
194 _nscd_is_int_addr(
195 void *ptr,
196 nscd_seq_num_t seq_num);
198 void
199 _nscd_del_int_addr(
200 void *ptr,
201 nscd_seq_num_t seq_num);
203 nscd_db_t *
204 _nscd_alloc_db(
205 int size);
207 void
208 _nscd_free_db(
209 nscd_db_t *db);
211 nscd_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);
219 const 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);
227 nscd_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);
234 nscd_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);
243 void *
244 _nscd_create_int_addrDB();
246 void
247 _nscd_destroy_int_addrDB();
249 #ifdef __cplusplus
251 #endif
253 #endif /* _NSCD_DB_H */