dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libast / common / comp / getgroups.c
blob33712c5fc86a6dd42835d854f0f5c5de80c5fa28
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
24 #include <ast.h>
26 #if !defined(getgroups) && defined(_lib_getgroups)
28 NoN(getgroups)
30 #else
32 #include <error.h>
34 #if defined(getgroups)
35 #undef getgroups
36 #define ast_getgroups _ast_getgroups
37 #define botched 1
38 extern int getgroups(int, int*);
39 #else
40 #define ast_getgroups getgroups
41 #endif
43 #if defined(__EXPORT__)
44 #define extern __EXPORT__
45 #endif
47 extern int
48 ast_getgroups(int len, gid_t* set)
50 #if botched
51 #if NGROUPS_MAX < 1
52 #undef NGROUPS_MAX
53 #define NGROUPS_MAX 1
54 #endif
55 register int i;
56 int big[NGROUPS_MAX];
57 #else
58 #undef NGROUPS_MAX
59 #define NGROUPS_MAX 1
60 #endif
61 if (!len) return(NGROUPS_MAX);
62 if (len < 0 || !set)
64 errno = EINVAL;
65 return(-1);
67 #if botched
68 len = getgroups(len > NGROUPS_MAX ? NGROUPS_MAX : len, big);
69 for (i = 0; i < len; i++)
70 set[i] = big[i];
71 return(len);
72 #else
73 *set = getgid();
74 return(1);
75 #endif
78 #endif