Mercurial > octave
annotate liboctave/system/oct-group.cc @ 27923:bd51beb6205e
update formatting of copyright notices
* Use <https://octave.org/copyright/> instead of
<https://octave.org/COPYRIGHT.html/>.
* For consistency with other comments in the Octave sources, use
C++-style comments for copyright blocks in C and C++ files.
* Use delimiters above and below copyright blocks that are appropriate
for the language used in the file.
* Eliminate extra spacing inside copyright blocks.
* lex.ll (looks_like_copyright): Also allow newlines and carriage
returns before the word "Copyright".
* scripts/mk-doc.pl (gethelp): Also skip empty comment lines.
* bp-table.cc, type.m: Adjust tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jan 2020 11:59:41 -0500 |
parents | 1891570abac8 |
children | 0a5b15007766 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1996-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2937 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
2937 | 28 #endif |
29 | |
30 #include <sys/types.h> | |
31 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
32 #if defined (HAVE_GRP_H) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
33 # include <grp.h> |
2937 | 34 #endif |
35 | |
36 #include "lo-error.h" | |
37 #include "oct-group.h" | |
38 #include "str-vec.h" | |
39 | |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21734
diff
changeset
|
40 #define NOT_SUPPORTED(nm) \ |
4062 | 41 nm ": not supported on this system" |
2937 | 42 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
43 OCTAVE_NORETURN static |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
44 void |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
45 err_invalid (void) |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
46 { |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
47 (*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
|
48 } |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
49 |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21728
diff
changeset
|
50 namespace octave |
2937 | 51 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21728
diff
changeset
|
52 namespace sys |
21728
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 std::string |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 group::name (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 err_invalid (); |
2937 | 59 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
60 return m_name; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
61 } |
2937 | 62 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 std::string |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 group::passwd (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
67 err_invalid (); |
2937 | 68 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
69 return m_passwd; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
70 } |
2937 | 71 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 gid_t |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 group::gid (void) const |
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 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
76 err_invalid (); |
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 return m_gid; |
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 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
81 string_vector |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
82 group::mem (void) const |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
83 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
84 if (! ok ()) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
85 err_invalid (); |
2937 | 86 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 return m_mem; |
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 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
91 group::getgrent (void) |
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 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
94 return getgrent (msg); |
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 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
97 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 group::getgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
99 { |
2937 | 100 #if defined (HAVE_GETGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
101 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
102 return group (::getgrent (), msg); |
2937 | 103 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 msg = NOT_SUPPORTED ("getgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
105 return group (); |
2937 | 106 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
107 } |
2937 | 108 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
109 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
110 group::getgrgid (gid_t gid) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
111 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
112 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 return getgrgid (gid, msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
114 } |
2937 | 115 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
116 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
117 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
|
118 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
119 #if defined (HAVE_GETGRGID) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
120 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
121 return group (::getgrgid (gid), msg); |
2937 | 122 #else |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
123 octave_unused_parameter (gid); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
124 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
125 msg = NOT_SUPPORTED ("getgruid"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
126 return group (); |
2937 | 127 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
128 } |
2937 | 129 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
130 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
131 group::getgrnam (const std::string& nm) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
132 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
133 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
134 return getgrnam (nm, msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
135 } |
2937 | 136 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
137 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
138 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
|
139 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
140 #if defined (HAVE_GETGRNAM) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
141 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
142 return group (::getgrnam (nm.c_str ()), msg); |
2937 | 143 #else |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
144 octave_unused_parameter (nm); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
145 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
146 msg = NOT_SUPPORTED ("getgrnam"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
147 return group (); |
2937 | 148 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
149 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
150 |
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 (void) |
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 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 return setgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
156 } |
2937 | 157 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
159 group::setgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
160 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
161 #if defined (HAVE_SETGRENT) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
162 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
163 ::setgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
164 return 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
165 #else |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
166 msg = NOT_SUPPORTED ("setgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
167 return -1; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
168 #endif |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
169 } |
2937 | 170 |
21728
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 (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
173 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
174 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 return endgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
176 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
177 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
178 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
179 group::endgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
180 { |
2937 | 181 #if defined (HAVE_ENDGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
182 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
183 ::endgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
184 return 0; |
2937 | 185 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
186 msg = NOT_SUPPORTED ("endgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
187 return -1; |
2937 | 188 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
189 } |
2937 | 190 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
191 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
|
192 : 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
|
193 { |
2937 | 194 #if defined (HAVE_GRP_H) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
195 msg = ""; |
2937 | 196 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
197 if (p) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
198 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
199 struct ::group *gr = static_cast<struct ::group *> (p); |
2937 | 200 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
201 m_name = gr->gr_name; |
2937 | 202 |
203 #if defined (HAVE_GR_PASSWD) | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
204 m_passwd = gr->gr_passwd; |
2937 | 205 #endif |
206 | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
207 m_gid = gr->gr_gid; |
4076 | 208 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
209 // 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
|
210 // 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
|
211 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
212 const char * const *tmp = gr->gr_mem; |
2937 | 213 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
214 int k = 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
215 while (*tmp++) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
216 k++; |
2937 | 217 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
218 if (k > 0) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
219 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
220 tmp = gr->gr_mem; |
2937 | 221 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
222 m_mem.resize (k); |
2937 | 223 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
224 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
|
225 m_mem[i] = tmp[i]; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
226 } |
2937 | 227 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
228 valid = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
229 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
230 #else |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
231 octave_unused_parameter (p); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
232 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
233 msg = NOT_SUPPORTED ("group functions"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
234 #endif |
2937 | 235 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
236 } |
2937 | 237 } |