xref: /titanic_52/usr/src/lib/nsswitch/nis/common/getprojent.c (revision 10db1377dafab8ba3feedef26db9c5d8539a5cd1)
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 (c) 1999-2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <stdio.h>
30 #include <project.h>
31 #include "nis_common.h"
32 #include <string.h>
33 
34 static nss_status_t
35 getbyname(nis_backend_ptr_t be, void *a) {
36 	nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
37 	return (_nss_nis_lookup(be, argp, 0, "project.byname",
38 	    argp->key.name, 0));
39 }
40 
41 static nss_status_t
42 getbyid(nis_backend_ptr_t be, void *a) {
43 	char projstr[PROJNAME_MAX];
44 	nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
45 	(void) sprintf(projstr, "%d", argp->key.projid);
46 	return (_nss_nis_lookup(be, argp, 0, "project.byprojid", projstr, 0));
47 }
48 
49 static nis_backend_op_t project_ops[] = {
50 	_nss_nis_destr,
51 	_nss_nis_endent,
52 	_nss_nis_setent,
53 	_nss_nis_getent_rigid,
54 	getbyname,
55 	getbyid
56 };
57 
58 /*ARGSUSED*/
59 nss_backend_t *
60 _nss_nis_project_constr(dummy1, dummy2, dummy3)
61 	const char	*dummy1, *dummy2, *dummy3;
62 {
63 	return (_nss_nis_constr(project_ops,
64 	    sizeof (project_ops) / sizeof (project_ops[0]),
65 	    "project.byname"));
66 }
67