summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2013-11-20 19:13:41 -0800
committerRich Felker <dalias@aerifal.cx>2013-11-24 21:04:53 -0500
commit7e771e62e78944b9d1fe7e78ef71422b9d51f275 (patch)
treec8ad2eee2edee71fbabad21557002b7f001908cc
parentb3646b30d670ac5a38674ecc492c38f7d4e92682 (diff)
downloadmusl-7e771e62e78944b9d1fe7e78ef71422b9d51f275.tar.gz
musl-7e771e62e78944b9d1fe7e78ef71422b9d51f275.tar.bz2
musl-7e771e62e78944b9d1fe7e78ef71422b9d51f275.tar.xz
musl-7e771e62e78944b9d1fe7e78ef71422b9d51f275.zip
shadow: Implement fgetspent
-rw-r--r--src/passwd/fgetspent.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/passwd/fgetspent.c b/src/passwd/fgetspent.c
index 3dda7848..47473bdb 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;
}