From: Isaac Dunham <idunham@lavabit.com>
To: musl@lists.openwall.com
Subject: fgetgrent
Date: Fri, 1 Feb 2013 21:14:04 -0800 [thread overview]
Message-ID: <20130201211404.55e1589f.idunham@lavabit.com> (raw)
In-Reply-To: <20130202023833.GW20323@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 350 bytes --]
On Fri, 1 Feb 2013 21:38:33 -0500
Rich Felker <dalias@aerifal.cx> wrote:
> > Add fgetgrent (for heirloom-pkgtools) (patch same as the last time I sent it)
>
> I'll look at it again.
It would be possible to implement getgrent as a wrapper for __fgetgrent, if that shrinks code size for a worthwhile amount.
--
Isaac Dunham <idunham@lavabit.com>
[-- Attachment #2: fgetgrent.diff --]
[-- Type: text/x-diff, Size: 958 bytes --]
diff --git a/include/grp.h b/include/grp.h
index 030d7f8..cb40e07 100644
--- a/include/grp.h
+++ b/include/grp.h
@@ -30,6 +30,10 @@ struct group *getgrent(void);
void endgrent(void);
void setgrent(void);
+#ifdef _GNU_SOURCE
+struct group *fgetgrent(FILE *stream);
+#endif
+
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
int getgrouplist(const char *, gid_t, gid_t *, int *);
int setgroups(size_t, const gid_t *);
diff --git a/src/passwd/getgrent.c b/src/passwd/getgrent.c
index 429a3e5..d59bcb6 100644
--- a/src/passwd/getgrent.c
+++ b/src/passwd/getgrent.c
@@ -10,6 +10,17 @@ void setgrent()
weak_alias(setgrent, endgrent);
+struct group *__fgetgrent(FILE *f)
+{
+ static char *line, **mem;
+ static struct group gr;
+ size_t size=0, nmem=0;
+ if (!f) return 0;
+ return __getgrent_a(f, &gr, &line, &size, &mem, &nmem);
+}
+
+weak_alias(__fgetgrent,fgetgrent);
+
struct group *getgrent()
{
static char *line, **mem;
next prev parent reply other threads:[~2013-02-02 5:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-01 7:10 musl 0.9.9 released Rich Felker
2013-02-02 2:23 ` Isaac Dunham
2013-02-02 2:38 ` Rich Felker
2013-02-02 4:04 ` strverscmp Isaac Dunham
2013-02-17 18:39 ` strverscmp Rich Felker
2013-02-19 1:15 ` strverscmp Isaac Dunham
2013-02-26 6:40 ` strverscmp Rich Felker
2013-02-02 5:14 ` Isaac Dunham [this message]
2013-02-02 5:32 ` fgetgrent Rich Felker
2013-02-17 18:50 ` fgetgrent Rich Felker
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=20130201211404.55e1589f.idunham@lavabit.com \
--to=idunham@lavabit.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).