// Code generated by cmd/cgo; DO NOT EDIT.

//line /home/abuild/rpmbuild/BUILD/go/src/os/user/getgrouplist_unix.go:1:1
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build dragonfly freebsd !android,linux netbsd openbsd
// +build cgo,!osusergo

package user

/*
#include <unistd.h>
#include <sys/types.h>
#include <grp.h>

static int mygetgrouplist(const char* user, gid_t group, gid_t* groups, int* ngroups) {
	return getgrouplist(user, group, groups, ngroups);
}
*/
import _ "unsafe"
import (
	"fmt"
	"unsafe"
)

func getGroupList(name * /*line :25:25*/_Ctype_char /*line :25:31*/, userGID  /*line :25:41*/_Ctype_gid_t /*line :25:48*/, gids * /*line :25:56*/_Ctype_gid_t /*line :25:63*/, n * /*line :25:68*/_Ctype_int /*line :25:73*/)  /*line :25:75*/_Ctype_int /*line :25:80*/ {
	return ( /*line :26:9*/_Cfunc_mygetgrouplist /*line :26:24*/)(name, userGID, gids, n)
}

// groupRetry retries getGroupList with much larger size for n. The result is
// stored in gids.
func groupRetry(username string, name []byte, userGID  /*line :31:55*/_Ctype_gid_t /*line :31:62*/, gids *[] /*line :31:72*/_Ctype_gid_t /*line :31:79*/, n * /*line :31:84*/_Ctype_int /*line :31:89*/) error {
	// More than initial buffer, but now n contains the correct size.
	if *n > maxGroups {
		return fmt.Errorf("user: %q is a member of more than %d groups", username, maxGroups)
	}
	*gids = make([] /*line :36:17*/_Ctype_gid_t /*line :36:24*/, *n)
	rv := getGroupList((* /*line :37:23*/_Ctype_char /*line :37:29*/)(unsafe.Pointer(&name[0])), userGID, &(*gids)[0], n)
	if rv == -1 {
		return fmt.Errorf("user: list groups for %s failed", username)
	}
	return nil
}
