]> git.lyx.org Git - lyx.git/blob - src/support/userinfo.C
make "make distcheck" work
[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 "support/userinfo.h"
14 #include "support/environment.h"
15
16 #include <boost/assert.hpp>
17
18 #include <pwd.h>
19 #ifdef HAVE_UNISTD_H
20 # include <unistd.h>
21 #endif
22 #include <sys/types.h>
23
24 using std::string;
25
26 namespace lyx {
27 namespace support {
28
29 string const user_name()
30 {
31         struct passwd * pw(getpwuid(geteuid()));
32         BOOST_ASSERT(pw);
33
34         string name = pw->pw_gecos;
35         if (name.empty())
36                 name = pw->pw_name;
37         return name;
38 }
39
40
41 string const user_email()
42 {
43         string email = getEnv("EMAIL_ADDRESS");
44         if (email.empty())
45                 email = getEnv("EMAIL");
46         return email;
47 }
48
49 } // namespace support
50 } // namespace lyx