xref: /titanic_51/usr/src/lib/nsswitch/user/common/user_common.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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  * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Common code and structures used by name-service-switch "user" backends.
27  */
28 
29 #ifndef _USER_COMMON_H
30 #define	_USER_COMMON_H
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 #include "synonyms.h"
35 #include <nss_common.h>
36 #include <nss_dbdefs.h>
37 #include <stdio.h>
38 #include "../../../libnsl/include/nsl_stdio_prv.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 	__NSL_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(__NSL_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