aboutsummaryrefslogtreecommitdiff
path: root/pwd/pwdread.c
diff options
context:
space:
mode:
Diffstat (limited to 'pwd/pwdread.c')
-rw-r--r--pwd/pwdread.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/pwd/pwdread.c b/pwd/pwdread.c
index 0ce27d7..1203236 100644
--- a/pwd/pwdread.c
+++ b/pwd/pwdread.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -114,3 +114,34 @@ DEFUN(__pwdread, (stream, p), FILE *stream AND PTR CONST p)
return &info->p;
}
+
+
+struct passwd *
+__pwdscan (void **info, int (*selector) (struct passwd *))
+{
+ FILE *stream;
+ struct passwd *p;
+
+ if (*info == NULL)
+ {
+ *info = __pwdalloc ();
+ if (info == NULL)
+ return NULL;
+ }
+
+ stream = __pwdopen ();
+ if (stream == NULL)
+ return NULL;
+
+ p = NULL;
+ while (! feof (stream))
+ {
+ p = __pwdread (stream, *info);
+ if (p && (*selector) (p))
+ break;
+ p = NULL;
+ }
+
+ (void) fclose (stream);
+ return p;
+}