xref: /titanic_50/usr/src/lib/nsswitch/user/common/user_common.h (revision 5bbb4db2c3f208d12bf0fd11769728f9e5ba66a2)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Common code and structures used by name-service-switch "user" backends.
29  */
30 
31 #ifndef _USER_COMMON_H
32 #define	_USER_COMMON_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <nss_common.h>
37 #include <nss_dbdefs.h>
38 #include <stdio.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 typedef struct user_backend *user_backend_ptr_t;
45 typedef nss_status_t	(*user_backend_op_t)(user_backend_ptr_t, void *);
46 
47 
48 
49 struct user_backend {
50 	user_backend_op_t	*ops;
51 	int			n_ops;
52 	const char		*filename;
53 	FILE			*f;
54 	int			minbuf;
55 	char			*buf;
56 };
57 
58 /*
59  * Iterator function for _nss_user_do_all()
60  *   NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now",
61  *   other values don't make much sense.  In other words we're abusing
62  *   (overloading) the meaning of nss_status_t, but hey...
63  * _nss_user_XY_all() is a wrapper around _nss_user_do_all() that does the
64  *   generic work for nss_XbyY_args_t backends (calls cstr2ent etc).
65  */
66 typedef nss_status_t	(*user_do_all_func_t)(const char *, int, void *args);
67 typedef int		(*user_XY_check_func)(nss_XbyY_args_t *);
68 
69 #if defined(__STDC__)
70 extern nss_backend_t	*_nss_user_constr(user_backend_op_t	*ops,
71 					int			n_ops,
72 					const char		*filename,
73 					int			min_bufsize);
74 extern nss_status_t	_nss_user_destr(user_backend_ptr_t, void *dummy);
75 extern nss_status_t	_nss_user_setent(user_backend_ptr_t, void *dummy);
76 extern nss_status_t	_nss_user_endent(user_backend_ptr_t, void *dummy);
77 extern nss_status_t 	_nss_user_do_all(user_backend_ptr_t,
78 					void			*func_priv,
79 					const char		*filter,
80 					user_do_all_func_t	func);
81 extern nss_status_t 	_nss_user_XY_all(user_backend_ptr_t	be,
82 					nss_XbyY_args_t		*args,
83 					int 			netdb,
84 					const char		*filter,
85 					user_XY_check_func	check);
86 extern int		_nss_user_read_line(FILE		*f,
87 					char			*buffer,
88 					int			buflen);
89 #else
90 extern nss_backend_t	*_nss_user_constr();
91 extern nss_status_t	_nss_user_destr();
92 extern nss_status_t	_nss_user_setent();
93 extern nss_status_t	_nss_user_endent();
94 extern nss_status_t	_nss_user_do_all();
95 extern nss_status_t	_nss_user_XY_all();
96 extern int		_nss_user_read_line();
97 #endif
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif /* _USER_COMMON_H */
104