public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 04/11] nss_files: Use generic result pointer in parse_line
Date: Fri, 17 Jul 2020 10:30:25 +0200	[thread overview]
Message-ID: <92c7e280f16600bd2f74109c243668b9e4ed87b0.1594974444.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1594974444.git.fweimer@redhat.com>

As a result, all parse_line functions have the same prototype, except
for that producing struct hostent.  This change is ABI-compatible, so
it does not alter the internal GLIBC_PRIVATE ABI (otherwise we should
probably have renamed the exported functions).

A future change will use this to implement a generict fget*ent_r
function.
---
 include/nss_files.h         | 48 ++++++++++---------------------------
 nss/nss_files/files-parse.c |  5 ++--
 2 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/include/nss_files.h b/include/nss_files.h
index 54b354afb3..d0f26815b5 100644
--- a/include/nss_files.h
+++ b/include/nss_files.h
@@ -26,45 +26,21 @@ FILE *__nss_files_fopen (const char *path);
 libc_hidden_proto (__nss_files_fopen)
 
 struct parser_data;
-struct etherent;
-struct group;
-struct netent;
-struct passwd;
-struct protoent;
-struct rpcent;
-struct servent;
-struct sgrp;
-struct spwd;
 
 /* Instances of the parse_line function from
    nss/nss_files/files-parse.c.  */
-extern int _nss_files_parse_etherent (char *line, struct etherent *result,
-                                      struct parser_data *data,
-                                      size_t datalen, int *errnop);
-extern int _nss_files_parse_grent (char *line, struct group *result,
-                                   struct parser_data *data,
-                                   size_t datalen, int *errnop);
-extern int _nss_files_parse_netent (char *line, struct netent *result,
-                                    struct parser_data *data,
-                                    size_t datalen, int *errnop);
-extern int _nss_files_parse_protoent (char *line, struct protoent *result,
-                                      struct parser_data *data,
-                                      size_t datalen, int *errnop);
-extern int _nss_files_parse_pwent (char *line, struct passwd *result,
-                                   struct parser_data *data,
-                                   size_t datalen, int *errnop);
-extern int _nss_files_parse_rpcent (char *line, struct rpcent *result,
-                                    struct parser_data *data,
-                                    size_t datalen, int *errnop);
-extern int _nss_files_parse_servent (char *line, struct servent *result,
-                                     struct parser_data *data,
-                                     size_t datalen, int *errnop);
-extern int _nss_files_parse_sgent (char *line, struct sgrp *result,
-                                   struct parser_data *data,
-                                   size_t datalen, int *errnop);
-extern int _nss_files_parse_spent (char *line, struct spwd *result,
-                                   struct parser_data *data,
-                                   size_t datalen, int *errnop);
+typedef int nss_files_parse_line (char *line, void *result,
+                                  struct parser_data *data,
+                                  size_t datalen, int *errnop);
+extern nss_files_parse_line _nss_files_parse_etherent;
+extern nss_files_parse_line _nss_files_parse_grent;
+extern nss_files_parse_line _nss_files_parse_netent;
+extern nss_files_parse_line _nss_files_parse_protoent;
+extern nss_files_parse_line _nss_files_parse_pwent;
+extern nss_files_parse_line _nss_files_parse_rpcent;
+extern nss_files_parse_line _nss_files_parse_servent;
+extern nss_files_parse_line _nss_files_parse_sgent;
+extern nss_files_parse_line _nss_files_parse_spent;
 
 libnss_files_hidden_proto (_nss_files_parse_etherent)
 libc_hidden_proto (_nss_files_parse_grent)
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index 382028765b..c6cd43babe 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -87,7 +87,7 @@ struct parser_data
 #ifdef EXTERN_PARSER
 
 /* The parser is defined in a different module.  */
-extern int parse_line (char *line, struct STRUCTURE *result,
+extern int parse_line (char *line, void *result,
 		       struct parser_data *data, size_t datalen, int *errnop
 		       EXTRA_ARGS_DECL);
 
@@ -99,10 +99,11 @@ extern int parse_line (char *line, struct STRUCTURE *result,
 
 # define LINE_PARSER(EOLSET, BODY)					      \
 parser_stclass int							      \
-parse_line (char *line, struct STRUCTURE *result,			      \
+parse_line (char *line, void *generic_result,				      \
 	    struct parser_data *data, size_t datalen, int *errnop	      \
 	    EXTRA_ARGS_DECL)						      \
 {									      \
+  struct STRUCTURE *result = generic_result;				      \
   ENTDATA_DECL (data)							      \
   BUFFER_PREPARE							      \
   char *p = strpbrk (line, EOLSET "\n");				      \
-- 
2.26.2



  parent reply	other threads:[~2020-07-17  8:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17  8:29 [PATCH 00/11] Fix fgetsgent_r data corruption bug (20338) Florian Weimer
2020-07-17  8:30 ` [PATCH 01/11] nss_files: Consolidate file opening in __nss_files_fopen Florian Weimer
2020-07-21  3:27   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 02/11] nss_compat: Do not use mmap to read database files (bug 26258) Florian Weimer
2020-07-21  3:27   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 03/11] nss_files: Consolidate line parse declarations in <nss_files.h> Florian Weimer
2020-07-21  3:27   ` Carlos O'Donell
2020-07-17  8:30 ` Florian Weimer [this message]
2020-07-21  3:27   ` [PATCH 04/11] nss_files: Use generic result pointer in parse_line Carlos O'Donell
2020-07-17  8:30 ` [PATCH 05/11] libio: Add fseterr_unlocked for internal use Florian Weimer
2020-07-21  3:27   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 06/11] nss: Add __nss_fgetent_r Florian Weimer
2020-07-21  3:27   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 07/11] grp: Implement fgetgrent_r using __nss_fgetent_r Florian Weimer
2020-07-21  3:28   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 08/11] gshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338) Florian Weimer
2020-07-21  3:28   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 09/11] pwd: Implement fgetpwent_r using __nss_fgetent_r Florian Weimer
2020-07-21  3:28   ` Carlos O'Donell
2020-07-17  8:30 ` [PATCH 10/11] shadow: Implement fgetspent_r " Florian Weimer
2020-07-21  3:28   ` Carlos O'Donell
2020-07-17  8:31 ` [PATCH 11/11] libio: Remove __libc_readline_unlocked Florian Weimer
2020-07-21  3:28   ` Carlos O'Donell
2020-07-21  3:27 ` [PATCH 00/11] Fix fgetsgent_r data corruption bug (20338) Carlos O'Donell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92c7e280f16600bd2f74109c243668b9e4ed87b0.1594974444.git.fweimer@redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).