xref: /titanic_41/usr/src/lib/nsswitch/user/common/user_common.h (revision d89fccd8788afe1e920f842edd883fe192a1b8fe)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 /*
29  * Common code and structures used by name-service-switch "user" backends.
30  */
31 
32 #ifndef _USER_COMMON_H
33 #define	_USER_COMMON_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include "c_synonyms.h"
38 #include <nss_common.h>
39 #include <nss_dbdefs.h>
40 #include <stdio.h>
41 #include "../../../libnsl/include/nsl_stdio_prv.h"
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 typedef struct user_backend *user_backend_ptr_t;
48 typedef nss_status_t	(*user_backend_op_t)(user_backend_ptr_t, void *);
49 
50 
51 
52 struct user_backend {
53 	user_backend_op_t	*ops;
54 	int			n_ops;
55 	const char		*filename;
56 	__NSL_FILE		*f;
57 	int			minbuf;
58 	char			*buf;
59 };
60 
61 /*
62  * Iterator function for _nss_user_do_all()
63  *   NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now",
64  *   other values don't make much sense.  In other words we're abusing
65  *   (overloading) the meaning of nss_status_t, but hey...
66  * _nss_user_XY_all() is a wrapper around _nss_user_do_all() that does the
67  *   generic work for nss_XbyY_args_t backends (calls cstr2ent etc).
68  */
69 typedef nss_status_t	(*user_do_all_func_t)(const char *, int, void *args);
70 typedef int		(*user_XY_check_func)(nss_XbyY_args_t *);
71 
72 #if defined(__STDC__)
73 extern nss_backend_t	*_nss_user_constr(user_backend_op_t	*ops,
74 					int			n_ops,
75 					const char		*filename,
76 					int			min_bufsize);
77 extern nss_status_t	_nss_user_destr (user_backend_ptr_t, void *dummy);
78 extern nss_status_t	_nss_user_setent(user_backend_ptr_t, void *dummy);
79 extern nss_status_t	_nss_user_endent(user_backend_ptr_t, void *dummy);
80 extern nss_status_t 	_nss_user_do_all(user_backend_ptr_t,
81 					void			*func_priv,
82 					const char		*filter,
83 					user_do_all_func_t	func);
84 extern nss_status_t 	_nss_user_XY_all(user_backend_ptr_t	be,
85 					nss_XbyY_args_t		*args,
86 					int 			netdb,
87 					const char		*filter,
88 					user_XY_check_func	check);
89 extern int		_nss_user_read_line(__NSL_FILE		*f,
90 					char			*buffer,
91 					int			buflen);
92 #else
93 extern nss_backend_t	*_nss_user_constr();
94 extern nss_status_t	_nss_user_destr ();
95 extern nss_status_t	_nss_user_setent();
96 extern nss_status_t	_nss_user_endent();
97 extern nss_status_t	_nss_user_do_all();
98 extern nss_status_t	_nss_user_XY_all();
99 extern int		_nss_user_read_line();
100 #endif
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif /* _USER_COMMON_H */
107