1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/passwdentry.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2002 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>
<font color="#a020f0">#ifndef RUDIMENTS_PASSWDENTRY_H</font>
<font color="#a020f0">#define RUDIMENTS_PASSWDENTRY_H</font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/private/passwdentryincludes.h></font>
<font color="#0000ff">// The passwdentry class provides methods for retrieving</font>
<font color="#0000ff">// entries from /etc/passwd</font>
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>
<font color="#2e8b57"><b>class</b></font> passwdentryprivate;
<font color="#2e8b57"><b>class</b></font> passwdentry {
<font color="#a52a2a"><b>public</b></font>:
<font color="#0000ff">// If you need to quickly look up ap specific field, use one</font>
<font color="#0000ff">// of these methods.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// These methods return true on success and false on failure.</font>
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getName(uid_t userid, <font color="#2e8b57"><b>char</b></font> **name);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getPassword(uid_t userid, <font color="#2e8b57"><b>char</b></font> **password);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getPrimaryGroupId(uid_t userid, gid_t *groupid);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getRealName(uid_t userid, <font color="#2e8b57"><b>char</b></font> **realname);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getHomeDirectory(uid_t userid, <font color="#2e8b57"><b>char</b></font> **homedir);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getShell(uid_t userid, <font color="#2e8b57"><b>char</b></font> **shell);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getPassword(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username,
<font color="#2e8b57"><b>char</b></font> **password);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getUserId(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username,
uid_t *userid);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getPrimaryGroupId(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username,
gid_t *groupid);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getRealName(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username,
<font color="#2e8b57"><b>char</b></font> **realname);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getHomeDirectory(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username,
<font color="#2e8b57"><b>char</b></font> **homedir);
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> getShell(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username,
<font color="#2e8b57"><b>char</b></font> **shell);
<font color="#0000ff">// If you need to look up a passwd entry and refer to multiple</font>
<font color="#0000ff">// fields, use these methods.</font>
passwdentry();
passwdentry(<font color="#2e8b57"><b>const</b></font> passwdentry &p);
passwdentry &<font color="#a52a2a"><b>operator</b></font>=(<font color="#2e8b57"><b>const</b></font> passwdentry &p);
~passwdentry();
<font color="#2e8b57"><b>bool</b></font> initialize(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *username);
<font color="#0000ff">// Looks up a passwd entry by name.</font>
<font color="#0000ff">// Returns true on success and false on failure.</font>
<font color="#2e8b57"><b>bool</b></font> initialize(uid_t userid);
<font color="#0000ff">// Looks up a passwd entry by user id.</font>
<font color="#0000ff">// Returns true on success and false on failure.</font>
<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *getName() <font color="#2e8b57"><b>const</b></font>;
<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *getPassword() <font color="#2e8b57"><b>const</b></font>;
uid_t getUserId() <font color="#2e8b57"><b>const</b></font>;
gid_t getPrimaryGroupId() <font color="#2e8b57"><b>const</b></font>;
<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *getRealName() <font color="#2e8b57"><b>const</b></font>;
<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *getHomeDirectory() <font color="#2e8b57"><b>const</b></font>;
<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *getShell() <font color="#2e8b57"><b>const</b></font>;
<font color="#2e8b57"><b>void</b></font> print() <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Prints out the passwd entry.</font>
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> needsMutex();
<font color="#0000ff">// If your system doesn't support getpwnam_r() and</font>
<font color="#0000ff">// getpwuid_r() then this class needs a mutex to assure</font>
<font color="#0000ff">// thread safety.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// This method returns true if this class needs a mutex</font>
<font color="#0000ff">// to operate safely in a threaded environment and false</font>
<font color="#0000ff">// otherwise.</font>
<font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>void</b></font> setMutex(mutex *mtx);
<font color="#0000ff">// Allows you to supply a mutex is the class needs it.</font>
<font color="#0000ff">// If your application is not multithreaded, then</font>
<font color="#0000ff">// there is no need to supply a mutex.</font>
<font color="#a020f0"> #include </font><font color="#ff00ff"><rudiments/private/passwdentry.h></font>
};
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>
<font color="#a020f0">#endif</font>
</pre>
</body>
</html>
|