aboutsummaryrefslogtreecommitdiff
path: root/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getpwent.c
diff options
context:
space:
mode:
Diffstat (limited to 'riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getpwent.c')
-rw-r--r--riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getpwent.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getpwent.c b/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getpwent.c
new file mode 100644
index 0000000..75ce6cb
--- /dev/null
+++ b/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getpwent.c
@@ -0,0 +1,44 @@
+#include <pwd.h> /*EXTRACT_UNMOD*/
+#include "parselib.h"
+#define NV_SETPWENT
+#include "config.h"
+
+static struct state S;
+
+void nv_setpwent() /*EXTRACT_INCL*/ {__prepare_parse(__PASSWD_FILE,&S);}
+void nv_endpwent() /*EXTRACT_INCL*/ {__end_parse(&S);}
+
+struct passwd *nv_getpwent() /*EXTRACT_INCL*/ {
+ static struct passwd pw;
+ static char buf[__PASSWD_BUFFER];
+ char *p,*arg[9];
+ unsigned long u;
+
+ if (!S.buffirst) nv_setpwent();
+ if (!S.buffirst) return 0;
+
+ again:
+ if ((u = __parse_feed(&S, buf, sizeof(buf)))==0) return 0;
+ if (7 != __parse_split(buf,u,':',7,arg)) goto again;
+
+ pw.pw_name = arg[0];
+#ifndef DONT_NEED_PASSWD
+ pw.pw_passwd = arg[1];
+#endif
+#ifndef DONT_NEED_UID
+ p=arg[2]; if (!*p || p[scan_ulong(p,&u)]) goto again; pw.pw_uid =u;
+#endif
+#ifndef DONT_NEED_GID
+ p=arg[3]; if (!*p || p[scan_ulong(p,&u)]) goto again; pw.pw_gid =u;
+#endif
+#ifndef DONT_NEED_GECOS
+ pw.pw_gecos = arg[4];
+#endif
+#ifndef DONT_NEED_DIR
+ pw.pw_dir = arg[5];
+#endif
+#ifndef DONT_NEED_SHELL
+ pw.pw_shell = arg[6];
+#endif
+ return(&pw);
+}