NAME
OUX_User -
Class to encapsulate UNIX user information.
SYNOPSIS
#include <OUX/system/user.hh>
class OUX_User
{
public:
static os_typespec* get_os_typespec();
OUX_User();
OUX_User(uid_t theUID);
OUX_User(OTC_String const& theName);
OUX_User(passwd const* thePwent);
OUX_User(OUX_User const& theUser);
OUX_User& operator=(OUX_User const& theUser);
OUX_User& operator=(passwd const* thePwent);
inline OTC_Boolean isValid() const;
inline OTC_String const& name() const;
inline OTC_String const& fullname() const;
inline uid_t uid() const;
inline operator uid_t() const;
inline gid_t gid() const;
};
CLASS TYPE
Concrete
DESCRIPTION
The OUX_User class is a wrapper around the password entry
for a user.
INITIALISATION
OUX_User();
Creates a class for the user corresponding
to the current user id. If the current
user id doesn't describe a valid user on
this host then the user id will still be
used and the group id, and user name will
also be set to the user id. Also, the full
name of the user will be empty.
OUX_User(uid_t theUID);
Creates a class for the user with user id
theUID. If theUID doesn't describe a
valid user on this host then the user id
will still be used and the group id, and
user name will also be set to the user id.
Also, the full name of the user will be
empty.
OUX_User(OTC_String const& theName);
Creates a class for the user with user
name theName. If theName doesn't
describe a valid user on this host then
the user name will still be used, however
the user id and group id will be set to
MAXUID, the id generally assigned to the
user nobody. Also, the full name of the
user will be empty.
OUX_User(passwd const* thePwent);
Creates a class for the user corresponding
to the password structure thePwent. If
thePwent is 0 the user id, group id,
and user name will be set to MAXUID, the
id generally assigned to the user
nobody. Also, the full name of the user
will be empty.
OUX_User(OUX_User const& theUser);
Creates a copy of theUser.
OUX_User& operator=(OUX_User const& theUser);
Initialises this user to be the same
as theUser.
OUX_User& operator=(passwd const* thePwent);
Initialises this user to be that defined
by the passwd structure thePwent. If
thePwent is 0 the user id, group id,
and user name will be set to MAXUID, the
id generally assigned to the user
nobody. Also, the full name of the user
will be empty.
ENQUIRY
inline OTC_Boolean isValid() const;
Returns OTCLIB_TRUE if this class
describes a valid user on this host.
inline OTC_String const& name() const;
Returns the user name of the user.
inline OTC_String const& fullname() const;
Returns the real name of the user.
inline uid_t uid() const;
Returns the user id of the user.
inline operator uid_t() const;
Returns the user id of the user.
inline gid_t gid() const;
Returns the group id corresponding to the
user.
NOTES
If the data used to get information about the user, doesn't
identify a valid user on the host then the information will be
filled out with default values. The isValid() function should
always be invoked to actually determine if the information
gathered is correct.
Note that successive calls to getpwent() to get all entries in
the passwd file may not be able to be used while creating
instances of this class using any constructor besides the copy
constructor and that accepting a pointer to a passwd structure, as
instantiation of the class may have the result of reseting the
pointer used by getpwent() back to the start. Whether this
occurs will depend on your variant of UNIX.
An OTC_BaseActions and OTC_HashActions are defined for
OUX_User. For OTC_HashActions the key on which hashing
and comparison is based is the user id.
LIBRARY
OUX
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1991 1992 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED