* lib/getugroups.c: Include "getugroups.h".
Remove uses of "register" keyword.
Move local variable, "cp", down into scope where used.
Give "username" parameter the "const" attribute.
* modules/getugroups (Files): Add lib/getugroups.h
+2007-07-04 Jim Meyering <jim@meyering.net>
+
+ * lib/getugroups.h: New file.
+ * lib/getugroups.c: Include "getugroups.h".
+ Remove uses of "register" keyword.
+ Move local variable, "cp", down into scope where used.
+ Give "username" parameter the "const" attribute.
+ * modules/getugroups (Files): Add lib/getugroups.h
+
2007-07-04 Karl Berry <karl@gnu.org>
* MODULES.html.sh (func_all_modules): Complete rename of
/* getugroups.c -- return a list of the groups a user is in
- Copyright (C) 1990, 1991, 1998, 1999, 2000, 2003, 2004, 2005, 2006
- Free Software Foundation.
+ Copyright (C) 1990, 1991, 1998-2000, 2003-2007 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <config.h>
-#include <sys/types.h>
+#include "getugroups.h"
+
#include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */
#include <grp.h>
Always return the number of groups of which USERNAME is a member. */
int
-getugroups (int maxcount, GETGROUPS_T *grouplist, char *username, gid_t gid)
+getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username,
+ gid_t gid)
{
struct group *grp;
- register char **cp;
- register int count = 0;
+ int count = 0;
if (gid != (gid_t) -1)
{
setgrent ();
while ((grp = getgrent ()) != 0)
{
+ char **cp;
for (cp = grp->gr_mem; *cp; ++cp)
{
int n;
--- /dev/null
+/* Get a list of group IDs associated with a specified user ID.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <sys/types.h>
+int getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username,
+ gid_t gid);
Files:
lib/getugroups.c
+lib/getugroups.h
m4/getugroups.m4
Depends-on: