| version 1.40, 2004/04/23 14:47:52 |
version 1.41, 2004/04/25 06:45:29 |
| Line 45 __RCSID("$NetBSD$"); |
|
| Line 45 __RCSID("$NetBSD$"); |
|
| #endif |
#endif |
| #endif /* LIBC_SCCS and not lint */ |
#endif /* LIBC_SCCS and not lint */ |
| |
|
| |
#ifndef SMALL |
| #include "namespace.h" |
#include "namespace.h" |
| |
#endif |
| #include <sys/types.h> |
#include <sys/types.h> |
| #include <sys/param.h> |
#include <sys/param.h> |
| |
|
| #include <assert.h> |
#include <assert.h> |
| #include <ctype.h> |
#include <ctype.h> |
| |
#ifndef SMALL |
| #include <db.h> |
#include <db.h> |
| |
#endif |
| #include <errno.h> |
#include <errno.h> |
| #include <fcntl.h> |
#include <fcntl.h> |
| #include <limits.h> |
#include <limits.h> |
| Line 87 static size_t topreclen; /* toprec leng |
|
| Line 91 static size_t topreclen; /* toprec leng |
|
| static char *toprec; /* Additional record specified by cgetset() */ |
static char *toprec; /* Additional record specified by cgetset() */ |
| static int gottoprec; /* Flag indicating retrieval of toprecord */ |
static int gottoprec; /* Flag indicating retrieval of toprecord */ |
| |
|
| |
#ifndef SMALL |
| static int cdbget(DB *, char **, const char *); |
static int cdbget(DB *, char **, const char *); |
| |
#endif |
| static int getent(char **, size_t *, const char * const *, int, |
static int getent(char **, size_t *, const char * const *, int, |
| const char *, int, char *); |
const char *, int, char *); |
| static int nfcmp(char *, char *); |
static int nfcmp(char *, char *); |
|
|
| getent(char **cap, size_t *len, const char * const *db_array, int fd, |
getent(char **cap, size_t *len, const char * const *db_array, int fd, |
| const char *name, int depth, char *nfield) |
const char *name, int depth, char *nfield) |
| { |
{ |
| |
#ifndef SMALL |
| DB *capdbp; |
DB *capdbp; |
| |
char pbuf[MAXPATHLEN]; |
| |
char *cbuf; |
| |
int retval; |
| |
size_t clen; |
| |
#endif |
| |
char *record, *newrecord; |
| char *r_end, *rp = NULL; /* pacify gcc */ |
char *r_end, *rp = NULL; /* pacify gcc */ |
| const char * const *db_p; |
const char * const *db_p; |
| int myfd = 0, eof, foundit, retval; |
int myfd = 0, eof, foundit; |
| size_t clen; |
|
| char *record, *cbuf, *newrecord; |
|
| int tc_not_resolved; |
int tc_not_resolved; |
| char pbuf[MAXPATHLEN]; |
|
| |
|
| _DIAGASSERT(cap != NULL); |
_DIAGASSERT(cap != NULL); |
| _DIAGASSERT(len != NULL); |
_DIAGASSERT(len != NULL); |
| Line 301 getent(char **cap, size_t *len, const ch |
|
| Line 311 getent(char **cap, size_t *len, const ch |
|
| if (fd >= 0) { |
if (fd >= 0) { |
| (void)lseek(fd, (off_t)0, SEEK_SET); |
(void)lseek(fd, (off_t)0, SEEK_SET); |
| } else { |
} else { |
| |
#ifndef SMALL |
| (void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p); |
(void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p); |
| if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0)) |
if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0)) |
| != NULL) { |
!= NULL) { |
| Line 325 getent(char **cap, size_t *len, const ch |
|
| Line 336 getent(char **cap, size_t *len, const ch |
|
| *len = clen; |
*len = clen; |
| *cap = cbuf; |
*cap = cbuf; |
| return (retval); |
return (retval); |
| } else { |
} else |
| |
#endif |
| |
{ |
| fd = open(*db_p, O_RDONLY, 0); |
fd = open(*db_p, O_RDONLY, 0); |
| if (fd < 0) { |
if (fd < 0) { |
| /* No error on unfound file. */ |
/* No error on unfound file. */ |
|
|
| return (0); |
return (0); |
| } |
} |
| |
|
| |
#ifndef SMALL |
| static int |
static int |
| cdbget(DB *capdbp, char **bp, const char *name) |
cdbget(DB *capdbp, char **bp, const char *name) |
| { |
{ |
| Line 666 cdbget(DB *capdbp, char **bp, const char |
|
| Line 680 cdbget(DB *capdbp, char **bp, const char |
|
| *bp = (char *)data.data + 1; |
*bp = (char *)data.data + 1; |
| return (((char *)(data.data))[0] == TCERR ? 1 : 0); |
return (((char *)(data.data))[0] == TCERR ? 1 : 0); |
| } |
} |
| |
#endif |
| |
|
| /* |
/* |
| * Cgetmatch will return 0 if name is one of the names of the capability |
* Cgetmatch will return 0 if name is one of the names of the capability |