Mercurial > hg > octave-nkf
annotate liboctave/oct-passwd.h @ 12747:901d466ee55a stable release-3-4-1
Version 3.4.1 released.
* configure.ac (AC_INIT): Version is now 3.4.1.
(OCTAVE_API_VERSION_NUMBER): Now 45.
(OCTAVE_RELEASE_DATE): Now 2011-06-15.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 15 Jun 2011 10:35:37 -0400 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
rev | line source |
---|---|
2934 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 John W. Eaton |
2934 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2934 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2934 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_passwd_h) | |
24 #define octave_passwd_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 #include <sys/types.h> | |
29 | |
30 class | |
6108 | 31 OCTAVE_API |
2934 | 32 octave_passwd |
33 { | |
34 public: | |
35 | |
36 octave_passwd (void) | |
37 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (), | |
38 pw_dir (), pw_shell (), valid (false) | |
39 { } | |
40 | |
41 octave_passwd (const octave_passwd& pw) | |
42 : pw_name (pw.pw_name), pw_passwd (pw.pw_passwd), | |
43 pw_uid (pw.pw_uid), pw_gid (pw.pw_gid), pw_gecos (pw.pw_gecos), | |
44 pw_dir (pw.pw_dir), pw_shell (pw.pw_shell), valid (pw.valid) | |
45 { } | |
46 | |
47 octave_passwd& operator = (const octave_passwd& pw) | |
2937 | 48 { |
49 if (this != &pw) | |
50 { | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
51 pw_name = pw.pw_name; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
52 pw_passwd = pw.pw_passwd; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
53 pw_uid = pw.pw_uid; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
54 pw_gid = pw.pw_gid; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
55 pw_gecos = pw.pw_gecos; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
56 pw_dir = pw.pw_dir; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
57 pw_shell = pw.pw_shell; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
58 valid = pw.valid; |
2937 | 59 } |
2934 | 60 |
2937 | 61 return *this; |
62 } | |
2934 | 63 |
64 ~octave_passwd (void) { } | |
65 | |
3504 | 66 std::string name (void) const; |
2934 | 67 |
3504 | 68 std::string passwd (void) const; |
2934 | 69 |
70 uid_t uid (void) const; | |
71 | |
72 gid_t gid (void) const; | |
73 | |
3504 | 74 std::string gecos (void) const; |
2934 | 75 |
3504 | 76 std::string dir (void) const; |
2934 | 77 |
3504 | 78 std::string shell (void) const; |
2934 | 79 |
80 bool ok (void) const { return valid; } | |
81 | |
3145 | 82 operator bool () const { return ok (); } |
2934 | 83 |
84 static octave_passwd getpwent (void); | |
3504 | 85 static octave_passwd getpwent (std::string& msg); |
2934 | 86 |
87 static octave_passwd getpwuid (uid_t uid); | |
3504 | 88 static octave_passwd getpwuid (uid_t uid, std::string& msg); |
2934 | 89 |
3504 | 90 static octave_passwd getpwnam (const std::string& nm); |
91 static octave_passwd getpwnam (const std::string& nm, std::string& msg); | |
2934 | 92 |
2937 | 93 static int setpwent (void); |
3504 | 94 static int setpwent (std::string& msg); |
2934 | 95 |
2937 | 96 static int endpwent (void); |
3504 | 97 static int endpwent (std::string& msg); |
2934 | 98 |
99 private: | |
100 | |
101 // User name. | |
3504 | 102 std::string pw_name; |
2934 | 103 |
104 // Encrypted password. | |
3504 | 105 std::string pw_passwd; |
2934 | 106 |
107 // Numeric user id. | |
108 uid_t pw_uid; | |
109 | |
110 // Numeric group id. | |
111 gid_t pw_gid; | |
112 | |
113 // Miscellaneous junk. | |
3504 | 114 std::string pw_gecos; |
2934 | 115 |
116 // Home directory. | |
3504 | 117 std::string pw_dir; |
2934 | 118 |
119 // Login shell. | |
3504 | 120 std::string pw_shell; |
2934 | 121 |
122 // Flag that says whether we have been properly initialized. | |
123 bool valid; | |
124 | |
125 // This is how we will create an octave_passwd object from a pointer | |
126 // to a struct passwd. | |
3504 | 127 octave_passwd (void *p, std::string& msg); |
2934 | 128 |
129 void gripe_invalid (void) const; | |
130 }; | |
131 | |
132 #endif |