1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| | #include "pwf.h"
static long xatol(char **s)
{
long x;
if (**s == ':' || **s == '\n') return -1;
for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
return x;
}
int __parsespent(char *s, struct spwd *sp)
{
sp->sp_namp = s;
if (!(s = strchr(s, ':'))) return -1;
*s = 0;
sp->sp_pwdp = ++s;
if (!(s = strchr(s, ':'))) return -1;
*s = 0;
s++; sp->sp_lstchg = xatol(&s);
if (*s != ':') return -1;
s++; sp->sp_min = xatol(&s);
if (*s != ':') return -1;
s++; sp->sp_max = xatol(&s);
if (*s != ':') return -1;
s++; sp->sp_warn = xatol(&s);
if (*s != ':') return -1;
s++; sp->sp_inact = xatol(&s);
if (*s != ':') return -1;
s++; sp->sp_expire = xatol(&s);
if (*s != ':') return -1;
s++; sp->sp_flag = xatol(&s);
if (*s != '\n') return -1;
return 0;
}
|