]> git.lyx.org Git - lyx.git/blob - src/support/userinfo.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / support / userinfo.cpp
1 /**
2  * \file userinfo.cpp
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 #if defined (_WIN32)
19 # include "gettext.h"
20 # include <windows.h>
21 # include <lmcons.h>
22 #else
23 # include <pwd.h>
24 # ifdef HAVE_UNISTD_H
25 #  include <unistd.h>
26 # endif
27 #endif
28 #ifdef HAVE_SYS_TYPES_H
29 # include <sys/types.h>
30 #endif
31
32 using std::string;
33
34 namespace lyx {
35 namespace support {
36
37 docstring const user_name()
38 {
39 #if defined (_WIN32)
40
41         char name[UNLEN + 1];
42         DWORD size = UNLEN + 1;
43         if (!GetUserName(name, &size))
44                 return _("Unknown user");
45         return from_local8bit(name);
46 #else
47         struct passwd * pw(getpwuid(geteuid()));
48         BOOST_ASSERT(pw);
49
50         string name = pw->pw_gecos;
51         if (name.empty())
52                 name = pw->pw_name;
53         return from_local8bit(name);
54 #endif
55 }
56
57
58 docstring const user_email()
59 {
60         //FIXME: quick fix wrt bug #3764; only Anonymous is detected now.
61         //The code after should be used only after user approval.
62         return docstring();
63
64         
65         string email = getEnv("EMAIL_ADDRESS");
66         if (email.empty())
67                 email = getEnv("EMAIL");
68         return from_local8bit(email);
69 }
70
71 } // namespace support
72 } // namespace lyx