Update.
[glibc.git] / nis / nis_checkpoint.c
blobff0a9b37a799e9629f25f7365db4f181c940954b
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 <rpcsvc/nislib.h>
22 #include "nis_intern.h"
24 nis_result *
25 nis_checkpoint(const_nis_name dirname)
27 nis_result *res;
29 res = calloc (1, sizeof (nis_result));
31 if (dirname != NULL)
33 cp_result *cpres = NULL;
34 nis_result *res2;
35 u_int i;
37 res2 = nis_lookup (dirname, EXPAND_NAME);
38 if (res2->status != NIS_SUCCESS && res2->status != NIS_S_SUCCESS)
39 return res2;
41 /* Check if obj is really a diryectory object */
42 if (res2->objects.objects_val[0].zo_data.zo_type != DIRECTORY_OBJ)
44 nis_freeresult (res);
45 res->status = NIS_INVALIDOBJ;
46 return res;
49 for (i = 0;
50 i < res2->objects.objects_val[0].DI_data.do_servers.do_servers_len;
51 ++i)
53 if (__do_niscall2 (&res2->objects.objects_val[0].DI_data.do_servers.do_servers_val[i],
54 1, NIS_CHECKPOINT, (xdrproc_t) xdr_nis_name,
55 (caddr_t) &dirname, (xdrproc_t) xdr_cp_result,
56 (caddr_t) &cpres, 0) != RPC_SUCCESS)
57 res->status = NIS_RPCERROR;
58 else
60 res->status += cpres->cp_status;
61 res->zticks += cpres->cp_zticks;
62 res->dticks += cpres->cp_dticks;
65 nis_freeresult (res2);
67 else
68 res->status = NIS_NOSUCHNAME;
70 return res;