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