gcontini
2020-01-09 b6277b30756c96404bc747f32ae45e9d3e205447
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
52
53
54
55
56
57
58
/*
 * pc_identifier.cpp
 *
 *  Created on: Dec 22, 2019
 *      Author: GC
 */
 
#include <algorithm>
#include "pc_identifier.hpp"
#include "../base/base64.h"
 
namespace license {
using namespace std;
 
PcIdentifier::PcIdentifier() {}
 
PcIdentifier::PcIdentifier(const std::string& param) {
    // TODO Auto-generated constructor stub
}
 
PcIdentifier::~PcIdentifier() {}
 
PcIdentifier::PcIdentifier(const PcIdentifier& other) : m_data(other.m_data) {}
 
void PcIdentifier::set_identification_strategy(IDENTIFICATION_STRATEGY strategy) {
    if (strategy == STRATEGY_UNKNOWN || strategy == STRATEGY_DEFAULT) {
        throw logic_error("Only known strategies are permitted");
    }
    uint8_t stratMov = (strategy << 5);
    m_data[1] = (m_data[1] & 0x1F) | stratMov;
}
 
void PcIdentifier::set_use_environment_var(bool use_env_var) {
    if (use_env_var) {
        m_data[0] = m_data[0] | 0x40;
    } else {
        m_data[0] = m_data[0] & ~0x40;
    }
}
 
void PcIdentifier::set_virtual_environment(VIRTUALIZATION virt) {
    // 110000 0x30
    m_data[0] = (m_data[0] && ~0x30) | virt << 4;
}
 
void PcIdentifier::set_virtualization(VIRTUALIZATION_DETAIL virtualization_detail) {}
 
void PcIdentifier::set_cloud_provider(CLOUD_PROVIDER cloud_provider) {}
 
void PcIdentifier::set_data(const std::array<uint8_t, 6>& data) {}
 
std::string PcIdentifier::print() const {
    string result = base64(m_data.data(), m_data.size(), 4);
    std::replace(result.begin(), result.end(), '\n', '-');
    return result;
}
 
} /* namespace license */