2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
21 * @brief provides wrapper and tools for (system) user and group information.
23 * @copyright Intra2net AG
27 * (c) Copyright 2007-2008 by Intra2net AG
30 #ifndef _I2N_USERFUNC_HPP_
31 #define _I2N_USERFUNC_HPP_
37 #include <sys/types.h>
43 * @brief structure similar to "struct passwd", but more C++ like.
45 /// FIXME: Argh, why is this a public struct without accessor functions
57 User(const std::string& name);
58 User(const char* name);
62 bool is_valid() const;
64 operator bool() const { return is_valid(); }
70 * @brief structure similar to "struct group", but more C++ like.
72 /// FIXME: Argh, why is this a public struct without accessor functions
78 std::vector< std::string > Members;
81 Group(const std::string& name);
82 Group(const char* name);
86 bool is_valid() const;
88 operator bool() const { return is_valid(); }
91 bool get_user(const std::string& name, User& result);
92 bool get_user(uid_t uid, User& result);
94 User get_user(const std::string& name);
95 User get_user(uid_t uid);
97 bool get_group(const std::string& name, Group& result);
98 bool get_group(gid_t gid, Group& result);
100 Group get_group(const std::string& name);
101 Group get_group(gid_t gid);
103 } // eo namespace I2n