Mercurial > octave
comparison liboctave/system/oct-passwd.h @ 21729:815b2f500fab
use namespace for system password wrapper class
* oct-passwd.h, oct-passwd.cc: Put password class in octave::sys
namespace. Change all uses.
(octave_passwd): Now a deprecated typedef for octave::sys::password.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 18 May 2016 13:11:15 -0400 |
parents | 1473547f50f5 |
children | 11af9c03400c |
comparison
equal
deleted
inserted
replaced
21728:c218a5b31ad7 | 21729:815b2f500fab |
---|---|
27 | 27 |
28 #include <string> | 28 #include <string> |
29 | 29 |
30 #include <sys/types.h> | 30 #include <sys/types.h> |
31 | 31 |
32 class | 32 namespace |
33 OCTAVE_API | 33 octave |
34 octave_passwd | |
35 { | 34 { |
36 public: | 35 namespace |
36 sys | |
37 { | |
38 class | |
39 OCTAVE_API | |
40 password | |
41 { | |
42 public: | |
37 | 43 |
38 octave_passwd (void) | 44 password (void) |
39 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (), | 45 : m_name (), m_passwd (), m_uid (0), m_gid (0), m_gecos (), |
40 pw_dir (), pw_shell (), valid (false) | 46 m_dir (), m_shell (), valid (false) |
41 { } | 47 { } |
42 | 48 |
43 octave_passwd (const octave_passwd& pw) | 49 password (const password& pw) |
44 : pw_name (pw.pw_name), pw_passwd (pw.pw_passwd), | 50 : m_name (pw.m_name), m_passwd (pw.m_passwd), |
45 pw_uid (pw.pw_uid), pw_gid (pw.pw_gid), pw_gecos (pw.pw_gecos), | 51 m_uid (pw.m_uid), m_gid (pw.m_gid), m_gecos (pw.m_gecos), |
46 pw_dir (pw.pw_dir), pw_shell (pw.pw_shell), valid (pw.valid) | 52 m_dir (pw.m_dir), m_shell (pw.m_shell), valid (pw.valid) |
47 { } | 53 { } |
48 | 54 |
49 octave_passwd& operator = (const octave_passwd& pw) | 55 password& operator = (const password& pw) |
50 { | 56 { |
51 if (this != &pw) | 57 if (this != &pw) |
52 { | 58 { |
53 pw_name = pw.pw_name; | 59 m_name = pw.m_name; |
54 pw_passwd = pw.pw_passwd; | 60 m_passwd = pw.m_passwd; |
55 pw_uid = pw.pw_uid; | 61 m_uid = pw.m_uid; |
56 pw_gid = pw.pw_gid; | 62 m_gid = pw.m_gid; |
57 pw_gecos = pw.pw_gecos; | 63 m_gecos = pw.m_gecos; |
58 pw_dir = pw.pw_dir; | 64 m_dir = pw.m_dir; |
59 pw_shell = pw.pw_shell; | 65 m_shell = pw.m_shell; |
60 valid = pw.valid; | 66 valid = pw.valid; |
61 } | 67 } |
62 | 68 |
63 return *this; | 69 return *this; |
70 } | |
71 | |
72 ~password (void) { } | |
73 | |
74 std::string name (void) const; | |
75 | |
76 std::string passwd (void) const; | |
77 | |
78 uid_t uid (void) const; | |
79 | |
80 gid_t gid (void) const; | |
81 | |
82 std::string gecos (void) const; | |
83 | |
84 std::string dir (void) const; | |
85 | |
86 std::string shell (void) const; | |
87 | |
88 bool ok (void) const { return valid; } | |
89 | |
90 operator bool () const { return ok (); } | |
91 | |
92 static password getpwent (void); | |
93 static password getpwent (std::string& msg); | |
94 | |
95 static password getpwuid (uid_t uid); | |
96 static password getpwuid (uid_t uid, std::string& msg); | |
97 | |
98 static password getpwnam (const std::string& nm); | |
99 static password getpwnam (const std::string& nm, std::string& msg); | |
100 | |
101 static int setpwent (void); | |
102 static int setpwent (std::string& msg); | |
103 | |
104 static int endpwent (void); | |
105 static int endpwent (std::string& msg); | |
106 | |
107 private: | |
108 | |
109 // User name. | |
110 std::string m_name; | |
111 | |
112 // Encrypted password. | |
113 std::string m_passwd; | |
114 | |
115 // Numeric user id. | |
116 uid_t m_uid; | |
117 | |
118 // Numeric group id. | |
119 gid_t m_gid; | |
120 | |
121 // Miscellaneous junk. | |
122 std::string m_gecos; | |
123 | |
124 // Home directory. | |
125 std::string m_dir; | |
126 | |
127 // Login shell. | |
128 std::string m_shell; | |
129 | |
130 // Flag that says whether we have been properly initialized. | |
131 bool valid; | |
132 | |
133 // This is how we will create a password object from a pointer | |
134 // to a struct passwd. | |
135 password (void *p, std::string& msg); | |
136 }; | |
64 } | 137 } |
138 } | |
65 | 139 |
66 ~octave_passwd (void) { } | 140 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
67 | 141 |
68 std::string name (void) const; | 142 OCTAVE_DEPRECATED ("use octave::sys::password instead") |
69 | 143 typedef octave::sys::password octave_passwd; |
70 std::string passwd (void) const; | |
71 | |
72 uid_t uid (void) const; | |
73 | |
74 gid_t gid (void) const; | |
75 | |
76 std::string gecos (void) const; | |
77 | |
78 std::string dir (void) const; | |
79 | |
80 std::string shell (void) const; | |
81 | |
82 bool ok (void) const { return valid; } | |
83 | |
84 operator bool () const { return ok (); } | |
85 | |
86 static octave_passwd getpwent (void); | |
87 static octave_passwd getpwent (std::string& msg); | |
88 | |
89 static octave_passwd getpwuid (uid_t uid); | |
90 static octave_passwd getpwuid (uid_t uid, std::string& msg); | |
91 | |
92 static octave_passwd getpwnam (const std::string& nm); | |
93 static octave_passwd getpwnam (const std::string& nm, std::string& msg); | |
94 | |
95 static int setpwent (void); | |
96 static int setpwent (std::string& msg); | |
97 | |
98 static int endpwent (void); | |
99 static int endpwent (std::string& msg); | |
100 | |
101 private: | |
102 | |
103 // User name. | |
104 std::string pw_name; | |
105 | |
106 // Encrypted password. | |
107 std::string pw_passwd; | |
108 | |
109 // Numeric user id. | |
110 uid_t pw_uid; | |
111 | |
112 // Numeric group id. | |
113 gid_t pw_gid; | |
114 | |
115 // Miscellaneous junk. | |
116 std::string pw_gecos; | |
117 | |
118 // Home directory. | |
119 std::string pw_dir; | |
120 | |
121 // Login shell. | |
122 std::string pw_shell; | |
123 | |
124 // Flag that says whether we have been properly initialized. | |
125 bool valid; | |
126 | |
127 // This is how we will create an octave_passwd object from a pointer | |
128 // to a struct passwd. | |
129 octave_passwd (void *p, std::string& msg); | |
130 }; | |
131 | 144 |
132 #endif | 145 #endif |
146 | |
147 #endif |