Update.
[glibc.git] / nis / nis_checkpoint.c
blobf4bd07252c87fb7589a327fc6c479858f08931ed
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.
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.
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.
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. */
20 #include <rpcsvc/nis.h>
21 #include "nis_intern.h"
23 nis_result *
24 nis_checkpoint(const_nis_name dirname)
26 nis_result *res;
28 res = calloc (1, sizeof (nis_result));
30 if (dirname != NULL)
32 cp_result *cpres = NULL;
33 nis_result *res2;
34 u_int i;
36 res2 = nis_lookup (dirname, EXPAND_NAME);
37 if (NIS_RES_STATUS (res2) != NIS_SUCCESS)
38 return res2;
40 /* Check if obj is really a diryectory object */
41 if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ)
43 nis_freeresult (res);
44 NIS_RES_STATUS (res) = NIS_INVALIDOBJ;
45 return res;
48 for (i = 0;
49 i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i)
51 if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i],
52 1, NIS_CHECKPOINT, (xdrproc_t) xdr_nis_name,
53 (caddr_t) &dirname, (xdrproc_t) xdr_cp_result,
54 (caddr_t) &cpres, 0, NULL) != RPC_SUCCESS)
55 NIS_RES_STATUS (res) = NIS_RPCERROR;
56 else
58 res->status += cpres->cp_status;
59 res->zticks += cpres->cp_zticks;
60 res->dticks += cpres->cp_dticks;
63 nis_freeresult (res2);
65 else
66 NIS_RES_STATUS (res) = NIS_NOSUCHNAME;
68 return res;