annotate liboctave/system/oct-passwd.cc @ 21734:11af9c03400c

write namespace keyword and name on same line in C++ files
author John W. Eaton <jwe@octave.org>
date Thu, 19 May 2016 01:00:37 -0400
parents 815b2f500fab
children e43d83253e28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
1 /*
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
3 Copyright (C) 1996-2015 John W. Eaton
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
4
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
6
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
10 option) any later version.
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
11
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
15 for more details.
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
16
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
19 <http://www.gnu.org/licenses/>.
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
20
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
21 */
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
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"
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
25 #endif
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
26
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
27 #include <sys/types.h>
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
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_PWD_H)
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 21102
diff changeset
30 # include <pwd.h>
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
31 #endif
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
32
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
33 #include "lo-error.h"
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
34 #include "oct-passwd.h"
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
35
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
36 #define NOT_SUPPORTED(nm) \
4062
86e4baa81410 [project @ 2002-09-23 15:38:05 by jwe]
jwe
parents: 3504
diff changeset
37 nm ": not supported on this system"
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
38
21102
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
39 OCTAVE_NORETURN static
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
40 void
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
41 err_invalid (void)
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
42 {
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
43 (*current_liboctave_error_handler) ("invalid password object");
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
44 }
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21017
diff changeset
45
21734
11af9c03400c write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents: 21729
diff changeset
46 namespace octave
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
47 {
21734
11af9c03400c write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents: 21729
diff changeset
48 namespace sys
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
49 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
50 std::string
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
51 password::name (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
52 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
53 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
54 err_invalid ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
55
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
56 return m_name;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
57 }
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
58
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
59 std::string
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
60 password::passwd (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
61 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
62 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
63 err_invalid ();
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
64
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
65 return m_passwd;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
66 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
67
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
68 uid_t
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
69 password::uid (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
70 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
71 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
72 err_invalid ();
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
73
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
74 return m_uid;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
75 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
76
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
77 gid_t
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
78 password::gid (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
79 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
80 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
81 err_invalid ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
82
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
83 return m_gid;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
84 }
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
85
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
86 std::string
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
87 password::gecos (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
88 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
89 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
90 err_invalid ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
91
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
92 return m_gecos;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
93 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
94
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
95 std::string
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
96 password::dir (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
97 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
98 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
99 err_invalid ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
100
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
101 return m_dir;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
102 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
103
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
104 std::string
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
105 password::shell (void) const
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
106 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
107 if (! ok ())
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
108 err_invalid ();
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
109
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
110 return m_shell;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
111 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
112
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
113 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
114 password::getpwent (void)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
115 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
116 std::string msg;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
117 return getpwent (msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
118 }
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
119
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
120 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
121 password::getpwent (std::string& msg)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
122 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
123 #if defined HAVE_GETPWENT
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
124 msg = "";
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
125 return password (::getpwent (), msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
126 #else
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
127 msg = NOT_SUPPORTED ("getpwent");
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
128 return password ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
129 #endif
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
130 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
131
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
132 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
133 password::getpwuid (uid_t uid)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
134 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
135 std::string msg;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
136 return getpwuid (uid, msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
137 }
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
138
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
139 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
140 password::getpwuid (uid_t uid, std::string& msg)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
141 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
142 #if defined (HAVE_GETPWUID)
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
143 msg = "";
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
144 return password (::getpwuid (uid), msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
145 #else
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
146 msg = NOT_SUPPORTED ("getpwuid");
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
147 return password ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
148 #endif
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
149 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
150
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
151 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
152 password::getpwnam (const std::string& nm)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
153 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
154 std::string msg;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
155 return getpwnam (nm, msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
156 }
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
157
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
158 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
159 password::getpwnam (const std::string& nm, std::string& msg)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
160 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
161 #if defined (HAVE_GETPWNAM)
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
162 msg = "";
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
163 return password (::getpwnam (nm.c_str ()), msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
164 #else
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
165 msg = NOT_SUPPORTED ("getpwnam");
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
166 return password ();
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
167 #endif
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
168 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
169
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
170 int
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
171 password::setpwent (void)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
172 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
173 std::string msg;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
174 return setpwent (msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
175 }
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
176
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
177 int
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
178 password::setpwent (std::string& msg)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
179 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
180 #if defined (HAVE_SETPWENT)
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
181 msg = "";
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
182 ::setpwent ();
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
183 return 0;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
184 #else
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
185 msg = NOT_SUPPORTED ("setpwent");
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
186 return -1;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
187 #endif
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
188 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
189
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
190 int
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
191 password::endpwent (void)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
192 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
193 std::string msg;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
194 return endpwent (msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
195 }
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
196
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
197 int
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
198 password::endpwent (std::string& msg)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
199 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
200 #if defined (HAVE_ENDPWENT)
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
201 msg = "";
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
202 ::endpwent ();
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
203 return 0;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
204 #else
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
205 msg = NOT_SUPPORTED ("endpwent");
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
206 return -1;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
207 #endif
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
208 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
209
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
210 password::password (void *p, std::string& msg)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
211 : m_name (), m_passwd (), m_uid (0), m_gid (0), m_gecos (),
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
212 m_dir (), m_shell (), valid (false)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
213 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
214 #if defined (HAVE_PWD_H)
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
215 msg = "";
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
216
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
217 if (p)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
218 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
219 struct ::passwd *pw = static_cast<struct ::passwd *> (p);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
220
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
221 m_name = pw->pw_name;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
222 m_passwd = pw->pw_passwd;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
223 m_uid = pw->pw_uid;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
224 m_gid = pw->pw_gid;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
225 m_gecos = pw->pw_gecos;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
226 m_dir = pw->pw_dir;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
227 m_shell = pw->pw_shell;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
228
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
229 valid = true;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
230 }
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
231 #else
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
232 msg = NOT_SUPPORTED ("password functions");
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
233 #endif
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
234 }
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
235 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
236 }