paludis Version 3.0.2
The one true package mangler
system.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_UTIL_SYSTEM_HH
21#define PALUDIS_GUARD_PALUDIS_UTIL_SYSTEM_HH 1
22
24#include <string>
25#include <sys/types.h>
26
27/** \file
28 * Various system utilities.
29 *
30 * \ingroup g_system
31 *
32 * \section Examples
33 *
34 * - None at this time.
35 */
36
37namespace paludis
38{
39 /**
40 * Thrown if getenv_or_error fails.
41 *
42 * \ingroup g_exceptions
43 * \ingroup g_system
44 * \nosubgrouping
45 */
46 class PALUDIS_VISIBLE GetenvError : public Exception
47 {
48 public:
49 ///\name Basic operations
50 ///\{
51
52 GetenvError(const std::string & key) noexcept;
53
54 ///\}
55 };
56
57 /**
58 * Fetch the value of environment variable key, or def if the variable is
59 * not defined.
60 *
61 * \ingroup g_system
62 */
63 std::string getenv_with_default(const std::string & key, const std::string & def) PALUDIS_VISIBLE;
64
65 /**
66 * Fetch the value of environment variable key, or throw a GetenvError if
67 * the variable is not defined.
68 *
69 * \ingroup g_system
70 */
71 std::string getenv_or_error(const std::string & key) PALUDIS_VISIBLE;
72
73 /**
74 * Fetch the kernel version, for $KV.
75 *
76 * \ingroup g_system
77 */
79
80 /**
81 * Fetch the username for a uid, or the uid as a string if not available.
82 *
83 * \ingroup g_system
84 */
85 std::string get_user_name(const uid_t) PALUDIS_VISIBLE;
86
87 /**
88 * Fetch the group name for a gid, or the gid as a string if not available.
89 *
90 * \ingroup g_system
91 */
92 std::string get_group_name(const gid_t) PALUDIS_VISIBLE;
93}
94
95#endif
96
std::string getenv_or_error(const std::string &key) PALUDIS_VISIBLE
std::string get_group_name(const gid_t) PALUDIS_VISIBLE
std::string getenv_with_default(const std::string &key, const std::string &def) PALUDIS_VISIBLE
std::string kernel_version() PALUDIS_VISIBLE
std::string get_user_name(const uid_t) PALUDIS_VISIBLE
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24