Mercurial > hg > octave-nkf > gnulib-hg
comparison lib/getugroups.c @ 5159:a535859efd14
Merge from coreutils.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 07 Aug 2004 00:09:38 +0000 |
parents | a4086e076f77 |
children | a48fb0e98c8c |
comparison
equal
deleted
inserted
replaced
5158:c710d6c89900 | 5159:a535859efd14 |
---|---|
1 /* getugroups.c -- return a list of the groups a user is in | 1 /* getugroups.c -- return a list of the groups a user is in |
2 Copyright (C) 1990, 1991, 1998, 1999, 2000, 2003 Free Software Foundation. | 2 |
3 Copyright (C) 1990, 1991, 1998, 1999, 2000, 2003, 2004 Free | |
4 Software Foundation. | |
3 | 5 |
4 This program is free software; you can redistribute it and/or modify | 6 This program is free software; you can redistribute it and/or modify |
5 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
6 the Free Software Foundation; either version 2, or (at your option) | 8 the Free Software Foundation; either version 2, or (at your option) |
7 any later version. | 9 any later version. |
25 #include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */ | 27 #include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */ |
26 #include <grp.h> | 28 #include <grp.h> |
27 | 29 |
28 #ifdef HAVE_UNISTD_H | 30 #ifdef HAVE_UNISTD_H |
29 # include <unistd.h> | 31 # include <unistd.h> |
32 #endif | |
33 | |
34 #include <errno.h> | |
35 #ifndef EOVERFLOW | |
36 # define EOVERFLOW EINVAL | |
30 #endif | 37 #endif |
31 | 38 |
32 /* setgrent, getgrent, and endgrent are not specified by POSIX.1, | 39 /* setgrent, getgrent, and endgrent are not specified by POSIX.1, |
33 so header files might not declare them. | 40 so header files might not declare them. |
34 If you don't have them at all, we can't implement this function. | 41 If you don't have them at all, we can't implement this function. |
86 return count; | 93 return count; |
87 } | 94 } |
88 grouplist[count] = grp->gr_gid; | 95 grouplist[count] = grp->gr_gid; |
89 } | 96 } |
90 count++; | 97 count++; |
98 if (count < 0) | |
99 { | |
100 errno = EOVERFLOW; | |
101 return -1; | |
102 } | |
91 } | 103 } |
92 } | 104 } |
93 } | 105 } |
94 endgrent (); | 106 endgrent (); |
95 | 107 |