/* The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING.GPL. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ /** @file * @brief provides wrapper and tools for (system) user and group information. * * @copyright Intra2net AG * * @license commercial * * (c) Copyright 2007-2008 by Intra2net AG */ #ifndef _I2N_USERFUNC_HPP_ #define _I2N_USERFUNC_HPP_ #include #include #include #include namespace I2n { /** * @brief structure similar to "struct passwd", but more C++ like. */ /// FIXME: Argh, why is this a public struct without accessor functions struct User { std::string Name; std::string Password; uid_t Uid; gid_t Gid; std::string Gecos; std::string Homedir; std::string Shell; User(); User(const std::string& name); User(const char* name); User(uid_t uid); void clear(); bool is_valid() const; operator bool() const { return is_valid(); } }; // eo struct User /** * @brief structure similar to "struct group", but more C++ like. */ /// FIXME: Argh, why is this a public struct without accessor functions struct Group { std::string Name; std::string Password; gid_t Gid; std::vector< std::string > Members; Group(); Group(const std::string& name); Group(const char* name); Group(gid_t gid); void clear(); bool is_valid() const; operator bool() const { return is_valid(); } }; // eo struct Group bool get_user(const std::string& name, User& result); bool get_user(uid_t uid, User& result); User get_user(const std::string& name); User get_user(uid_t uid); bool get_group(const std::string& name, Group& result); bool get_group(gid_t gid, Group& result); Group get_group(const std::string& name); Group get_group(gid_t gid); } // eo namespace I2n #endif