Annotation of truecrypt/main/unix/main.cpp, revision 1.1

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: 
        !            57:                // Set user interface type
        !            58:                if (argc > 1 && (strcmp (argv[1], "-t") == 0 || strcmp (argv[1], "--text") == 0))
        !            59:                        Application::Initialize (UserInterfaceType::Text);
        !            60:                else
        !            61:                        Application::Initialize (UserInterfaceType::Graphic);
        !            62: 
        !            63:                // Start main application
        !            64:                Application::SetExitCode (1);
        !            65: 
        !            66:                if (::wxEntry (argc, argv) == 0)
        !            67:                        Application::SetExitCode (0);
        !            68:        }
        !            69:        catch (ErrorMessage &e)
        !            70:        {
        !            71:                wcerr << wstring (e) << endl;
        !            72:        }
        !            73:        catch (SystemException &e)
        !            74:        {
        !            75:                wstringstream s;
        !            76:                if (e.GetSubject().empty())
        !            77:                        s << e.what() << endl << e.SystemText();
        !            78:                else
        !            79:                        s << e.what() << endl << e.SystemText() << endl << e.GetSubject();
        !            80:                wcerr << s.str() << endl;
        !            81:        }
        !            82:        catch (exception &e)
        !            83:        {
        !            84:                stringstream s;
        !            85:                s << StringConverter::GetTypeName (typeid (e)) << endl << e.what();
        !            86:                cerr << s.str() << endl;
        !            87:        }
        !            88: 
        !            89:        return Application::GetExitCode();
        !            90: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.