]> granicus.if.org Git - musl/commitdiff
shadow: Implement fgetspent
authorMichael Forney <mforney@mforney.org>
Thu, 21 Nov 2013 03:13:41 +0000 (19:13 -0800)
committerRich Felker <dalias@aerifal.cx>
Mon, 25 Nov 2013 02:04:53 +0000 (21:04 -0500)
src/passwd/fgetspent.c

index 3dda7848eb0347a1e2fb11fa7a0520e8ccac1654..47473bdb8cd84c0f31f57a89c11e654747589852 100644 (file)
@@ -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;
 }