lib/libutil/gr_util.c
static bool
__gr_scan(char *line, struct group *gr)
{
	char *loc;
	int ndx;

	/* Assign non-member information to structure. */
	gr->gr_name = line;
	if ((loc = strchr(line, ':')) == NULL)
		return (false);
	*loc = '\0';
	gr->gr_passwd = loc + 1;
	if (*gr->gr_passwd == ':')
		*gr->gr_passwd = '\0';
	else {
		if ((loc = strchr(loc + 1, ':')) == NULL)
			return (false);
		*loc = '\0';
	}
	if (sscanf(loc + 1, "%u", &gr->gr_gid) != 1)
		return (false);

	/* Assign member information to structure. */
	if ((loc = strchr(loc + 1, ':')) == NULL)
		return (false);
	line = loc + 1;
	gr->gr_mem = NULL;
	ndx = 0;
	do {
		gr->gr_mem = reallocf(gr->gr_mem, sizeof(*gr->gr_mem) *
		    (ndx + 1));
		if (gr->gr_mem == NULL)
			return (false);

		/* Skip locations without members (i.e., empty string). */
		do {
			gr->gr_mem[ndx] = strsep(&line, ",");
		} while (gr->gr_mem[ndx] != NULL && *gr->gr_mem[ndx] == '\0');
	} while (gr->gr_mem[ndx++] != NULL);

	return (true);
}
/*
 * Scan a line and place it into a group structure.
 */
Scan a line and place it into a group structure.
Scan a line and place it into a group structure .
static bool
__gr_scan(char *line, struct group *gr)
{
	char *loc;
	int ndx;
	gr->gr_name = line;
	if ((loc = strchr(line, ':')) == NULL)
		return (false);
	*loc = '\0';
	gr->gr_passwd = loc + 1;
	if (*gr->gr_passwd == ':')
		*gr->gr_passwd = '\0';
	else {
		if ((loc = strchr(loc + 1, ':')) == NULL)
			return (false);
		*loc = '\0';
	}
	if (sscanf(loc + 1, "%u", &gr->gr_gid) != 1)
		return (false);
	if ((loc = strchr(loc + 1, ':')) == NULL)
		return (false);
	line = loc + 1;
	gr->gr_mem = NULL;
	ndx = 0;
	do {
		gr->gr_mem = reallocf(gr->gr_mem, sizeof(*gr->gr_mem) *
		    (ndx + 1));
		if (gr->gr_mem == NULL)
			return (false);
		do {
			gr->gr_mem[ndx] = strsep(&line, ",");
		} while (gr->gr_mem[ndx] != NULL && *gr->gr_mem[ndx] == '\0');
	} while (gr->gr_mem[ndx++] != NULL);
	return (true);
}
static bool __gr_scan ( char * line , struct group * gr ) { char * loc ; int ndx ; gr -> gr_name = line ; if ( ( loc = strchr ( line , ' ' ) ) == NULL ) return ( false ) ; * loc = ' \0 ' ; gr -> gr_passwd = loc + 1 ; if ( * gr -> gr_passwd == ' ' ) * gr -> gr_passwd = ' \0 ' ; else { if ( ( loc = strchr ( loc + 1 , ' ' ) ) == NULL ) return ( false ) ; * loc = ' \0 ' ; } if ( sscanf ( loc + 1 , " " , & gr -> gr_gid ) != 1 ) return ( false ) ; if ( ( loc = strchr ( loc + 1 , ' ' ) ) == NULL ) return ( false ) ; line = loc + 1 ; gr -> gr_mem = NULL ; ndx = 0 ; do { gr -> gr_mem = reallocf ( gr -> gr_mem , sizeof ( * gr -> gr_mem ) * ( ndx + 1 ) ) ; if ( gr -> gr_mem == NULL ) return ( false ) ; do { gr -> gr_mem [ ndx ] = strsep ( & line , " " ) ; } while ( gr -> gr_mem [ ndx ] != NULL && * gr -> gr_mem [ ndx ] == ' \0 ' ) ; } while ( gr -> gr_mem [ ndx ++ ] != NULL ) ; return ( true ) ; }
Scan a line and place it into a group structure.
Scan a line and place it into a group structure .
/* Assign non-member information to structure. */ /* Assign member information to structure. */ /* Skip locations without members (i.e., empty string). */