blob: ed14ad5833d33f94029ff5eee6481475b184764f (
plain)
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
|
#include <grp.h> /*EXTRACT_UNMOD*/
#include "parselib.h"
#define NV_SETGRENT
#include "config.h"
static struct state S;
void nv_setgrent() /*EXTRACT_INCL*/ {__prepare_parse(__GROUP_FILE,&S);}
void nv_endgrent() /*EXTRACT_INCL*/ {__end_parse(&S);}
struct group *nv_getgrent() /*EXTRACT_INCL*/ {
static struct group gr;
static char *arg[SCAN_GROUPS + 2];
static char buf[__GROUP_BUFFER];
char *p;
unsigned long u;
if (!S.buffirst) nv_setgrent();
if (!S.buffirst) return 0;
again:
if ((u = __parse_feed(&S, buf, sizeof(buf)))==0) return 0;
if (4 != __parse_split(buf,u,':',4,arg)) goto again;
gr.gr_name = arg[0];
#ifndef DONT_NEED_PASSWD
gr.gr_passwd = arg[1];
#endif
#ifndef DONT_NEED_GID
p=arg[2]; if (!*p || p[scan_ulong(p,&u)]) goto again; gr.gr_gid =u;
#endif
#ifndef DONT_NEED_MEMBERS
__parse_split(arg[3],str_len(arg[3])+1,',',SCAN_GROUPS,arg);
gr.gr_mem = arg;
#endif
return(&gr);
}
|