comparison liboctave/oct-passwd.cc @ 3504:5eef8a2294bd

[project @ 2000-02-01 10:06:51 by jwe]
author jwe
date Tue, 01 Feb 2000 10:07:26 +0000
parents 9d26524e2869
children 86e4baa81410
comparison
equal deleted inserted replaced
3503:d14c483b3c12 3504:5eef8a2294bd
36 #include "oct-passwd.h" 36 #include "oct-passwd.h"
37 37
38 #define NOT_SUPPORTED(nm) \ 38 #define NOT_SUPPORTED(nm) \
39 nm ## ": not supported on this system" 39 nm ## ": not supported on this system"
40 40
41 string 41 std::string
42 octave_passwd::name (void) const 42 octave_passwd::name (void) const
43 { 43 {
44 if (! ok ()) 44 if (! ok ())
45 gripe_invalid (); 45 gripe_invalid ();
46 46
47 return pw_name; 47 return pw_name;
48 } 48 }
49 49
50 string 50 std::string
51 octave_passwd::passwd (void) const 51 octave_passwd::passwd (void) const
52 { 52 {
53 if (! ok ()) 53 if (! ok ())
54 gripe_invalid (); 54 gripe_invalid ();
55 55
72 gripe_invalid (); 72 gripe_invalid ();
73 73
74 return pw_gid; 74 return pw_gid;
75 } 75 }
76 76
77 string 77 std::string
78 octave_passwd::gecos (void) const 78 octave_passwd::gecos (void) const
79 { 79 {
80 if (! ok ()) 80 if (! ok ())
81 gripe_invalid (); 81 gripe_invalid ();
82 82
83 return pw_gecos; 83 return pw_gecos;
84 } 84 }
85 85
86 string 86 std::string
87 octave_passwd::dir (void) const 87 octave_passwd::dir (void) const
88 { 88 {
89 if (! ok ()) 89 if (! ok ())
90 gripe_invalid (); 90 gripe_invalid ();
91 91
92 return pw_dir; 92 return pw_dir;
93 } 93 }
94 94
95 string 95 std::string
96 octave_passwd::shell (void) const 96 octave_passwd::shell (void) const
97 { 97 {
98 if (! ok ()) 98 if (! ok ())
99 gripe_invalid (); 99 gripe_invalid ();
100 100
102 } 102 }
103 103
104 octave_passwd 104 octave_passwd
105 octave_passwd::getpwent (void) 105 octave_passwd::getpwent (void)
106 { 106 {
107 string msg; 107 std::string msg;
108 return getpwent (msg); 108 return getpwent (msg);
109 } 109 }
110 110
111 octave_passwd 111 octave_passwd
112 octave_passwd::getpwent (string& msg) 112 octave_passwd::getpwent (std::string& msg)
113 { 113 {
114 #if defined HAVE_GETPWENT 114 #if defined HAVE_GETPWENT
115 msg = string (); 115 msg = std::string ();
116 return octave_passwd (::getpwent (), msg); 116 return octave_passwd (::getpwent (), msg);
117 #else 117 #else
118 msg = NOT_SUPPORTED ("getpwent"); 118 msg = NOT_SUPPORTED ("getpwent");
119 return octave_passwd (); 119 return octave_passwd ();
120 #endif 120 #endif
121 } 121 }
122 122
123 octave_passwd 123 octave_passwd
124 octave_passwd::getpwuid (uid_t uid) 124 octave_passwd::getpwuid (uid_t uid)
125 { 125 {
126 string msg; 126 std::string msg;
127 return getpwuid (uid, msg); 127 return getpwuid (uid, msg);
128 } 128 }
129 129
130 octave_passwd 130 octave_passwd
131 octave_passwd::getpwuid (uid_t uid, string& msg) 131 octave_passwd::getpwuid (uid_t uid, std::string& msg)
132 { 132 {
133 #if defined (HAVE_GETPWUID) 133 #if defined (HAVE_GETPWUID)
134 msg = string (); 134 msg = std::string ();
135 return octave_passwd (::getpwuid (uid), msg); 135 return octave_passwd (::getpwuid (uid), msg);
136 #else 136 #else
137 msg = NOT_SUPPORTED ("getpwuid"); 137 msg = NOT_SUPPORTED ("getpwuid");
138 return octave_passwd (); 138 return octave_passwd ();
139 #endif 139 #endif
140 } 140 }
141 141
142 octave_passwd 142 octave_passwd
143 octave_passwd::getpwnam (const string& nm) 143 octave_passwd::getpwnam (const std::string& nm)
144 { 144 {
145 string msg; 145 std::string msg;
146 return getpwnam (nm, msg); 146 return getpwnam (nm, msg);
147 } 147 }
148 148
149 octave_passwd 149 octave_passwd
150 octave_passwd::getpwnam (const string& nm, string& msg) 150 octave_passwd::getpwnam (const std::string& nm, std::string& msg)
151 { 151 {
152 #if defined (HAVE_GETPWNAM) 152 #if defined (HAVE_GETPWNAM)
153 msg = string (); 153 msg = std::string ();
154 return octave_passwd (::getpwnam (nm.c_str ()), msg); 154 return octave_passwd (::getpwnam (nm.c_str ()), msg);
155 #else 155 #else
156 msg = NOT_SUPPORTED ("getpwnam"); 156 msg = NOT_SUPPORTED ("getpwnam");
157 return octave_passwd (); 157 return octave_passwd ();
158 #endif 158 #endif
159 } 159 }
160 160
161 int 161 int
162 octave_passwd::setpwent (void) 162 octave_passwd::setpwent (void)
163 { 163 {
164 string msg; 164 std::string msg;
165 return setpwent (msg); 165 return setpwent (msg);
166 } 166 }
167 167
168 int 168 int
169 octave_passwd::setpwent (string& msg) 169 octave_passwd::setpwent (std::string& msg)
170 { 170 {
171 #if defined (HAVE_SETPWENT) 171 #if defined (HAVE_SETPWENT)
172 msg = string (); 172 msg = std::string ();
173 ::setpwent (); 173 ::setpwent ();
174 return 0; 174 return 0;
175 #else 175 #else
176 msg = NOT_SUPPORTED ("setpwent"); 176 msg = NOT_SUPPORTED ("setpwent");
177 return -1; 177 return -1;
179 } 179 }
180 180
181 int 181 int
182 octave_passwd::endpwent (void) 182 octave_passwd::endpwent (void)
183 { 183 {
184 string msg; 184 std::string msg;
185 return endpwent (msg); 185 return endpwent (msg);
186 } 186 }
187 187
188 int 188 int
189 octave_passwd::endpwent (string& msg) 189 octave_passwd::endpwent (std::string& msg)
190 { 190 {
191 #if defined (HAVE_ENDPWENT) 191 #if defined (HAVE_ENDPWENT)
192 msg = string (); 192 msg = std::string ();
193 ::endpwent (); 193 ::endpwent ();
194 return 0; 194 return 0;
195 #else 195 #else
196 msg = NOT_SUPPORTED ("endpwent"); 196 msg = NOT_SUPPORTED ("endpwent");
197 return -1; 197 return -1;
198 #endif 198 #endif
199 } 199 }
200 200
201 octave_passwd::octave_passwd (void *p, string& msg) 201 octave_passwd::octave_passwd (void *p, std::string& msg)
202 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (), 202 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (),
203 pw_dir (), pw_shell (), valid (false) 203 pw_dir (), pw_shell (), valid (false)
204 { 204 {
205 #if defined (HAVE_PWD_H) 205 #if defined (HAVE_PWD_H)
206 msg = string (); 206 msg = std::string ();
207 207
208 if (p) 208 if (p)
209 { 209 {
210 struct passwd *pw = static_cast<struct passwd *> (p); 210 struct passwd *pw = static_cast<struct passwd *> (p);
211 211