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_API
00034 octave_passwd
00035 {
00036 public:
00037
00038 octave_passwd (void)
00039 : pw_name (), pw_passwd (), pw_uid (0), pw_gid (0), pw_gecos (),
00040 pw_dir (), pw_shell (), valid (false)
00041 { }
00042
00043 octave_passwd (const octave_passwd& pw)
00044 : pw_name (pw.pw_name), pw_passwd (pw.pw_passwd),
00045 pw_uid (pw.pw_uid), pw_gid (pw.pw_gid), pw_gecos (pw.pw_gecos),
00046 pw_dir (pw.pw_dir), pw_shell (pw.pw_shell), valid (pw.valid)
00047 { }
00048
00049 octave_passwd& operator = (const octave_passwd& pw)
00050 {
00051 if (this != &pw)
00052 {
00053 pw_name = pw.pw_name;
00054 pw_passwd = pw.pw_passwd;
00055 pw_uid = pw.pw_uid;
00056 pw_gid = pw.pw_gid;
00057 pw_gecos = pw.pw_gecos;
00058 pw_dir = pw.pw_dir;
00059 pw_shell = pw.pw_shell;
00060 valid = pw.valid;
00061 }
00062
00063 return *this;
00064 }
00065
00066 ~octave_passwd (void) { }
00067
00068 std::string name (void) const;
00069
00070 std::string passwd (void) const;
00071
00072 uid_t uid (void) const;
00073
00074 gid_t gid (void) const;
00075
00076 std::string gecos (void) const;
00077
00078 std::string dir (void) const;
00079
00080 std::string shell (void) const;
00081
00082 bool ok (void) const { return valid; }
00083
00084 operator bool () const { return ok (); }
00085
00086 static octave_passwd getpwent (void);
00087 static octave_passwd getpwent (std::string& msg);
00088
00089 static octave_passwd getpwuid (uid_t uid);
00090 static octave_passwd getpwuid (uid_t uid, std::string& msg);
00091
00092 static octave_passwd getpwnam (const std::string& nm);
00093 static octave_passwd getpwnam (const std::string& nm, std::string& msg);
00094
00095 static int setpwent (void);
00096 static int setpwent (std::string& msg);
00097
00098 static int endpwent (void);
00099 static int endpwent (std::string& msg);
00100
00101 private:
00102
00103
00104 std::string pw_name;
00105
00106
00107 std::string pw_passwd;
00108
00109
00110 uid_t pw_uid;
00111
00112
00113 gid_t pw_gid;
00114
00115
00116 std::string pw_gecos;
00117
00118
00119 std::string pw_dir;
00120
00121
00122 std::string pw_shell;
00123
00124
00125 bool valid;
00126
00127
00128
00129 octave_passwd (void *p, std::string& msg);
00130
00131 void gripe_invalid (void) const;
00132 };
00133
00134 #endif
00135
00136
00137
00138
00139
00140