aboutsummaryrefslogtreecommitdiff
path: root/nss/nss_files
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-08-25 17:19:50 +0000
committerUlrich Drepper <drepper@redhat.com>1999-08-25 17:19:50 +0000
commit71d3bda9a7a15bf3f935ffcde8aeceefef8074f7 (patch)
tree3188ef1b1ad5a60d512813dadfc756225dda0ff4 /nss/nss_files
parentad65970214c9dfaa6b61b9519cb0667b376e14d9 (diff)
downloadglibc-71d3bda9a7a15bf3f935ffcde8aeceefef8074f7.zip
glibc-71d3bda9a7a15bf3f935ffcde8aeceefef8074f7.tar.gz
glibc-71d3bda9a7a15bf3f935ffcde8aeceefef8074f7.tar.bz2
Update.
1999-08-25 Ulrich Drepper <drepper@cygnus.com> * inet/Makefile (routines): Add getipnodebynm. * inet/getipnodebynm.c: New file. * nss/digits_dots.c: If HAVE_TYPE is define type contains the interface type. * nss/nss_files/files-XXX.c: Define EXTRA_ARGS, EXTRA_ARGS_DECL, and EXTRA_ARGS_VALUE is not already done. (internal_getent): Allow extra parameters and pass them to parse_line. (_nss_files_get,ENTNAME_r): Pass extra parameters to internal_getent. (_nss_files_get##name##_r): Likewise. * nss/nss_files/files-hosts.c: Define EXTRA_ARGS, EXTRA_ARGS_DECL, and EXTRA_ARGS_VALUE to pass flags and type to parser. Add getipnodebyname function. * nss/nss_files/files-parse.c: Define EXTRA_ARGS, EXTRA_ARGS_DECL, and EXTRA_ARGS_VALUE is not already done. (parse_line): Add EXTRA_ARGS_DECL to parameter list. * nss/nss_db/db-XXX.c (lookup): Allow extra parameters and pass them to parse_line. (_nss_db_get##name##_r): Pass extra parameters to lookup. (_nss_db_get,ENTNAME_r): Likewise. * sysdeps/generic/if_index.c (__protocol_available): New function. * sysdeps/unix/sysv/linux/if_index.c: Likewise.
Diffstat (limited to 'nss/nss_files')
-rw-r--r--nss/nss_files/files-XXX.c16
-rw-r--r--nss/nss_files/files-hosts.c37
-rw-r--r--nss/nss_files/files-parse.c18
3 files changed, 52 insertions, 19 deletions
diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index d145001..6dd5919 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -50,6 +50,12 @@
# define H_ERRNO_SET(val) ((void) 0)
#endif
+#ifndef EXTRA_ARGS
+# define EXTRA_ARGS
+# define EXTRA_ARGS_DECL
+# define EXTRA_ARGS_VALUE
+#endif
+
/* Locks the static variables in this file. */
__libc_lock_define_initialized (static, lock)
@@ -161,7 +167,8 @@ CONCAT(_nss_files_end,ENTNAME) (void)
static enum nss_status
internal_getent (struct STRUCTURE *result,
- char *buffer, size_t buflen, int *errnop H_ERRNO_PROTO)
+ char *buffer, size_t buflen, int *errnop H_ERRNO_PROTO
+ EXTRA_ARGS_DECL)
{
char *p;
struct parser_data *data = (void *) buffer;
@@ -204,7 +211,8 @@ internal_getent (struct STRUCTURE *result,
while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */
/* Parse the line. If it is invalid, loop to get the next
line of the file to parse. */
- || ! (parse_result = parse_line (p, result, data, buflen, errnop)));
+ || ! (parse_result = parse_line (p, result, data, buflen, errnop
+ EXTRA_ARGS)));
/* Filled in RESULT with the next entry from the database file. */
return parse_result == -1 ? NSS_STATUS_TRYAGAIN : NSS_STATUS_SUCCESS;
@@ -249,7 +257,7 @@ CONCAT(_nss_files_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
if (status == NSS_STATUS_SUCCESS)
{
status = internal_getent (result, buffer, buflen, errnop
- H_ERRNO_ARG);
+ H_ERRNO_ARG EXTRA_ARGS_VALUE);
/* Remember this position if we were successful. If the
operation failed we give the user a chance to repeat the
@@ -298,7 +306,7 @@ _nss_files_get##name##_r (proto, \
last_use = getby; \
\
while ((status = internal_getent (result, buffer, buflen, errnop \
- H_ERRNO_ARG)) \
+ H_ERRNO_ARG EXTRA_ARGS_VALUE)) \
== NSS_STATUS_SUCCESS) \
{ break_if_match } \
\
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index 2379919..a5f4fcc 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -1,5 +1,5 @@
/* Hosts file parser in nss_files module.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -32,6 +32,9 @@
#define DATABASE "hosts"
#define NEED_H_ERRNO
+#define EXTRA_ARGS , af, flags
+#define EXTRA_ARGS_DECL , int af, int flags
+
#define ENTDATA hostent_data
struct hostent_data
{
@@ -50,9 +53,9 @@ LINE_PARSER
STRING_FIELD (addr, isspace, 1);
/* Parse address. */
- if (inet_pton (AF_INET, addr, entdata->host_addr) > 0)
+ if (af == AF_INET && inet_pton (AF_INET, addr, entdata->host_addr) > 0)
{
- if (_res.options & RES_USE_INET6)
+ if (flags & AI_V4MAPPED)
{
map_v4v6_address ((char *) entdata->host_addr,
(char *) entdata->host_addr);
@@ -65,7 +68,8 @@ LINE_PARSER
result->h_length = INADDRSZ;
}
}
- else if (inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
+ else if (af == AF_INET6
+ && inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
{
result->h_addrtype = AF_INET6;
result->h_length = IN6ADDRSZ;
@@ -82,26 +86,35 @@ LINE_PARSER
STRING_FIELD (result->h_name, isspace, 1);
})
+#define EXTRA_ARGS_VALUE \
+ , ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET), \
+ ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)
#include "files-XXX.c"
DB_LOOKUP (hostbyname, ,,
{
- if (result->h_addrtype != ((_res.options & RES_USE_INET6)
- ? AF_INET6 : AF_INET))
- continue;
LOOKUP_NAME_CASE (h_name, h_aliases)
}, const char *name)
+#undef EXTRA_ARGS_VALUE
+#define EXTRA_ARGS_VALUE \
+ , af, ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)
DB_LOOKUP (hostbyname2, ,,
{
- if (result->h_addrtype != af)
- continue;
LOOKUP_NAME_CASE (h_name, h_aliases)
}, const char *name, int af)
DB_LOOKUP (hostbyaddr, ,,
{
- if (result->h_addrtype == type && result->h_length == len &&
- ! memcmp (addr, result->h_addr_list[0], len))
+ if (result->h_length == len
+ && ! memcmp (addr, result->h_addr_list[0], len))
break;
- }, const char *addr, int len, int type)
+ }, const char *addr, int len, int af)
+
+#undef EXTRA_ARGS_VALUE
+#define EXTRA_ARGS_VALUE \
+ , af, flags
+DB_LOOKUP (ipnodebyname, ,,
+ {
+ LOOKUP_NAME_CASE (h_name, h_aliases)
+ }, const char *name, int af, int flags)
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index d688fdc..41f0ef6 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -1,5 +1,5 @@
/* Common code for file-based database parsers in nss_files module.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -33,8 +33,18 @@
NEED_H_ERRNO - defined iff an arg `int *herrnop' is used.
+ EXTRA_ARGS -- defined iff extra parameters must be passed to the parser
+ EXTRA_ARGS_DECL -- declaration for these extra parameters
+ EXTRA_ARGS_VALUE -- values to be passed for these parameters
+
Also see files-XXX.c. */
+#ifndef EXTRA_ARGS
+# define EXTRA_ARGS
+# define EXTRA_ARGS_DECL
+# define EXTRA_ARGS_VALUE
+#endif
+
#define CONCAT(a,b) CONCAT1(a,b)
#define CONCAT1(a,b) a##b
@@ -69,7 +79,8 @@ struct parser_data
/* The parser is defined in a different module. */
extern int parse_line (char *line, struct STRUCTURE *result,
- struct parser_data *data, size_t datalen, int *errnop);
+ struct parser_data *data, size_t datalen, int *errnop
+ EXTRA_ARGS_DECL);
# define LINE_PARSER(EOLSET, BODY) /* Do nothing */
@@ -80,7 +91,8 @@ extern int parse_line (char *line, struct STRUCTURE *result,
# define LINE_PARSER(EOLSET, BODY) \
parser_stclass int \
parse_line (char *line, struct STRUCTURE *result, \
- struct parser_data *data, size_t datalen, int *errnop) \
+ struct parser_data *data, size_t datalen, int *errnop \
+ EXTRA_ARGS_DECL) \
{ \
ENTDATA_DECL (data) \
char *p = strpbrk (line, EOLSET "\n"); \