* elf/dl-reloc.c (allocate_static_tls): Rename to...
[glibc.git] / nis / nis_checkpoint.c
blob0146d53054b96bd72c576e4c0592bbfafd097a5b
1 /* Copyright (c) 1997, 1998, 1999 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.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <string.h>
21 #include <rpcsvc/nis.h>
23 #include "nis_xdr.h"
24 #include "nis_intern.h"
26 nis_result *
27 nis_checkpoint(const_nis_name dirname)
29 nis_result *res;
31 res = calloc (1, sizeof (nis_result));
32 if (res == NULL)
33 return NULL;
35 if (dirname != NULL)
37 nis_result *res2;
38 u_int i;
40 res2 = nis_lookup (dirname, EXPAND_NAME);
41 if (NIS_RES_STATUS (res2) != NIS_SUCCESS)
43 free (res);
44 return res2;
47 /* Check if obj is really a diryectory object */
48 if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ)
50 nis_freeresult (res2);
51 nis_freeresult (res);
52 NIS_RES_STATUS (res) = NIS_INVALIDOBJ;
53 return res;
56 for (i = 0;
57 i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i)
59 cp_result cpres;
61 memset (&cpres, '\0', sizeof (cp_result));
62 if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i],
63 1, NIS_CHECKPOINT, (xdrproc_t) _xdr_nis_name,
64 (caddr_t) &dirname, (xdrproc_t) _xdr_cp_result,
65 (caddr_t) &cpres, 0, NULL) != NIS_SUCCESS)
66 NIS_RES_STATUS (res) = NIS_RPCERROR;
67 else
69 NIS_RES_STATUS (res) = cpres.cp_status;
70 res->zticks += cpres.cp_zticks;
71 res->dticks += cpres.cp_dticks;
74 nis_freeresult (res2);
76 else
77 NIS_RES_STATUS (res) = NIS_NOSUCHNAME;
79 return res;