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. */
21 #include <rpcsvc/nis.h>
22 #include <rpcsvc/nislib.h>
23 #include "nis_intern.h"
25 /* Nearly the same as nis_getnames, but nis_getnames stopped
28 __nis_expandname (const char *name
)
30 nis_name
*getnames
= NULL
;
31 char local_domain
[NIS_MAXNAMELEN
+ 1];
35 strncpy (local_domain
, nis_local_directory (), NIS_MAXNAMELEN
);
36 local_domain
[NIS_MAXNAMELEN
] = '\0';
39 if ((getnames
= malloc ((count
+ 1) * sizeof (char *))) == NULL
)
42 /* Do we have a fully qualified NIS+ name ? If yes, give it back */
43 if (name
[strlen (name
) - 1] == '.')
45 if ((getnames
[0] = strdup (name
)) == NULL
)
55 /* Get the search path, where we have to search "name" */
56 path
= getenv ("NIS_PATH");
60 path
= strdupa (path
);
64 cp
= strtok (path
, ":");
67 if (strcmp (cp
, "$") == 0)
69 char *cptr
= local_domain
;
77 getnames
= realloc (getnames
, (count
+ 1) * sizeof (char *));
79 tmp
= malloc (strlen (cptr
) + strlen (local_domain
) +
85 tmp
= stpcpy (tmp
, name
);
93 while ((*cptr
!= '\0') && (*cptr
!= '.'))
96 if ((*cptr
== '.') && (cptr
[1] != '\0'))
104 if (cp
[strlen (cp
) - 1] == '$')
106 tmp
= malloc (strlen (cp
) + strlen (local_domain
) +
112 tmp
= stpcpy (tmp
, name
);
114 tmp
= stpcpy (tmp
, cp
);
118 stpcpy (tmp
, local_domain
);
122 tmp
= malloc (strlen (cp
) + strlen (name
) + 2);
126 tmp
= stpcpy (tmp
, name
);
134 getnames
= realloc (getnames
, (count
+ 1) * sizeof (char *));
139 cp
= strtok (NULL
, ":");
142 getnames
[pos
] = NULL
;
148 __nis_finddirectoy (const_nis_name name
)
154 args
.dir_name
= (char *) name
;
155 args
.requester
= nis_local_principal ();
157 res
= calloc (1, sizeof (fd_result
));
161 if ((status
= __do_niscall (NULL
, 0, NIS_FINDDIRECTORY
,
162 (xdrproc_t
) xdr_fd_args
,
164 (xdrproc_t
) xdr_fd_result
,
165 (caddr_t
) res
, 0)) != RPC_SUCCESS
)
166 res
->status
= status
;