|
|
446cf2 |
From 9980bf0b307368959cb29f3ca3f7446ad92347f1 Mon Sep 17 00:00:00 2001
|
|
|
446cf2 |
From: Florian Weimer <fweimer@redhat.com>
|
|
|
446cf2 |
Date: Thu, 16 Jul 2020 16:55:45 +0200
|
|
|
446cf2 |
Subject: [PATCH 04/11] nss_files: Use generic result pointer in parse_line
|
|
|
446cf2 |
|
|
|
446cf2 |
As a result, all parse_line functions have the same prototype, except
|
|
|
446cf2 |
for that producing struct hostent. This change is ABI-compatible, so
|
|
|
446cf2 |
it does not alter the internal GLIBC_PRIVATE ABI (otherwise we should
|
|
|
446cf2 |
probably have renamed the exported functions).
|
|
|
446cf2 |
|
|
|
446cf2 |
A future change will use this to implement a generict fget*ent_r
|
|
|
446cf2 |
function.
|
|
|
446cf2 |
|
|
|
446cf2 |
Tested-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
446cf2 |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
446cf2 |
---
|
|
|
446cf2 |
include/nss_files.h | 48 ++++++++++++---------------------------------
|
|
|
446cf2 |
nss/nss_files/files-parse.c | 5 +++--
|
|
|
446cf2 |
2 files changed, 15 insertions(+), 38 deletions(-)
|
|
|
446cf2 |
|
|
|
446cf2 |
diff --git a/include/nss_files.h b/include/nss_files.h
|
|
|
446cf2 |
index 54b354a..d0f2681 100644
|
|
|
446cf2 |
--- a/include/nss_files.h
|
|
|
446cf2 |
+++ b/include/nss_files.h
|
|
|
446cf2 |
@@ -26,45 +26,21 @@ FILE *__nss_files_fopen (const char *path);
|
|
|
446cf2 |
libc_hidden_proto (__nss_files_fopen)
|
|
|
446cf2 |
|
|
|
446cf2 |
struct parser_data;
|
|
|
446cf2 |
-struct etherent;
|
|
|
446cf2 |
-struct group;
|
|
|
446cf2 |
-struct netent;
|
|
|
446cf2 |
-struct passwd;
|
|
|
446cf2 |
-struct protoent;
|
|
|
446cf2 |
-struct rpcent;
|
|
|
446cf2 |
-struct servent;
|
|
|
446cf2 |
-struct sgrp;
|
|
|
446cf2 |
-struct spwd;
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Instances of the parse_line function from
|
|
|
446cf2 |
nss/nss_files/files-parse.c. */
|
|
|
446cf2 |
-extern int _nss_files_parse_etherent (char *line, struct etherent *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_grent (char *line, struct group *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_netent (char *line, struct netent *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_protoent (char *line, struct protoent *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_pwent (char *line, struct passwd *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_rpcent (char *line, struct rpcent *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_servent (char *line, struct servent *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_sgent (char *line, struct sgrp *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
-extern int _nss_files_parse_spent (char *line, struct spwd *result,
|
|
|
446cf2 |
- struct parser_data *data,
|
|
|
446cf2 |
- size_t datalen, int *errnop);
|
|
|
446cf2 |
+typedef int nss_files_parse_line (char *line, void *result,
|
|
|
446cf2 |
+ struct parser_data *data,
|
|
|
446cf2 |
+ size_t datalen, int *errnop);
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_etherent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_grent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_netent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_protoent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_pwent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_rpcent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_servent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_sgent;
|
|
|
446cf2 |
+extern nss_files_parse_line _nss_files_parse_spent;
|
|
|
446cf2 |
|
|
|
446cf2 |
libnss_files_hidden_proto (_nss_files_parse_etherent)
|
|
|
446cf2 |
libc_hidden_proto (_nss_files_parse_grent)
|
|
|
446cf2 |
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
|
|
|
446cf2 |
index 3820287..c6cd43b 100644
|
|
|
446cf2 |
--- a/nss/nss_files/files-parse.c
|
|
|
446cf2 |
+++ b/nss/nss_files/files-parse.c
|
|
|
446cf2 |
@@ -87,7 +87,7 @@ struct parser_data
|
|
|
446cf2 |
#ifdef EXTERN_PARSER
|
|
|
446cf2 |
|
|
|
446cf2 |
/* The parser is defined in a different module. */
|
|
|
446cf2 |
-extern int parse_line (char *line, struct STRUCTURE *result,
|
|
|
446cf2 |
+extern int parse_line (char *line, void *result,
|
|
|
446cf2 |
struct parser_data *data, size_t datalen, int *errnop
|
|
|
446cf2 |
EXTRA_ARGS_DECL);
|
|
|
446cf2 |
|
|
|
446cf2 |
@@ -99,10 +99,11 @@ extern int parse_line (char *line, struct STRUCTURE *result,
|
|
|
446cf2 |
|
|
|
446cf2 |
# define LINE_PARSER(EOLSET, BODY) \
|
|
|
446cf2 |
parser_stclass int \
|
|
|
446cf2 |
-parse_line (char *line, struct STRUCTURE *result, \
|
|
|
446cf2 |
+parse_line (char *line, void *generic_result, \
|
|
|
446cf2 |
struct parser_data *data, size_t datalen, int *errnop \
|
|
|
446cf2 |
EXTRA_ARGS_DECL) \
|
|
|
446cf2 |
{ \
|
|
|
446cf2 |
+ struct STRUCTURE *result = generic_result; \
|
|
|
446cf2 |
ENTDATA_DECL (data) \
|
|
|
446cf2 |
BUFFER_PREPARE \
|
|
|
446cf2 |
char *p = strpbrk (line, EOLSET "\n"); \
|
|
|
446cf2 |
--
|
|
|
446cf2 |
1.8.3.1
|
|
|
446cf2 |
|