xref: /titanic_41/usr/src/lib/nsswitch/user/common/user_common.h (revision 2a9459bdd821c1cf59590a7a9069ac9c591e8a6b)
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 /*
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 "c_synonyms.h"
37 #include <nss_common.h>
38 #include <nss_dbdefs.h>
39 #include <stdio.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 typedef struct user_backend *user_backend_ptr_t;
46 typedef nss_status_t	(*user_backend_op_t)(user_backend_ptr_t, void *);
47 
48 
49 
50 struct user_backend {
51 	user_backend_op_t	*ops;
52 	int			n_ops;
53 	const char		*filename;
54 	FILE			*f;
55 	int			minbuf;
56 	char			*buf;
57 };
58 
59 /*
60  * Iterator function for _nss_user_do_all()
61  *   NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now",
62  *   other values don't make much sense.  In other words we're abusing
63  *   (overloading) the meaning of nss_status_t, but hey...
64  * _nss_user_XY_all() is a wrapper around _nss_user_do_all() that does the
65  *   generic work for nss_XbyY_args_t backends (calls cstr2ent etc).
66  */
67 typedef nss_status_t	(*user_do_all_func_t)(const char *, int, void *args);
68 typedef int		(*user_XY_check_func)(nss_XbyY_args_t *);
69 
70 #if defined(__STDC__)
71 extern nss_backend_t	*_nss_user_constr(user_backend_op_t	*ops,
72 					int			n_ops,
73 					const char		*filename,
74 					int			min_bufsize);
75 extern nss_status_t	_nss_user_destr(user_backend_ptr_t, void *dummy);
76 extern nss_status_t	_nss_user_setent(user_backend_ptr_t, void *dummy);
77 extern nss_status_t	_nss_user_endent(user_backend_ptr_t, void *dummy);
78 extern nss_status_t 	_nss_user_do_all(user_backend_ptr_t,
79 					void			*func_priv,
80 					const char		*filter,
81 					user_do_all_func_t	func);
82 extern nss_status_t 	_nss_user_XY_all(user_backend_ptr_t	be,
83 					nss_XbyY_args_t		*args,
84 					int 			netdb,
85 					const char		*filter,
86 					user_XY_check_func	check);
87 extern int		_nss_user_read_line(FILE		*f,
88 					char			*buffer,
89 					int			buflen);
90 #else
91 extern nss_backend_t	*_nss_user_constr();
92 extern nss_status_t	_nss_user_destr();
93 extern nss_status_t	_nss_user_setent();
94 extern nss_status_t	_nss_user_endent();
95 extern nss_status_t	_nss_user_do_all();
96 extern nss_status_t	_nss_user_XY_all();
97 extern int		_nss_user_read_line();
98 #endif
99 
100 #ifdef	__cplusplus
101 }
102 #endif
103 
104 #endif /* _USER_COMMON_H */
105