Mercurial > hg > octave-kai > gnulib-hg
changeset 9043:c69012fcd861
* 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
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Wed, 04 Jul 2007 21:46:44 +0000 |
parents | ed4a80971dcd |
children | 20fba8637b7d |
files | ChangeLog lib/getugroups.c lib/getugroups.h modules/getugroups |
diffstat | 4 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +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
--- a/lib/getugroups.c +++ b/lib/getugroups.c @@ -1,7 +1,6 @@ /* 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 @@ -21,7 +20,8 @@ #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> @@ -49,11 +49,11 @@ 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) { @@ -65,6 +65,7 @@ setgrent (); while ((grp = getgrent ()) != 0) { + char **cp; for (cp = grp->gr_mem; *cp; ++cp) { int n;
new file mode 100644 --- /dev/null +++ b/lib/getugroups.h @@ -0,0 +1,21 @@ +/* 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);