1 /* Copyright (c) 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
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. */
22 #include <rpcsvc/nis.h>
25 #include "nis_intern.h"
26 #include "nis_cache2.h"
28 static struct timeval TIMEOUT
= { 25, 0 };
31 __nis_cache_search (const_nis_name name
, u_long flags
, cache2_info
*cinfo
)
35 struct sockaddr_in clnt_saddr
;
36 directory_obj
*obj
= NULL
;
40 cinfo
->server_used
= -1;
41 cinfo
->current_ep
= -1;
44 memset (&clnt_saddr
, '\0', sizeof clnt_saddr
);
45 clnt_saddr
.sin_family
= AF_INET
;
46 clnt_saddr
.sin_addr
.s_addr
= htonl (INADDR_LOOPBACK
);
47 clnt_sock
= RPC_ANYSOCK
;
48 clnt
= clnttcp_create (&clnt_saddr
, CACHEPROG
, CACHE_VER_1
,
53 memset (&fsres
, 0, sizeof (fsres
));
54 if (flags
& MASTER_ONLY
)
56 if (clnt_call (clnt
, NIS_CACHE_FIND_MASTER
, (xdrproc_t
) xdr_wrapstring
,
57 (caddr_t
) &name
, (xdrproc_t
) xdr_fs_result
,
58 (caddr_t
) &fsres
, TIMEOUT
) != RPC_SUCCESS
)
67 if (clnt_call (clnt
, NIS_CACHE_FIND_SERVER
, (xdrproc_t
) xdr_wrapstring
,
68 (caddr_t
) &name
, (xdrproc_t
) xdr_fs_result
,
69 (caddr_t
) &fsres
, TIMEOUT
) != RPC_SUCCESS
)
80 if (fsres
.status
!= NIS_SUCCESS
)
83 obj
= calloc (1, sizeof (directory_obj
));
87 xdrmem_create (&xdrs
, fsres
.dir_data
.dir_data_val
,
88 fsres
.dir_data
.dir_data_len
, XDR_DECODE
);
89 _xdr_directory_obj (&xdrs
, obj
);
92 cinfo
->server_used
= fsres
.server_used
;
93 cinfo
->current_ep
= fsres
.current_ep
;
94 cinfo
->class = fsres
.class;