* lib/getugroups.h: New file.
authorJim Meyering <jim@meyering.net>
Wed, 4 Jul 2007 21:46:44 +0000 (21:46 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 4 Jul 2007 21:46:44 +0000 (21:46 +0000)
* 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
lib/getugroups.c
lib/getugroups.h [new file with mode: 0644]
modules/getugroups

index 978103a..ffdb2c2 100644 (file)
--- 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
index 970192e..0293d27 100644 (file)
@@ -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 @@ 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 (file)
index 0000000..837bddc
--- /dev/null
@@ -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);
index 930f0bd..634a72b 100644 (file)
@@ -3,6 +3,7 @@ Return the group IDs of a user.
 
 Files:
 lib/getugroups.c
+lib/getugroups.h
 m4/getugroups.m4
 
 Depends-on: