diff options
Diffstat (limited to 'riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getspent.c')
| -rw-r--r-- | riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getspent.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getspent.c b/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getspent.c new file mode 100644 index 0000000..3d6a75c --- /dev/null +++ b/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/nv_getspent.c @@ -0,0 +1,47 @@ +#include <shadow.h> /*EXTRACT_UNMOD*/ +#include "parselib.h" +#define NV_SETSPENT +#include "config.h" + +static struct state S; + +void nv_setspent() /*EXTRACT_INCL*/{__prepare_parse(__SHADOW_FILE,&S);} +void nv_endspent() /*EXTRACT_INCL*/{__end_parse(&S);} + +struct spwd *nv_getspent() /*EXTRACT_INCL*/ { + static struct spwd sp; + static char buf[__SHADOW_BUFFER]; + char *arg[12]; + unsigned int u; + + if (!S.buffirst) nv_setspent(); + if (!S.buffirst) return 0; + + again: + if ((u=__parse_feed(&S, buf, sizeof(buf)))==0) return 0; + if ((u=__parse_split(buf,u,':',9,arg)) < 6) goto again; + + sp.sp_namp = arg[0]; + sp.sp_pwdp = arg[1]; +#ifndef DONT_NEED_ALL_SHADOW + { + unsigned long i,j,l; + for (i=2; i<u; i++) { + j=scan_ulong(arg[i],&l); + if (arg[i][j]) goto again; + if (j==0) l = (unsigned long)-1; + + switch (i) { + case 2: sp.sp_lstchg=l; break; + case 3: sp.sp_min=l; break; + case 4: sp.sp_max=l; break; + case 5: sp.sp_warn=l; break; + case 6: sp.sp_inact=l; break; + case 7: sp.sp_expire=l; break; + case 8: sp.sp_flag=l; break; + } + } + } +#endif + return(&sp); +} |
