00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_passwd_h)
00024 #define octave_passwd_h 1
00025
00026 #include <string>
00027
00028 #ifdef HAVE_SYS_TYPES_H
00029 #include <sys/types.h>
00030 #endif
00031
00032 class
00033 octave_passwd
00034 {
00035 public:
00036
00037 octave_passwd (void)
00038 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (),
00039 pw_dir (), pw_shell (), valid (false)
00040 { }
00041
00042 octave_passwd (const octave_passwd& pw)
00043 : pw_name (pw.pw_name), pw_passwd (pw.pw_passwd),
00044 pw_uid (pw.pw_uid), pw_gid (pw.pw_gid), pw_gecos (pw.pw_gecos),
00045 pw_dir (pw.pw_dir), pw_shell (pw.pw_shell), valid (pw.valid)
00046 { }
00047
00048 octave_passwd& operator = (const octave_passwd& pw)
00049 {
00050 if (this != &pw)
00051 {
00052 pw_name = pw.pw_name;
00053 pw_passwd = pw.pw_passwd;
00054 pw_uid = pw.pw_uid;
00055 pw_gid = pw.pw_gid;
00056 pw_gecos = pw.pw_gecos;
00057 pw_dir = pw.pw_dir;
00058 pw_shell = pw.pw_shell;
00059 valid = pw.valid;
00060 }
00061
00062 return *this;
00063 }
00064
00065 ~octave_passwd (void) { }
00066
00067 std::string name (void) const;
00068
00069 std::string passwd (void) const;
00070
00071 uid_t uid (void) const;
00072
00073 gid_t gid (void) const;
00074
00075 std::string gecos (void) const;
00076
00077 std::string dir (void) const;
00078
00079 std::string shell (void) const;
00080
00081 bool ok (void) const { return valid; }
00082
00083 operator bool () const { return ok (); }
00084
00085 static octave_passwd getpwent (void);
00086 static octave_passwd getpwent (std::string& msg);
00087
00088 static octave_passwd getpwuid (uid_t uid);
00089 static octave_passwd getpwuid (uid_t uid, std::string& msg);
00090
00091 static octave_passwd getpwnam (const std::string& nm);
00092 static octave_passwd getpwnam (const std::string& nm, std::string& msg);
00093
00094 static int setpwent (void);
00095 static int setpwent (std::string& msg);
00096
00097 static int endpwent (void);
00098 static int endpwent (std::string& msg);
00099
00100 private:
00101
00102
00103 std::string pw_name;
00104
00105
00106 std::string pw_passwd;
00107
00108
00109 uid_t pw_uid;
00110
00111
00112 gid_t pw_gid;
00113
00114
00115 std::string pw_gecos;
00116
00117
00118 std::string pw_dir;
00119
00120
00121 std::string pw_shell;
00122
00123
00124 bool valid;
00125
00126
00127
00128 octave_passwd (void *p, std::string& msg);
00129
00130 void gripe_invalid (void) const;
00131 };
00132
00133 #endif
00134
00135
00136
00137
00138
00139