]> git.ipfire.org Git - thirdparty/glibc.git/blob - nis/nis_server.c
Update.
[thirdparty/glibc.git] / nis / nis_server.c
1 /* Copyright (c) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20 #include <rpcsvc/nis.h>
21 #include <rpcsvc/nislib.h>
22 #include "nis_intern.h"
23
24 nis_error
25 nis_mkdir (const_nis_name dir, const nis_server *server)
26 {
27 nis_error res;
28
29 if (server == NULL)
30 {
31 int result;
32 if ((result = __do_niscall (NULL, 0, NIS_MKDIR, (xdrproc_t) xdr_nis_name,
33 (caddr_t) &dir, (xdrproc_t) xdr_nis_error,
34 (caddr_t) &res, 0)) != RPC_SUCCESS)
35 {
36 fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
37 return NIS_RPCERROR;
38 }
39 }
40 else
41 {
42 int result;
43 if ((result = __do_niscall (server, 1, NIS_MKDIR,
44 (xdrproc_t) xdr_nis_name,
45 (caddr_t) &dir, (xdrproc_t) xdr_nis_error,
46 (caddr_t) &res, 0)) != RPC_SUCCESS)
47 {
48 fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
49 return NIS_RPCERROR;
50 }
51 }
52
53 return res;
54 }
55
56 nis_error
57 nis_rmdir (const_nis_name dir, const nis_server *server)
58 {
59 nis_error res;
60
61 if (server == NULL)
62 {
63 int result;
64 if ((result = __do_niscall (NULL, 0, NIS_RMDIR, (xdrproc_t) xdr_nis_name,
65 (caddr_t) &dir, (xdrproc_t) xdr_nis_error,
66 (caddr_t) &res, 0)) != RPC_SUCCESS)
67 {
68 fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
69 return NIS_RPCERROR;
70 }
71 }
72 else
73 {
74 int result;
75 if ((result = __do_niscall (server, 1, NIS_RMDIR,
76 (xdrproc_t) xdr_nis_name,
77 (caddr_t) &dir, (xdrproc_t) xdr_nis_error,
78 (caddr_t) &res, 0)) != RPC_SUCCESS)
79 {
80 fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
81 return NIS_RPCERROR;
82 }
83 }
84
85 return res;
86 }
87
88 nis_error
89 nis_servstate (const nis_server *serv, const nis_tag *tags,
90 const int numtags, nis_tag **result)
91 {
92 *result = NULL;
93 return NIS_FAIL;
94 }
95 stub_warning (nis_servstate)
96
97 nis_error
98 nis_stats (const nis_server *serv, const nis_tag *tags,
99 const int numtags, nis_tag **result)
100 {
101 result = malloc (sizeof (nis_tag *));
102 if (result != NULL)
103 result[0] = NULL;
104 return NIS_FAIL;
105 }
106 stub_warning (nis_stats);
107
108 void
109 nis_freetags (nis_tag *tags, const int numtags)
110 {
111 int i;
112
113 for (i = 0; i < numtags; ++i)
114 free (tags->tag_val);
115 free (tags);
116 }
117
118 nis_server **
119 nis_getservlist (const_nis_name dir)
120 {
121 nis_server **serv;
122
123 serv = malloc (sizeof (nis_server *));
124 if (serv != NULL)
125 serv[0] = NULL;
126
127 return serv;
128 }
129 stub_warning (nis_getservlist);
130
131 void
132 nis_freeservlist (nis_server **serv)
133 {
134 int i;
135
136 if (serv == NULL)
137 return;
138
139 i = 0;
140 while (serv[i] != NULL)
141 nis_free_servers (serv[i], 1);
142 free (serv);
143 }