gcontini
2019-12-07 74001fb4ce5041c3deb42a0ca252ae338aa571db
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef DATATYPES_H_
#define DATATYPES_H_
 
#ifdef __cplusplus
extern "C" {
#endif
 
// definition of size_t
#include <stdlib.h>
#include <stdint.h>
#ifndef _MSC_VER
#include <stdbool.h>
#endif
 
#ifdef __unix__
#define DllExport
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
#else
#include <windows.h>
#define DllExport __declspec(dllexport)
#endif
 
// define api structure sizes
#define PC_IDENTIFIER_SIZE 18
#define PROPRIETARY_DATA_SIZE 16
#define AUDIT_EVENT_NUM 5
 
typedef enum {
    LICENSE_OK = 0,  // OK
    LICENSE_FILE_NOT_FOUND = 1,  // license file not found
    LICENSE_SERVER_NOT_FOUND = 2,  // license server can't be contacted
    ENVIRONMENT_VARIABLE_NOT_DEFINED = 3,  // environment variable not defined
    FILE_FORMAT_NOT_RECOGNIZED = 4,  // license file has invalid format (not .ini file)
    LICENSE_MALFORMED = 5,  // some mandatory field are missing, or data can't be fully read.
    PRODUCT_NOT_LICENSED = 6,  // this product was not licensed
    PRODUCT_EXPIRED = 7,
    LICENSE_CORRUPTED = 8,  // License signature didn't match with current license
    IDENTIFIERS_MISMATCH = 9,  // Calculated identifier and the one provided in license didn't match
 
    LICENSE_SPECIFIED = 100,  // license location was specified
    LICENSE_FOUND = 101,  // License file has been found or license data has been located
    PRODUCT_FOUND = 102,  // License has been loaded and the declared product has been found
    SIGNATURE_VERIFIED = 103
} EVENT_TYPE;
 
typedef enum {
    LOCAL,
    REMOTE  // remote licenses are not supported now.
} LICENSE_TYPE;
 
typedef enum { SVRT_INFO, SVRT_WARN, SVRT_ERROR } SEVERITY;
 
typedef struct {
    SEVERITY severity;
    EVENT_TYPE event_type;
    /**
     * License file name or location where the license is stored.
     */
    char license_reference[MAX_PATH];
    char param2[256];
} AuditEvent;
 
/**
 * This structure contains informations on the raw license data. Software authors
 * can specify the location of the license file or its full content.
 *
 * Can be NULL, in this case OpenLicenseManager will try to figure out the
 * license file location on its own.
 */
typedef struct {
    /**
     * A list of absolute path separated by ';' containing the eventual location
     * of the license files. Can be NULL.
     */
    const char *licenseFileLocation;
    /**
     * The application can provide the full license content through this string.
     * It can be both in encoded form (base64) or in plain. It's optional.
     */
    const char *licenseData;
} LicenseLocation;
/**
 * Informations on the software requiring the license
 */
typedef struct {
    char version[16];  // software version in format xxxx.xxxx.xxxx
    char project_name[16];  // name of the project (must correspond to the name in the license)
    uint32_t magic;  // reserved
} CallerInformations;
typedef struct {
    /**
     * Detailed reason of success/failure. Reasons for a failure can be
     * multiple (for instance, license expired and signature not verified).
     * Only the last AUDIT_EVENT_NUM are reported.
     */
    AuditEvent status[AUDIT_EVENT_NUM];
    /**
     * Eventual expiration date of the software,
     * can be '\0' if the software don't expire
     * */
    char expiry_date[11];
    unsigned int days_left;
    bool has_expiry;
    bool linked_to_pc;
    LICENSE_TYPE license_type;  // Local or Remote
    /* A string of character inserted into the license understood
     * by the calling application.
     * '\0' if the application didn't specify one */
    char proprietary_data[PROPRIETARY_DATA_SIZE + 1];
    int license_version;  // license file version
} LicenseInfo;
 
/**
 * Enum to select a specific pc identification_strategy. DEFAULT Should be used
 * in most cases.
 */
typedef enum {
    STRATEGY_DEFAULT,
    STRATEGY_ETHERNET,
    STRATEGY_IP_ADDRESS,
    STRATEGY_DISK_NUM,
    STRATEGY_DISK_LABEL,
    STRATEGY_PLATFORM_SPECIFIC,
    STRATEGY_UNKNOWN
} IDENTIFICATION_STRATEGY;
 
#ifdef __cplusplus
}
#endif
 
#endif