parsegid(const char *s, gid_t *gid)
{
	struct group *gr;
	#if !defined(__linux__) && !defined(__NetBSD__)
	const char *errstr = NULL;
        #else
        int status;
        #endif

	if ((gr = getgrnam(s)) != NULL) {
		*gid = gr->gr_gid;
		return 0;
	}
	#if !defined(__linux__) && !defined(__NetBSD__)
	*gid = strtonum(s, 0, GID_MAX, &errstr);
	if (errstr)
		return -1;
	#else
	status = sscanf(s, "%d", gid);
        if (status != 1)
            return -1;
	#endif
	return 0;
}
parsegid(const char *s, gid_t *gid)
{
	struct group *gr;
	#if !defined(__linux__) && !defined(__NetBSD__)
	const char *errstr = NULL;
        #else
        int status;
        #endif

	if ((gr = getgrnam(s)) != NULL) {
		*gid = gr->gr_gid;
		return 0;
	}
	#if !defined(__linux__) && !defined(__NetBSD__)
	*gid = strtonum(s, 0, GID_MAX, &errstr);
	if (errstr)
		return -1;
	#else
	status = sscanf(s, "%d", gid);
        if (status != 1)
            return -1;
	#endif
	return 0;
}