Mercurial > octave
annotate liboctave/system/oct-group.cc @ 22197:e43d83253e28
refill multi-line macro definitions
Use the Emacs C++ mode style for line continuation markers in
multi-line macro definitions.
* make_int.cc, __dsearchn__.cc, __magick_read__.cc, besselj.cc,
bitfcns.cc, bsxfun.cc, cellfun.cc, data.cc, defun-dld.h, defun-int.h,
defun.h, det.cc, error.h, find.cc, gcd.cc, graphics.cc, interpreter.h,
jit-ir.h, jit-typeinfo.h, lookup.cc, ls-mat5.cc, max.cc, mexproto.h,
mxarray.in.h, oct-stream.cc, ordschur.cc, pr-output.cc, profiler.h,
psi.cc, regexp.cc, sparse-xdiv.cc, sparse-xpow.cc, tril.cc, txt-eng.h,
utils.cc, variables.cc, variables.h, xdiv.cc, xpow.cc, __glpk__.cc,
ov-base.cc, ov-base.h, ov-cell.cc, ov-ch-mat.cc, ov-classdef.cc,
ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-float.cc, ov-float.h,
ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc,
ov-int-traits.h, ov-lazy-idx.h, ov-perm.cc, ov-re-mat.cc,
ov-re-sparse.cc, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc,
ov-type-conv.h, ov.cc, ov.h, op-class.cc, op-int-conv.cc, op-int.h,
op-str-str.cc, ops.h, lex.ll, Array.cc, CMatrix.cc, CSparse.cc,
MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse.h,
Sparse.cc, dMatrix.cc, dSparse.cc, fCMatrix.cc, fMatrix.cc,
idx-vector.cc, f77-fcn.h, quit.h, bsxfun-decl.h, bsxfun-defs.cc,
lo-specfun.cc, oct-convn.cc, oct-convn.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, Sparse-op-decls.h, Sparse-op-defs.h, mx-inlines.cc,
mx-op-decl.h, mx-op-defs.h, mach-info.cc, oct-group.cc, oct-passwd.cc,
oct-syscalls.cc, oct-time.cc, data-conv.cc, kpse.cc, lo-ieee.h,
lo-macros.h, oct-cmplx.h, oct-glob.cc, oct-inttypes.cc,
oct-inttypes.h, oct-locbuf.h, oct-sparse.h, url-transfer.cc,
oct-conf-post.in.h, shared-fcns.h: Refill macro definitions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Aug 2016 12:40:18 -0400 |
parents | 11af9c03400c |
children | bac0d6f07a3e |
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 | |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21734
diff
changeset
|
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 |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21728
diff
changeset
|
47 namespace octave |
2937 | 48 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21728
diff
changeset
|
49 namespace sys |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
51 std::string |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
52 group::name (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
54 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 err_invalid (); |
2937 | 56 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 return m_name; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 } |
2937 | 59 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
60 std::string |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
61 group::passwd (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
62 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 err_invalid (); |
2937 | 65 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 return m_passwd; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
67 } |
2937 | 68 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
69 gid_t |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
70 group::gid (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 err_invalid (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
74 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
75 return m_gid; |
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 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
78 string_vector |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 group::mem (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
80 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
81 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
82 err_invalid (); |
2937 | 83 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
84 return m_mem; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
85 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
86 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
88 group::getgrent (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
89 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
91 return getgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
92 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
93 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
94 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
95 group::getgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 { |
2937 | 97 #if defined (HAVE_GETGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
99 return group (::getgrent (), msg); |
2937 | 100 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
101 msg = NOT_SUPPORTED ("getgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
102 return group (); |
2937 | 103 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 } |
2937 | 105 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
106 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
107 group::getgrgid (gid_t gid) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
108 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
109 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
110 return getgrgid (gid, msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
111 } |
2937 | 112 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
114 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
|
115 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
116 #if defined (HAVE_GETGRGID) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
117 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
118 return group (::getgrgid (gid), msg); |
2937 | 119 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
120 msg = NOT_SUPPORTED ("getgruid"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
121 return group (); |
2937 | 122 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
123 } |
2937 | 124 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
125 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
126 group::getgrnam (const std::string& nm) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
127 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
128 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
129 return getgrnam (nm, msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
130 } |
2937 | 131 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
132 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
133 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
|
134 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
135 #if defined (HAVE_GETGRNAM) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
136 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
137 return group (::getgrnam (nm.c_str ()), msg); |
2937 | 138 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
139 msg = NOT_SUPPORTED ("getgrnam"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
140 return group (); |
2937 | 141 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
142 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
143 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
144 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
145 group::setgrent (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
146 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
147 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
148 return setgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
149 } |
2937 | 150 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
151 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
152 group::setgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
153 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
154 #if defined (HAVE_SETGRENT) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
156 ::setgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
157 return 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 #else |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
159 msg = NOT_SUPPORTED ("setgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
160 return -1; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
161 #endif |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
162 } |
2937 | 163 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
164 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
165 group::endgrent (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
166 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
167 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
168 return endgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
169 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
170 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
171 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
172 group::endgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
173 { |
2937 | 174 #if defined (HAVE_ENDGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
176 ::endgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
177 return 0; |
2937 | 178 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
179 msg = NOT_SUPPORTED ("endgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
180 return -1; |
2937 | 181 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
182 } |
2937 | 183 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
184 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
|
185 : 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
|
186 { |
2937 | 187 #if defined (HAVE_GRP_H) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
188 msg = ""; |
2937 | 189 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
190 if (p) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
191 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
192 struct ::group *gr = static_cast<struct ::group *> (p); |
2937 | 193 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
194 m_name = gr->gr_name; |
2937 | 195 |
196 #if defined (HAVE_GR_PASSWD) | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
197 m_passwd = gr->gr_passwd; |
2937 | 198 #endif |
199 | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
200 m_gid = gr->gr_gid; |
4076 | 201 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
202 // 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
|
203 // 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
|
204 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
205 const char * const *tmp = gr->gr_mem; |
2937 | 206 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
207 int k = 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
208 while (*tmp++) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
209 k++; |
2937 | 210 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
211 if (k > 0) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
212 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
213 tmp = gr->gr_mem; |
2937 | 214 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
215 m_mem.resize (k); |
2937 | 216 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
217 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
|
218 m_mem[i] = tmp[i]; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
219 } |
2937 | 220 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
221 valid = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
222 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
223 #else |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
224 msg = NOT_SUPPORTED ("group functions"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
225 #endif |
2937 | 226 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
227 } |
2937 | 228 } |