Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

getgroups.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2002 by Martin Pool
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 /**
00020  * @file getgroups.c
00021  *
00022  * Print out the gids of all groups for the current user.  This is
00023  * like `id -G` on Linux, but it's too hard to find a portable
00024  * equivalent.
00025  **/
00026 
00027 #include "rsync.h"
00028 
00029 #ifndef NGROUPS
00030 /* It ought to be defined, but just in case. */
00031 #  define NGROUPS 32
00032 #endif
00033 
00034 int main(int argc, char *argv[])
00035 {
00036         int n, i;
00037         gid_t list[NGROUPS];
00038 
00039         if ((n = getgroups(NGROUPS, list)) == -1) {
00040                 perror("getgroups");
00041                 return 1;
00042         }
00043 
00044         for (i = 0; i < n; i++) 
00045                 printf("%u ", list[i]);
00046         printf("\n");
00047                 
00048         return 0;
00049 }

Generated on Tue Apr 16 12:37:36 2002 for rsync by doxygen1.2.15