2934
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2934
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_passwd_h) |
|
25 #define octave_passwd_h 1 |
|
26 |
|
27 #include <string> |
|
28 |
|
29 #ifdef HAVE_SYS_TYPES_H |
|
30 #include <sys/types.h> |
|
31 #endif |
|
32 |
|
33 class |
6108
|
34 OCTAVE_API |
2934
|
35 octave_passwd |
|
36 { |
|
37 public: |
|
38 |
|
39 octave_passwd (void) |
|
40 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (), |
|
41 pw_dir (), pw_shell (), valid (false) |
|
42 { } |
|
43 |
|
44 octave_passwd (const octave_passwd& pw) |
|
45 : pw_name (pw.pw_name), pw_passwd (pw.pw_passwd), |
|
46 pw_uid (pw.pw_uid), pw_gid (pw.pw_gid), pw_gecos (pw.pw_gecos), |
|
47 pw_dir (pw.pw_dir), pw_shell (pw.pw_shell), valid (pw.valid) |
|
48 { } |
|
49 |
|
50 octave_passwd& operator = (const octave_passwd& pw) |
2937
|
51 { |
|
52 if (this != &pw) |
|
53 { |
|
54 pw_name = pw.pw_name; |
|
55 pw_passwd = pw.pw_passwd; |
|
56 pw_uid = pw.pw_uid; |
|
57 pw_gid = pw.pw_gid; |
|
58 pw_gecos = pw.pw_gecos; |
|
59 pw_dir = pw.pw_dir; |
|
60 pw_shell = pw.pw_shell; |
|
61 valid = pw.valid; |
|
62 } |
2934
|
63 |
2937
|
64 return *this; |
|
65 } |
2934
|
66 |
|
67 ~octave_passwd (void) { } |
|
68 |
3504
|
69 std::string name (void) const; |
2934
|
70 |
3504
|
71 std::string passwd (void) const; |
2934
|
72 |
|
73 uid_t uid (void) const; |
|
74 |
|
75 gid_t gid (void) const; |
|
76 |
3504
|
77 std::string gecos (void) const; |
2934
|
78 |
3504
|
79 std::string dir (void) const; |
2934
|
80 |
3504
|
81 std::string shell (void) const; |
2934
|
82 |
|
83 bool ok (void) const { return valid; } |
|
84 |
3145
|
85 operator bool () const { return ok (); } |
2934
|
86 |
|
87 static octave_passwd getpwent (void); |
3504
|
88 static octave_passwd getpwent (std::string& msg); |
2934
|
89 |
|
90 static octave_passwd getpwuid (uid_t uid); |
3504
|
91 static octave_passwd getpwuid (uid_t uid, std::string& msg); |
2934
|
92 |
3504
|
93 static octave_passwd getpwnam (const std::string& nm); |
|
94 static octave_passwd getpwnam (const std::string& nm, std::string& msg); |
2934
|
95 |
2937
|
96 static int setpwent (void); |
3504
|
97 static int setpwent (std::string& msg); |
2934
|
98 |
2937
|
99 static int endpwent (void); |
3504
|
100 static int endpwent (std::string& msg); |
2934
|
101 |
|
102 private: |
|
103 |
|
104 // User name. |
3504
|
105 std::string pw_name; |
2934
|
106 |
|
107 // Encrypted password. |
3504
|
108 std::string pw_passwd; |
2934
|
109 |
|
110 // Numeric user id. |
|
111 uid_t pw_uid; |
|
112 |
|
113 // Numeric group id. |
|
114 gid_t pw_gid; |
|
115 |
|
116 // Miscellaneous junk. |
3504
|
117 std::string pw_gecos; |
2934
|
118 |
|
119 // Home directory. |
3504
|
120 std::string pw_dir; |
2934
|
121 |
|
122 // Login shell. |
3504
|
123 std::string pw_shell; |
2934
|
124 |
|
125 // Flag that says whether we have been properly initialized. |
|
126 bool valid; |
|
127 |
|
128 // This is how we will create an octave_passwd object from a pointer |
|
129 // to a struct passwd. |
3504
|
130 octave_passwd (void *p, std::string& msg); |
2934
|
131 |
|
132 void gripe_invalid (void) const; |
|
133 }; |
|
134 |
|
135 #endif |
|
136 |
|
137 /* |
|
138 ;;; Local Variables: *** |
|
139 ;;; mode: C++ *** |
|
140 ;;; End: *** |
|
141 */ |