Mercurial > octave
annotate liboctave/system/oct-group.cc @ 21728:c218a5b31ad7
use namespace for system group wrapper class
* oct-group.h, oct-group.cc: Put group class in octave::sys
namespace. Change all uses.
(octave_group): Now a deprecated typedef for octave::sys::group.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 18 May 2016 12:35:37 -0400 |
parents | aba2e6293dd8 |
children | 11af9c03400c |
rev | line source |
---|---|
2937 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
2937 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2937 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2937 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
24 # include "config.h" |
2937 | 25 #endif |
26 | |
27 #include <sys/types.h> | |
28 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
29 #if defined (HAVE_GRP_H) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
30 # include <grp.h> |
2937 | 31 #endif |
32 | |
33 #include "lo-error.h" | |
34 #include "oct-group.h" | |
35 #include "str-vec.h" | |
36 | |
37 #define NOT_SUPPORTED(nm) \ | |
4062 | 38 nm ": not supported on this system" |
2937 | 39 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
40 OCTAVE_NORETURN static |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
41 void |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
42 err_invalid (void) |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
43 { |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
44 (*current_liboctave_error_handler) ("invalid group object"); |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
45 } |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
46 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
47 namespace |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
48 octave |
2937 | 49 { |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 namespace |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
51 sys |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
52 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 std::string |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
54 group::name (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 err_invalid (); |
2937 | 58 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
59 return m_name; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
60 } |
2937 | 61 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
62 std::string |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 group::passwd (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 err_invalid (); |
2937 | 67 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
68 return m_passwd; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
69 } |
2937 | 70 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 gid_t |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 group::gid (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
74 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
75 err_invalid (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
76 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
77 return m_gid; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
78 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
80 string_vector |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
81 group::mem (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
82 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
83 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
84 err_invalid (); |
2937 | 85 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
86 return m_mem; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
88 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
89 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 group::getgrent (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
91 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
92 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
93 return getgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
94 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
95 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
97 group::getgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 { |
2937 | 99 #if defined (HAVE_GETGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
100 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
101 return group (::getgrent (), msg); |
2937 | 102 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
103 msg = NOT_SUPPORTED ("getgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 return group (); |
2937 | 105 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
106 } |
2937 | 107 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
108 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
109 group::getgrgid (gid_t gid) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
110 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
111 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
112 return getgrgid (gid, msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 } |
2937 | 114 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
115 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
116 group::getgrgid (gid_t gid, std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
117 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
118 #if defined (HAVE_GETGRGID) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
119 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
120 return group (::getgrgid (gid), msg); |
2937 | 121 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
122 msg = NOT_SUPPORTED ("getgruid"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
123 return group (); |
2937 | 124 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
125 } |
2937 | 126 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
127 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
128 group::getgrnam (const std::string& nm) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
129 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
130 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
131 return getgrnam (nm, msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
132 } |
2937 | 133 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
134 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
135 group::getgrnam (const std::string& nm, std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
136 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
137 #if defined (HAVE_GETGRNAM) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
138 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
139 return group (::getgrnam (nm.c_str ()), msg); |
2937 | 140 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
141 msg = NOT_SUPPORTED ("getgrnam"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
142 return group (); |
2937 | 143 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
144 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
145 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
146 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
147 group::setgrent (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
148 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
149 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
150 return setgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
151 } |
2937 | 152 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
153 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
154 group::setgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
156 #if defined (HAVE_SETGRENT) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
157 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 ::setgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
159 return 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
160 #else |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
161 msg = NOT_SUPPORTED ("setgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
162 return -1; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
163 #endif |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
164 } |
2937 | 165 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
166 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
167 group::endgrent (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
168 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
169 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
170 return endgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
171 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
172 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
173 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
174 group::endgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 { |
2937 | 176 #if defined (HAVE_ENDGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
177 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
178 ::endgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
179 return 0; |
2937 | 180 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
181 msg = NOT_SUPPORTED ("endgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
182 return -1; |
2937 | 183 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
184 } |
2937 | 185 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
186 group::group (void *p, std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
187 : m_name (), m_passwd (), m_gid (0), m_mem (), valid (false) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
188 { |
2937 | 189 #if defined (HAVE_GRP_H) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
190 msg = ""; |
2937 | 191 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
192 if (p) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
193 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
194 struct ::group *gr = static_cast<struct ::group *> (p); |
2937 | 195 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
196 m_name = gr->gr_name; |
2937 | 197 |
198 #if defined (HAVE_GR_PASSWD) | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
199 m_passwd = gr->gr_passwd; |
2937 | 200 #endif |
201 | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
202 m_gid = gr->gr_gid; |
4076 | 203 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
204 // FIXME: Maybe there should be a string_vector constructor |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
205 // that takes a NUL terminated list of C strings? |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
206 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
207 const char * const *tmp = gr->gr_mem; |
2937 | 208 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
209 int k = 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
210 while (*tmp++) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
211 k++; |
2937 | 212 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
213 if (k > 0) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
214 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
215 tmp = gr->gr_mem; |
2937 | 216 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
217 m_mem.resize (k); |
2937 | 218 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
219 for (int i = 0; i < k; i++) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
220 m_mem[i] = tmp[i]; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
221 } |
2937 | 222 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
223 valid = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
224 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
225 #else |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
226 msg = NOT_SUPPORTED ("group functions"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
227 #endif |
2937 | 228 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
229 } |
2937 | 230 } |