Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen Use the common __nsdefaultFOO rather than priva...
details: https://anonhg.NetBSD.org/src/rev/b86312f3b80c
branches: trunk
changeset: 571057:b86312f3b80c
user: lukem <lukem%NetBSD.org@localhost>
date: Wed Nov 10 12:57:32 2004 +0000
description:
Use the common __nsdefaultFOO rather than private defaultFOO duplicates.
diffstat:
lib/libc/gen/getgrent.c | 59 +++++++++++++++++-------------------------------
lib/libc/gen/getpwent.c | 50 ++++++++++++-----------------------------
2 files changed, 36 insertions(+), 73 deletions(-)
diffs (truncated from 335 to 300 lines):
diff -r 4fa17d5dcd6b -r b86312f3b80c lib/libc/gen/getgrent.c
--- a/lib/libc/gen/getgrent.c Wed Nov 10 12:21:32 2004 +0000
+++ b/lib/libc/gen/getgrent.c Wed Nov 10 12:57:32 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getgrent.c,v 1.52 2004/11/10 06:10:03 lukem Exp $ */
+/* $NetBSD: getgrent.c,v 1.53 2004/11/10 12:57:32 lukem Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
#if 0
static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94";
#else
-__RCSID("$NetBSD: getgrent.c,v 1.52 2004/11/10 06:10:03 lukem Exp $");
+__RCSID("$NetBSD: getgrent.c,v 1.53 2004/11/10 12:57:32 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -142,27 +142,6 @@
static mutex_t _grmutex = MUTEX_INITIALIZER;
#endif
-static const ns_src defaultcompat[] = {
- { NSSRC_COMPAT, NS_SUCCESS },
- { 0 }
-};
-
-static const ns_src defaultcompat_forceall[] = {
- { NSSRC_COMPAT, NS_SUCCESS | NS_FORCEALL },
- { 0 }
-};
-
-static const ns_src defaultnis[] = {
- { NSSRC_NIS, NS_SUCCESS },
- { 0 }
-};
-
-static const ns_src defaultnis_forceall[] = {
- { NSSRC_NIS, NS_SUCCESS | NS_FORCEALL },
- { 0 }
-};
-
-
/*
* _gr_memfrombuf
* Obtain want bytes from buffer (of size buflen) and return a pointer
@@ -1384,7 +1363,8 @@
if (state->name[0]) { /* specific +group: */
crv = nsdispatch(NULL, compatnamdtab,
- NSDB_GROUP_COMPAT, "getgrnam_r", defaultnis,
+ NSDB_GROUP_COMPAT, "getgrnam_r",
+ __nsdefaultnis,
&cretval, state->name,
&cgrp, filebuf, sizeof(filebuf), &cgrpres);
free(state->name); /* (only check 1 grp) */
@@ -1392,16 +1372,19 @@
} else if (!search) { /* any group */
/* XXXLUKEM: need to implement and use getgrent_r() */
crv = nsdispatch(NULL, compatentdtab,
- NSDB_GROUP_COMPAT, "getgrent", defaultnis,
+ NSDB_GROUP_COMPAT, "getgrent",
+ __nsdefaultnis,
&cgrpres);
} else if (name) { /* specific group */
crv = nsdispatch(NULL, compatnamdtab,
- NSDB_GROUP_COMPAT, "getgrnam_r", defaultnis,
+ NSDB_GROUP_COMPAT, "getgrnam_r",
+ __nsdefaultnis,
&cretval, name,
&cgrp, filebuf, sizeof(filebuf), &cgrpres);
} else { /* specific gid */
crv = nsdispatch(NULL, compatgiddtab,
- NSDB_GROUP_COMPAT, "getgrgid_r", defaultnis,
+ NSDB_GROUP_COMPAT, "getgrgid_r",
+ __nsdefaultnis,
&cretval, gid,
&cgrp, filebuf, sizeof(filebuf), &cgrpres);
}
@@ -1496,7 +1479,7 @@
/* force group_compat setgrent() */
(void) nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
- defaultnis_forceall);
+ __nsdefaultnis_forceall);
/* reset state, keep fp open */
_compat_state.stayopen = 0;
@@ -1522,7 +1505,7 @@
/* force group_compat setgroupent() */
(void) nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgroupent",
- defaultnis_forceall, &rv, stayopen);
+ __nsdefaultnis_forceall, &rv, stayopen);
_compat_state.stayopen = stayopen;
rv = _compat_start(&_compat_state);
@@ -1544,7 +1527,7 @@
/* force group_compat endgrent() */
(void) nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "endgrent",
- defaultnis_forceall);
+ __nsdefaultnis_forceall);
/* reset state, close fp */
_compat_state.stayopen = 0;
@@ -1698,7 +1681,7 @@
};
mutex_lock(&_grmutex);
- rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent", __nsdefaultcompat,
&retval);
mutex_unlock(&_grmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
@@ -1719,7 +1702,7 @@
};
mutex_lock(&_grmutex);
- rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid", __nsdefaultcompat,
&retval, gid);
mutex_unlock(&_grmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
@@ -1746,7 +1729,7 @@
*result = NULL;
retval = 0;
mutex_lock(&_grmutex);
- rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", __nsdefaultcompat,
&retval, gid, grp, buffer, buflen, result);
mutex_unlock(&_grmutex);
return (rv == NS_SUCCESS) ? 0 : retval ? retval : ENOENT;
@@ -1767,7 +1750,7 @@
};
mutex_lock(&_grmutex);
- rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam", __nsdefaultcompat,
&retval, name);
mutex_unlock(&_grmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
@@ -1795,7 +1778,7 @@
*result = NULL;
retval = 0;
mutex_lock(&_grmutex);
- rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam_r", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam_r", __nsdefaultcompat,
&retval, name, grp, buffer, buflen, result);
mutex_unlock(&_grmutex);
return (rv == NS_SUCCESS) ? 0 : retval ? retval : ENOENT;
@@ -1815,7 +1798,7 @@
mutex_lock(&_grmutex);
/* force all endgrent() methods */
(void) nsdispatch(NULL, dtab, NSDB_GROUP, "endgrent",
- defaultcompat_forceall);
+ __nsdefaultcompat_forceall);
mutex_unlock(&_grmutex);
}
@@ -1834,7 +1817,7 @@
mutex_lock(&_grmutex);
/* force all setgroupent() methods */
rv = nsdispatch(NULL, dtab, NSDB_GROUP, "setgroupent",
- defaultcompat_forceall, &retval, stayopen);
+ __nsdefaultcompat_forceall, &retval, stayopen);
mutex_unlock(&_grmutex);
return (rv == NS_SUCCESS) ? retval : 0;
}
@@ -1853,6 +1836,6 @@
mutex_lock(&_grmutex);
/* force all setgrent() methods */
(void) nsdispatch(NULL, dtab, NSDB_GROUP, "setgrent",
- defaultcompat_forceall);
+ __nsdefaultcompat_forceall);
mutex_unlock(&_grmutex);
}
diff -r 4fa17d5dcd6b -r b86312f3b80c lib/libc/gen/getpwent.c
--- a/lib/libc/gen/getpwent.c Wed Nov 10 12:21:32 2004 +0000
+++ b/lib/libc/gen/getpwent.c Wed Nov 10 12:57:32 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getpwent.c,v 1.64 2004/11/10 04:11:34 lukem Exp $ */
+/* $NetBSD: getpwent.c,v 1.65 2004/11/10 12:57:32 lukem Exp $ */
/*-
* Copyright (c) 1997-2000, 2004 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
#if 0
static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: getpwent.c,v 1.64 2004/11/10 04:11:34 lukem Exp $");
+__RCSID("$NetBSD: getpwent.c,v 1.65 2004/11/10 12:57:32 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -151,26 +151,6 @@
const char __yp_token[] = "__YP!"; /* Let pwd_mkdb pull this in. */
-static const ns_src defaultcompat[] = {
- { NSSRC_COMPAT, NS_SUCCESS },
- { 0 }
-};
-
-static const ns_src defaultcompat_forceall[] = {
- { NSSRC_COMPAT, NS_SUCCESS | NS_FORCEALL },
- { 0 }
-};
-
-static const ns_src defaultnis[] = {
- { NSSRC_NIS, NS_SUCCESS },
- { 0 }
-};
-
-static const ns_src defaultnis_forceall[] = {
- { NSSRC_NIS, NS_SUCCESS | NS_FORCEALL },
- { 0 }
-};
-
/*
* The pwd.db lookup techniques and data extraction code here must be kept
@@ -1638,7 +1618,7 @@
int rv, result;
rv = nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "setpassent",
- defaultnis_forceall, &result, stayopen);
+ __nsdefaultnis_forceall, &result, stayopen);
return rv;
}
@@ -1658,7 +1638,7 @@
};
return nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "endpwent",
- defaultnis_forceall);
+ __nsdefaultnis_forceall);
}
/*
@@ -1701,7 +1681,7 @@
case _PW_KEYBYNUM:
/* XXXREENTRANT: implement & use getpwent_r */
rv = nsdispatch(NULL, compatentdtab,
- NSDB_PASSWD_COMPAT, "getpwent", defaultnis,
+ NSDB_PASSWD_COMPAT, "getpwent", __nsdefaultnis,
&cpw);
if (rv == NS_SUCCESS &&
! _pw_copy(cpw, pw, buffer, buflen, NULL, 0)) {
@@ -1712,12 +1692,12 @@
case _PW_KEYBYNAME:
_DIAGASSERT(name != NULL);
rv = nsdispatch(NULL, compatnamdtab,
- NSDB_PASSWD_COMPAT, "getpwnam_r", defaultnis,
+ NSDB_PASSWD_COMPAT, "getpwnam_r", __nsdefaultnis,
&crv, name, pw, buffer, buflen, &cpw);
break;
case _PW_KEYBYUID:
rv = nsdispatch(NULL, compatuiddtab,
- NSDB_PASSWD_COMPAT, "getpwuid_r", defaultnis,
+ NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis,
&crv, uid, pw, buffer, buflen, &cpw);
break;
default:
@@ -2164,7 +2144,7 @@
};
mutex_lock(&_pwmutex);
- r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwent", defaultcompat,
+ r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwent", __nsdefaultcompat,
&retval);
mutex_unlock(&_pwmutex);
return (r == NS_SUCCESS) ? retval : NULL;
@@ -2185,7 +2165,7 @@
};
mutex_lock(&_pwmutex);
- rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam", __nsdefaultcompat,
&retval, name);
mutex_unlock(&_pwmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
@@ -2213,7 +2193,7 @@
*result = NULL;
retval = 0;
mutex_lock(&_pwmutex);
- r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam_r", defaultcompat,
+ r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam_r", __nsdefaultcompat,
&retval, name, pwd, buffer, buflen, result);
mutex_unlock(&_pwmutex);
return (r == NS_SUCCESS) ? 0 : retval ? retval : ENOENT;
@@ -2234,7 +2214,7 @@
};
mutex_lock(&_pwmutex);
- rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", defaultcompat,
+ rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat,
&retval, uid);
mutex_unlock(&_pwmutex);
return (rv == NS_SUCCESS) ? retval : NULL;
Home |
Main Index |
Thread Index |
Old Index