Mercurial > octave
annotate liboctave/system/oct-group.cc @ 24118:f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
* sighandlers.cc (w32_interrupt_manager::do_jump_to_enclosing_context): Use
reinterpret_cast to silence compiler warning from -Wold-style-cast.
* welcome-wizard.cc (welcome_wizard::welcome_wizard): Likewise.
* oct-procbuf.cc (octave_procbuf_list): Only define on systems that use it to
silence compiler warning from -Wunused-variable.
* sysdep.cc (w32_shell_execute): Delete empty unused function to silence several
compiler warnings. (raw_mode): Use octave_unused_parameter to silence compiler
warnings from -Wunused-parameter on certain systems.
* cdisplay.c (octave_get_display_info): Use octave_unused_parameter to silence
compiler warning from -Wunused-parameter on certain systems.
* oct-group.cc (octave::sys::group::getgrgid, octave::sys::group::getgrnam,
octave::sys::group::group): Likewise.
* oct-passwd.cc (octave::sys::password::getpwuid,
octave::sys::password::getpwnam, octave::sys::password::password): Likewise.
* signal-wrappers.c (octave_kill_wrapper, block_or_unblock_signal): Likewise.
* wait-for-input.c (octave_wait_for_input): Likewise.
* unistd-wrappers.c (prepare_spawn): Add const-qualifier on argument to silence
compiler warning from -Wdiscarded-qualifiers.
* stat-wrappers.c: Use pragma to disable -Wunused-parameter warnings for wrapper
functions around macros that may discard their arguments on certain systems.
* wait-wrappers.c Use pragma to disable -Wunused-parameter warnings for wrapper
functions around macros that may discard their arguments on certain systems.
Reorder functions to group related wrappers.
(octave_waitpid_wrapper): Use octave_unused_parameter to silence compiler
warning from -Wunused-parameter on certain systems.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sun, 01 Oct 2017 14:52:33 -0700 |
parents | 092078913d54 |
children | 194eb4bd202b |
rev | line source |
---|---|
2937 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 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 | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
10 (at your option) any later version. |
2937 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 GNU General Public License for more details. |
2937 | 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 |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
120 octave_unused_parameter (gid); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
121 |
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 |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
141 octave_unused_parameter (nm); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
142 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
143 msg = NOT_SUPPORTED ("getgrnam"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
144 return group (); |
2937 | 145 #endif |
21728
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 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
148 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
149 group::setgrent (void) |
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 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
152 return setgrent (msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
153 } |
2937 | 154 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
156 group::setgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
157 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 #if defined (HAVE_SETGRENT) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
159 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
160 ::setgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
161 return 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
162 #else |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
163 msg = NOT_SUPPORTED ("setgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
164 return -1; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
165 #endif |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
166 } |
2937 | 167 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
168 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
169 group::endgrent (void) |
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 std::string msg; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
172 return endgrent (msg); |
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 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 int |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
176 group::endgrent (std::string& msg) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
177 { |
2937 | 178 #if defined (HAVE_ENDGRENT) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
179 msg = ""; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
180 ::endgrent (); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
181 return 0; |
2937 | 182 #else |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
183 msg = NOT_SUPPORTED ("endgrent"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
184 return -1; |
2937 | 185 #endif |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
186 } |
2937 | 187 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
188 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
|
189 : 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
|
190 { |
2937 | 191 #if defined (HAVE_GRP_H) |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
192 msg = ""; |
2937 | 193 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
194 if (p) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
195 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
196 struct ::group *gr = static_cast<struct ::group *> (p); |
2937 | 197 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
198 m_name = gr->gr_name; |
2937 | 199 |
200 #if defined (HAVE_GR_PASSWD) | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
201 m_passwd = gr->gr_passwd; |
2937 | 202 #endif |
203 | |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
204 m_gid = gr->gr_gid; |
4076 | 205 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
206 // 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
|
207 // 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
|
208 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
209 const char * const *tmp = gr->gr_mem; |
2937 | 210 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
211 int k = 0; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
212 while (*tmp++) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
213 k++; |
2937 | 214 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
215 if (k > 0) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
216 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
217 tmp = gr->gr_mem; |
2937 | 218 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
219 m_mem.resize (k); |
2937 | 220 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
221 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
|
222 m_mem[i] = tmp[i]; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
223 } |
2937 | 224 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
225 valid = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
226 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
227 #else |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
228 octave_unused_parameter (p); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
229 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
230 msg = NOT_SUPPORTED ("group functions"); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
231 #endif |
2937 | 232 } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
233 } |
2937 | 234 } |