]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind/lib/irs/nis.c
This commit was generated by cvs2svn to compensate for changes in r52894,
[FreeBSD/FreeBSD.git] / contrib / bind / lib / irs / nis.c
1 /*
2  * Copyright (c) 1996, 1998 by Internet Software Consortium.
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
9  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
10  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
11  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
13  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
15  * SOFTWARE.
16  */
17
18 #if defined(LIBC_SCCS) && !defined(lint)
19 static const char rcsid[] = "$Id: nis.c,v 1.10 1998/03/21 00:59:50 halley Exp $";
20 #endif
21
22 /* Imports */
23
24 #include "port_before.h"
25
26 #ifdef WANT_IRS_NIS
27
28 #include <rpc/rpc.h>
29 #include <rpc/xdr.h>
30 #include <rpcsvc/yp_prot.h>
31 #include <rpcsvc/ypclnt.h>
32
33 #include <stdlib.h>
34 #include <string.h>
35 #include <errno.h>
36
37 #include <irs.h>
38
39 #include "port_after.h"
40
41 #include "irs_p.h"
42 #include "hesiod.h"
43 #include "nis_p.h"
44
45 /* Forward */
46
47 static void             nis_close(struct irs_acc *);
48
49 /* Public */
50
51 struct irs_acc *
52 irs_nis_acc(const char *options) {
53         struct nis_p *nis;
54         struct irs_acc *acc;
55         char *domain;
56
57         if (yp_get_default_domain(&domain) != 0)
58                 return (NULL);
59         if (!(nis = malloc(sizeof *nis))) {
60                 errno = ENOMEM;
61                 return (NULL);
62         }
63         memset(nis, 0, sizeof *nis);
64         if (!(acc = malloc(sizeof *acc))) {
65                 free(nis);
66                 errno = ENOMEM;
67                 return (NULL);
68         }
69         memset(acc, 0x5e, sizeof *acc);
70         acc->private = nis;
71         nis->domain = strdup(domain);
72 #ifdef WANT_IRS_GR
73         acc->gr_map = irs_nis_gr;
74 #else
75         acc->gr_map = NULL;
76 #endif
77 #ifdef WANT_IRS_PW
78         acc->pw_map = irs_nis_pw;
79 #else
80         acc->pw_map = NULL;
81 #endif
82         acc->sv_map = irs_nis_sv;
83         acc->pr_map = irs_nis_pr;
84         acc->ho_map = irs_nis_ho;
85         acc->nw_map = irs_nis_nw;
86         acc->ng_map = irs_nis_ng;
87         acc->close = nis_close;
88         return (acc);
89 }
90
91 /* Methods */
92
93 static void
94 nis_close(struct irs_acc *this) {
95         struct nis_p *nis = (struct nis_p *)this->private;
96
97         free(nis->domain);
98         free(nis);
99         free(this);
100 }
101
102 #endif /*WANT_IRS_NIS*/