From c471cb38f3b7a9011f58d585dbdb0057e7bbd331 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 4 Jul 2007 21:46:44 +0000 Subject: [PATCH] * 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 --- ChangeLog | 9 +++++++++ lib/getugroups.c | 13 +++++++------ lib/getugroups.h | 21 +++++++++++++++++++++ modules/getugroups | 1 + 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 lib/getugroups.h diff --git a/ChangeLog b/ChangeLog index 978103a56..ffdb2c23a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-07-04 Jim Meyering + + * 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 * MODULES.html.sh (func_all_modules): Complete rename of diff --git a/lib/getugroups.c b/lib/getugroups.c index 970192e67..0293d2785 100644 --- 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 -#include +#include "getugroups.h" + #include /* grp.h on alpha OSF1 V2.0 uses "FILE *". */ #include @@ -49,11 +49,11 @@ struct group *getgrent (); 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 @@ getugroups (int maxcount, GETGROUPS_T *grouplist, char *username, gid_t gid) setgrent (); while ((grp = getgrent ()) != 0) { + char **cp; for (cp = grp->gr_mem; *cp; ++cp) { int n; diff --git a/lib/getugroups.h b/lib/getugroups.h new file mode 100644 index 000000000..837bddc13 --- /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 +int getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username, + gid_t gid); diff --git a/modules/getugroups b/modules/getugroups index 930f0bd72..634a72b2a 100644 --- a/modules/getugroups +++ b/modules/getugroups @@ -3,6 +3,7 @@ Return the group IDs of a user. Files: lib/getugroups.c +lib/getugroups.h m4/getugroups.m4 Depends-on: -- 2.11.0