-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathmain.cc
More file actions
51 lines (47 loc) · 1.58 KB
/
Copy pathmain.cc
File metadata and controls
51 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// License++
//
// Copyright © 2018-present @abumq (Majid Q.)
//
// See https://github.com/abumq/licensepp/blob/master/LICENSE
//
// Usage: ./license-manager-sample --license <license-file> [--signature <signature>]
#include <cstring>
#include <sstream>
#include <fstream>
#include <iostream>
#include <string>
#include "license-manager.h"
int main(int argc, char* argv[])
{
std::string licenseFile;
std::string signature;
for (int i = 0; i < argc; i++) {
std::string arg(argv[i]);
if (arg == "--license" && i < argc) {
licenseFile = argv[++i];
} else if (arg == "--signature" && i < argc) {
signature = argv[++i];
}
}
if (!licenseFile.empty()) {
License license;
try {
if (license.loadFromFile(licenseFile)) {
LicenseManager licenseManager;
if (!licenseManager.validate(&license, true, signature)) {
std::cout << "License is not valid" << std::endl;
} else {
std::cout << "Licensed to " << license.licensee() << std::endl;
std::cout << "Subscription is active until " << license.formattedExpiry() << std::endl << std::endl;
}
}
} catch (LicenseException& e) {
std::cerr << "Exception thrown " << e.what() << std::endl;
}
} else {
std::cout << "License file not provided" << std::endl;
std::cout << "Usage: ./license-manager-sample --license <license-file> [--signature <signature>]" << std::endl;
}
return 0;
}