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