2003-01-18 Ulrich Drepper <drepper@redhat.com>
+ * nis/nss_nis/nis-hosts.c: Make _nss_nis_endhostent an alias of
+ _nss_nis_sethostent. Work around the different prototypes.
+ * nis/nss_nis/nis-grp.c: Make _nss_nis_endgrent an alias of
+ _nss_nis_setgrent. Work around the different prototypes.
+ * nis/nss_nis/nis-ethers.c (internal_nis_endetherent): New
+ function. Split out from _nss_nis_endetherent.
+ (internal_nis_setetherent): Use internal_nis_endetherent instead of
+ duplicating the code.
+ * nis/nss_nis/nis-alias.c: Make _nss_nss_nis_endaliasent an alias
+ of _nss_nis_setaliasent.
+ * nis/nss_nis/nis-service.c (internal_nis_setservent): Reuse
+ internal_nis_endservent code, don't duplicate it.
+
* inet/rexec.c (rexec_af): Protect socket operations with
TEMP_FAILURE_RETRY. Use writev instead of multiple write.
* inet/rcmd.c (rcmd_af): Likewise.
-/* Copyright (C) 1996,1997,1998,1999,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
return NSS_STATUS_SUCCESS;
}
-
-enum nss_status
-_nss_nis_endaliasent (void)
-{
- __libc_lock_lock (lock);
-
- new_start = 1;
- if (oldkey != NULL)
- {
- free (oldkey);
- oldkey = NULL;
- oldkeylen = 0;
- }
-
- __libc_lock_unlock (lock);
-
- return NSS_STATUS_SUCCESS;
-}
+/* The 'endaliasent' function is identical. */
+strong_alias (_nss_nis_setaliasent, _nss_nis_endaliasent)
static enum nss_status
internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
-/* Copyright (C) 1996-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
return 0;
}
-static enum nss_status
-internal_nis_setetherent (void)
+static void
+internal_nis_endetherent (void)
{
- char *domainname;
- struct ypall_callback ypcb;
- enum nss_status status;
-
- yp_get_default_domain (&domainname);
-
while (start != NULL)
{
if (start->val != NULL)
start = start->next;
free (next);
}
- start = NULL;
+}
+
+enum nss_status
+_nss_nis_endetherent (void)
+{
+ __libc_lock_lock (lock);
+
+ internal_nis_endetherent ();
+ next = NULL;
+
+ __libc_lock_unlock (lock);
+
+ return NSS_STATUS_SUCCESS;
+}
+
+static enum nss_status
+internal_nis_setetherent (void)
+{
+ char *domainname;
+ struct ypall_callback ypcb;
+ enum nss_status status;
+
+ yp_get_default_domain (&domainname);
+
+ internal_nis_endetherent ();
ypcb.foreach = saveit;
ypcb.data = NULL;
return result;
}
-enum nss_status
-_nss_nis_endetherent (void)
-{
- __libc_lock_lock (lock);
-
- while (start != NULL)
- {
- if (start->val != NULL)
- free (start->val);
- next = start;
- start = start->next;
- free (next);
- }
- start = NULL;
- next = NULL;
-
- __libc_lock_unlock (lock);
-
- return NSS_STATUS_SUCCESS;
-}
-
static enum nss_status
internal_nis_getetherent_r (struct etherent *eth, char *buffer, size_t buflen,
int *errnop)
-/* Copyright (C) 1996,1997,1998,1999,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
02111-1307 USA. */
#include <nss.h>
+/* The following is an ugly trick to avoid a prototype declaration for
+ _nss_nis_endgrent. */
+#define _nss_nis_endgrent _nss_nis_endgrent_XXX
#include <grp.h>
+#undef _nss_nis_endgrent
#include <ctype.h>
#include <errno.h>
#include <string.h>
return NSS_STATUS_SUCCESS;
}
-
-enum nss_status
-_nss_nis_endgrent (void)
-{
- __libc_lock_lock (lock);
-
- new_start = 1;
- if (oldkey != NULL)
- {
- free (oldkey);
- oldkey = NULL;
- oldkeylen = 0;
- }
-
- __libc_lock_unlock (lock);
-
- return NSS_STATUS_SUCCESS;
-}
+/* Make _nss_nis_endgrent an alias of _nss_nis_setgrent. We do this
+ even though the prototypes don't match. The argument of setgrent
+ is used so this makes no difference. */
+strong_alias (_nss_nis_setgrent, _nss_nis_endgrent)
static enum nss_status
internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen,
-/* Copyright (C) 1996,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
#include <nss.h>
#include <ctype.h>
+/* The following is an ugly trick to avoid a prototype declaration for
+ _nss_nis_endgrent. */
+#define _nss_nis_endhostent _nss_nis_endhostent_XXX
#include <netdb.h>
+#undef _nss_nis_endhostent
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
return NSS_STATUS_SUCCESS;
}
-
-enum nss_status
-_nss_nis_endhostent (void)
-{
- __libc_lock_lock (lock);
-
- new_start = 1;
- if (oldkey != NULL)
- {
- free (oldkey);
- oldkey = NULL;
- oldkeylen = 0;
- }
-
- __libc_lock_unlock (lock);
-
- return NSS_STATUS_SUCCESS;
-}
+/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent. We do this
+ even though the prototypes don't match. The argument of sethostent
+ is used so this makes no difference. */
+strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
/* The calling function always need to get a lock first. */
static enum nss_status
-/* Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
}
static enum nss_status
-internal_nis_setservent (intern_t *intern)
+internal_nis_endservent (intern_t * intern)
{
- char *domainname;
- struct ypall_callback ypcb;
- enum nss_status status;
-
- if (yp_get_default_domain (&domainname))
- return NSS_STATUS_UNAVAIL;
-
while (intern->start != NULL)
{
if (intern->start->val != NULL)
}
intern->start = NULL;
- ypcb.foreach = saveit;
- ypcb.data = (char *) intern;
- status = yperr2nss (yp_all (domainname, "services.byname", &ypcb));
- intern->next = intern->start;
-
- return status;
+ return NSS_STATUS_SUCCESS;
}
+
enum nss_status
-_nss_nis_setservent (int stayopen)
+_nss_nis_endservent (void)
{
enum nss_status status;
__libc_lock_lock (lock);
- status = internal_nis_setservent (&intern);
+ status = internal_nis_endservent (&intern);
__libc_lock_unlock (lock);
}
static enum nss_status
-internal_nis_endservent (intern_t * intern)
+internal_nis_setservent (intern_t *intern)
{
- while (intern->start != NULL)
- {
- if (intern->start->val != NULL)
- free (intern->start->val);
- intern->next = intern->start;
- intern->start = intern->start->next;
- free (intern->next);
- }
- intern->start = NULL;
+ char *domainname;
+ struct ypall_callback ypcb;
+ enum nss_status status;
- return NSS_STATUS_SUCCESS;
-}
+ if (yp_get_default_domain (&domainname))
+ return NSS_STATUS_UNAVAIL;
+ (void) internal_nis_endservent (intern);
+
+ ypcb.foreach = saveit;
+ ypcb.data = (char *) intern;
+ status = yperr2nss (yp_all (domainname, "services.byname", &ypcb));
+ intern->next = intern->start;
+
+ return status;
+}
enum nss_status
-_nss_nis_endservent (void)
+_nss_nis_setservent (int stayopen)
{
enum nss_status status;
__libc_lock_lock (lock);
- status = internal_nis_endservent (&intern);
+ status = internal_nis_setservent (&intern);
__libc_lock_unlock (lock);