mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Michael Forney <mforney@mforney.org>
To: musl@lists.openwall.com
Subject: [PATCH 2/2] shadow: Implement fgetspent
Date: Wed, 20 Nov 2013 19:13:41 -0800	[thread overview]
Message-ID: <1385003621-10289-3-git-send-email-mforney@mforney.org> (raw)
In-Reply-To: <1385003621-10289-1-git-send-email-mforney@mforney.org>

---
 src/passwd/fgetspent.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/passwd/fgetspent.c b/src/passwd/fgetspent.c
index 3dda784..47473bd 100644
--- a/src/passwd/fgetspent.c
+++ b/src/passwd/fgetspent.c
@@ -1,6 +1,15 @@
 #include "pwf.h"
+#include <pthread.h>
 
 struct spwd *fgetspent(FILE *f)
 {
-	return 0;
+	static char *line;
+	static struct spwd sp;
+	size_t size = 0;
+	struct spwd *res = 0;
+	int cs;
+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+	if (getline(&line, &size, f) >= 0 && __parsespent(line, &sp) >= 0) res = &sp;
+	pthread_setcancelstate(cs, 0);
+	return res;
 }
-- 
1.8.4.2



  parent reply	other threads:[~2013-11-21  3:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-21  3:13 [PATCH 0/2] " Michael Forney
2013-11-21  3:13 ` [PATCH 1/2] shadow: Move spent parsing to internal function Michael Forney
2013-11-24  6:17   ` [PATCH v2 " Michael Forney
2013-11-21  3:13 ` Michael Forney [this message]
2013-11-23 21:08 ` [PATCH 0/2] Implement fgetspent 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=1385003621-10289-3-git-send-email-mforney@mforney.org \
    --to=mforney@mforney.org \
    --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).