<commit_before>package styxauth

/*
#include <sys/types.h>
#include <grp.h>
*/
import "C"
import (
	"fmt"
	"strconv"
	"syscall"
	"unsafe"
)

// helper function to resolve a group name to gid
func lookupGid(name string) (string, error) {
	var (
		bufSize C.long
		rv      C.int
		grp     C.struct_group
		result  *C.struct_group
	)

	bufSize := C.sysconf(C._SC_GETGR_R_SIZE_MAX)
	if bufSize < 0 {
		// FreeBSD doesn't have _SC_GETPW_R_SIZE_MAX
		// or SC_GETGR_R_SIZE_MAX and just returns -1.
		// So just use the same size that Linux returns
		bufSize = 1024
	}
	buf := C.malloc(C.size_t(bufSize))
	defer C.free(buf)

	nameC := C.CString(name)
	defer C.free(unsafe.Pointer(nameC))

	rv = C.getrnam_r(nameC, &grp, (*C.char)(buf), C.size_t(bufSize), &result)
	if rv != 0 {
		return "", fmt.Errorf("lookup group %s: %s", name, syscall.Errno(rv))
	}
	if result == nil {
		return "", fmt.Errorf("unknown group %s", name)
	}

	return strconv.Itoa(int(grp.gr_id)), nil
}<commit_msg>correct missing C imports and identifier typos<commit_after>package styxauth

/*
#include <sys/types.h>
#include <grp.h>
#include <unistd.h>
#include <stdlib.h>
*/
import "C"
import (
	"fmt"
	"strconv"
	"syscall"
	"unsafe"
)

// helper function to resolve a group name to gid
func lookupGid(name string) (string, error) {
	var (
		bufSize C.long
		rv      C.int
		grp     C.struct_group
		result  *C.struct_group
	)

	bufSize := C.sysconf(C._SC_GETGR_R_SIZE_MAX)
	if bufSize < 0 {
		// FreeBSD doesn't have _SC_GETPW_R_SIZE_MAX
		// or SC_GETGR_R_SIZE_MAX and just returns -1.
		// So just use the same size that Linux returns
		bufSize = 1024
	}
	buf := C.malloc(C.size_t(bufSize))
	defer C.free(buf)

	nameC := C.CString(name)
	defer C.free(unsafe.Pointer(nameC))

	rv = C.getgrnam_r(nameC, &grp, (*C.char)(buf), C.size_t(bufSize), &result)
	if rv != 0 {
		return "", fmt.Errorf("lookup group %s: %s", name, syscall.Errno(rv))
	}
	if result == nil {
		return "", fmt.Errorf("unknown group %s", name)
	}

	return strconv.Itoa(int(grp.gr_gid)), nil
}
{'fraction_non_alphanumeric': 0.14716049382716048, 'fraction_numerical': 0.006913580246913581, 'mean_word_length': 3.5941043083900226, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5181975', 'n_tokens_mistral': 876, 'n_tokens_neox': 820, 'n_words': 204}