]>
Commit | Line | Data |
---|---|---|
843ede44 | 1 | /* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc. |
51702635 UD |
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 | ||
ba9234d9 | 20 | #include <string.h> |
51702635 | 21 | #include <rpcsvc/nis.h> |
91eee4dd UD |
22 | |
23 | #include "nis_xdr.h" | |
51702635 UD |
24 | #include "nis_intern.h" |
25 | ||
26 | nis_result * | |
27 | nis_checkpoint(const_nis_name dirname) | |
28 | { | |
29 | nis_result *res; | |
30 | ||
31 | res = calloc (1, sizeof (nis_result)); | |
91eee4dd UD |
32 | if (res == NULL) |
33 | return NULL; | |
51702635 UD |
34 | |
35 | if (dirname != NULL) | |
36 | { | |
51702635 UD |
37 | nis_result *res2; |
38 | u_int i; | |
39 | ||
40 | res2 = nis_lookup (dirname, EXPAND_NAME); | |
dfd2257a | 41 | if (NIS_RES_STATUS (res2) != NIS_SUCCESS) |
843ede44 UD |
42 | { |
43 | free (res); | |
44 | return res2; | |
45 | } | |
51702635 UD |
46 | |
47 | /* Check if obj is really a diryectory object */ | |
dfd2257a | 48 | if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ) |
51702635 | 49 | { |
843ede44 | 50 | nis_freeresult (res2); |
51702635 | 51 | nis_freeresult (res); |
dfd2257a | 52 | NIS_RES_STATUS (res) = NIS_INVALIDOBJ; |
51702635 UD |
53 | return res; |
54 | } | |
55 | ||
56 | for (i = 0; | |
dfd2257a | 57 | i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i) |
51702635 | 58 | { |
91eee4dd UD |
59 | cp_result cpres; |
60 | ||
61 | memset (&cpres, '\0', sizeof (cp_result)); | |
dfd2257a | 62 | if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i], |
91eee4dd UD |
63 | 1, NIS_CHECKPOINT, (xdrproc_t) _xdr_nis_name, |
64 | (caddr_t) &dirname, (xdrproc_t) _xdr_cp_result, | |
e852e889 | 65 | (caddr_t) &cpres, 0, NULL) != NIS_SUCCESS) |
dfd2257a | 66 | NIS_RES_STATUS (res) = NIS_RPCERROR; |
51702635 UD |
67 | else |
68 | { | |
91eee4dd UD |
69 | NIS_RES_STATUS (res) = cpres.cp_status; |
70 | res->zticks += cpres.cp_zticks; | |
71 | res->dticks += cpres.cp_dticks; | |
51702635 UD |
72 | } |
73 | } | |
74 | nis_freeresult (res2); | |
75 | } | |
76 | else | |
dfd2257a | 77 | NIS_RES_STATUS (res) = NIS_NOSUCHNAME; |
51702635 UD |
78 | |
79 | return res; | |
80 | } |