]> git.lyx.org Git - lyx.git/blob - src/support/userinfo.C
* lyxfunctional.h: delete compare_memfun and helper classes
[lyx.git] / src / support / userinfo.C
1 /**
2  * \file userinfo.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "userinfo.h"
14 #include "filetools.h"
15
16 #include <boost/assert.hpp>
17
18 #include <pwd.h>
19 #include <unistd.h>
20 #include <sys/types.h>
21
22 using std::string;
23
24 namespace lyx {
25 namespace support {
26
27 string const user_name()
28 {
29         struct passwd * pw(getpwuid(geteuid()));
30         BOOST_ASSERT(pw);
31
32         string name = pw->pw_gecos;
33         if (name.empty())
34                 name = pw->pw_name;
35         return name;
36 }
37
38
39 string const user_email()
40 {
41         string email = GetEnv("EMAIL_ADDRESS");
42         if (email.empty())
43                 email = GetEnv("EMAIL");
44         return email;
45 }
46
47 } // namespace support
48 } // namespace lyx