|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3:
4: Governed by the TrueCrypt License 2.4 the full text of which is contained
5: in the file License.txt included in TrueCrypt binary and source code
6: distribution packages.
7: */
8:
9: #include "System.h"
10: #include <sys/mman.h>
11:
12: #include "Platform/Platform.h"
13: #include "Platform/SystemLog.h"
14: #include "Core/Unix/CoreService.h"
15: #include "Main/Application.h"
16: #include "Main/Main.h"
17: #include "Main/UserInterface.h"
18:
19: using namespace TrueCrypt;
20:
21: int main (int argc, char **argv)
22: {
23: try
24: {
25: // Make sure all required commands can be executed via default search path
26: string sysPathStr = "/usr/sbin:/sbin:/usr/bin:/bin";
27:
28: char *sysPath = getenv ("PATH");
29: if (sysPath)
30: {
31: sysPathStr += ":";
32: sysPathStr += sysPath;
33: }
34:
35: setenv ("PATH", sysPathStr.c_str(), 1);
36:
37: if (argc > 1 && strcmp (argv[1], TC_CORE_SERVICE_CMDLINE_OPTION) == 0)
38: {
39: // Process elevated requests
40: try
41: {
42: CoreService::ProcessElevatedRequests();
43: return 0;
44: }
45: catch (exception &e)
46: {
47: SystemLog::WriteException (e);
48: }
49: catch (...) { }
50: return 1;
51: }
52:
53: // Start core service
54: CoreService::Start();
55: finally_do ({ CoreService::Stop(); });
56:
1.1.1.2 ! root 57: bool forceTextUI = false;
! 58: #ifdef __WXGTK__
! 59: if (!getenv ("DISPLAY"))
! 60: forceTextUI = true;
! 61: #endif
! 62:
1.1 root 63: // Set user interface type
1.1.1.2 ! root 64: if (forceTextUI || (argc > 1 && (strcmp (argv[1], "-t") == 0 || strcmp (argv[1], "--text") == 0)))
1.1 root 65: Application::Initialize (UserInterfaceType::Text);
66: else
67: Application::Initialize (UserInterfaceType::Graphic);
68:
69: // Start main application
70: Application::SetExitCode (1);
71:
72: if (::wxEntry (argc, argv) == 0)
73: Application::SetExitCode (0);
74: }
75: catch (ErrorMessage &e)
76: {
77: wcerr << wstring (e) << endl;
78: }
79: catch (SystemException &e)
80: {
81: wstringstream s;
82: if (e.GetSubject().empty())
83: s << e.what() << endl << e.SystemText();
84: else
85: s << e.what() << endl << e.SystemText() << endl << e.GetSubject();
86: wcerr << s.str() << endl;
87: }
88: catch (exception &e)
89: {
90: stringstream s;
91: s << StringConverter::GetTypeName (typeid (e)) << endl << e.what();
92: cerr << s.str() << endl;
93: }
94:
95: return Application::GetExitCode();
96: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.