2016-02-23 21:07:23 +01:00
|
|
|
#include "Cli.h"
|
2016-02-11 16:39:42 +01:00
|
|
|
#include <cpp-utils/random/Random.h>
|
2016-09-24 20:28:56 +02:00
|
|
|
#include <cpp-utils/io/IOStreamConsole.h>
|
2019-01-26 08:38:34 +01:00
|
|
|
#include <cryfs/impl/CryfsException.h>
|
2015-10-24 19:35:37 +02:00
|
|
|
|
2018-09-17 08:37:30 +02:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#include <cpp-utils/network/WinHttpClient.h>
|
2018-12-14 09:40:38 +01:00
|
|
|
#include <VersionHelpers.h>
|
2018-09-17 08:37:30 +02:00
|
|
|
#else
|
|
|
|
#include <cpp-utils/network/CurlHttpClient.h>
|
|
|
|
#endif
|
|
|
|
|
2019-01-19 22:02:41 +01:00
|
|
|
using namespace cryfs_cli;
|
2015-11-04 05:27:00 +01:00
|
|
|
using cpputils::Random;
|
|
|
|
using cpputils::SCrypt;
|
2016-09-24 20:28:56 +02:00
|
|
|
using cpputils::IOStreamConsole;
|
2017-09-30 19:53:03 +02:00
|
|
|
using cpputils::make_unique_ref;
|
2016-01-25 15:01:34 +01:00
|
|
|
using std::make_shared;
|
2016-09-24 09:51:29 +02:00
|
|
|
using std::cerr;
|
2015-09-28 13:41:23 +02:00
|
|
|
|
2016-05-10 01:07:02 +02:00
|
|
|
int main(int argc, const char *argv[]) {
|
2018-12-14 09:40:38 +01:00
|
|
|
#if defined(_MSC_VER)
|
2018-12-22 10:25:47 +01:00
|
|
|
if (!IsWindows7SP1OrGreater()) {
|
|
|
|
std::cerr << "CryFS is currently only supported on Windows 7 SP1 (or later)." << std::endl;
|
2018-12-22 10:18:08 +01:00
|
|
|
exit(1);
|
2018-12-14 09:40:38 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-24 09:51:29 +02:00
|
|
|
try {
|
|
|
|
auto &keyGenerator = Random::OSRandom();
|
2018-09-17 08:37:30 +02:00
|
|
|
#if defined(_MSC_VER)
|
2018-12-14 09:40:38 +01:00
|
|
|
auto httpClient = make_unique_ref<cpputils::WinHttpClient>();
|
2018-09-17 08:37:30 +02:00
|
|
|
#else
|
2018-12-14 09:40:38 +01:00
|
|
|
auto httpClient = make_unique_ref<cpputils::CurlHttpClient>();
|
2018-09-17 08:37:30 +02:00
|
|
|
#endif
|
2017-09-30 19:53:03 +02:00
|
|
|
return Cli(keyGenerator, SCrypt::DefaultSettings, make_shared<IOStreamConsole>())
|
2018-12-09 18:27:53 +01:00
|
|
|
.main(argc, argv, std::move(httpClient), []{});
|
2019-01-19 22:02:41 +01:00
|
|
|
} catch (const cryfs::CryfsException &e) {
|
2018-12-11 06:20:18 +01:00
|
|
|
if (e.what() != string()) {
|
2018-02-02 01:08:01 +01:00
|
|
|
std::cerr << "Error: " << e.what() << std::endl;
|
|
|
|
}
|
|
|
|
return exitCode(e.errorCode());
|
2016-09-24 09:51:29 +02:00
|
|
|
} catch (const std::exception &e) {
|
|
|
|
cerr << "Error: " << e.what();
|
2019-01-19 22:02:41 +01:00
|
|
|
return exitCode(cryfs::ErrorCode::UnspecifiedError);
|
2016-09-24 09:51:29 +02:00
|
|
|
}
|
2014-11-04 02:32:06 +01:00
|
|
|
}
|