From 2695752f624aa7dc3f91672c6fbeb894c22eaa47 Mon Sep 17 00:00:00 2001 From: Gabriele Contini <contini.mailing@gmail.com> Date: 周六, 11 1月 2020 15:24:46 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/develop' into feature/pc_identifiers --- include/licensecc/datatypes.h | 75 ++++++++++++++++++++++++------------- 1 files changed, 48 insertions(+), 27 deletions(-) diff --git a/include/licensecc/datatypes.h b/include/licensecc/datatypes.h index 7a95afb..3355876 100644 --- a/include/licensecc/datatypes.h +++ b/include/licensecc/datatypes.h @@ -22,10 +22,17 @@ #define DllExport __declspec(dllexport) #endif +#define API_LICENSE_DATA_LENGTH 1024 * 4 + // define api structure sizes -#define PC_IDENTIFIER_SIZE 19 -#define PROPRIETARY_DATA_SIZE 16 -#define AUDIT_EVENT_NUM 5 +#define API_PC_IDENTIFIER_SIZE 19 +#define API_PROPRIETARY_DATA_SIZE 16 +#define API_AUDIT_EVENT_NUM 5 +#define API_AUDIT_EVENT_PARAM2 255 +#define API_VERSION_LENGTH 15 +#define API_PROJECT_NAME_SIZE 15 +#define API_EXPIRY_DATE_SIZE 10 +#define API_ERROR_BUFFER_SIZE 256 typedef enum { LICENSE_OK = 0, // OK @@ -59,8 +66,24 @@ * License file name or location where the license is stored. */ char license_reference[MAX_PATH]; - char param2[256]; + char param2[API_AUDIT_EVENT_PARAM2 + 1]; } AuditEvent; + +typedef enum { + /** + * A list of absolute path separated by ';' containing the eventual location + * of the license files. Can be NULL. + */ + LICENSE_PATH, + /** + * The license is provided as plain data + */ + LICENSE_PLAIN_DATA, + /** + * The license is encoded + */ + LICENSE_ENCODED +} LICENSE_DATA_TYPE; /** * This structure contains informations on the raw license data. Software authors @@ -70,37 +93,35 @@ * 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; + LICENSE_DATA_TYPE license_data_type; + char licenseData[API_LICENSE_DATA_LENGTH]; } 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 + char version[API_VERSION_LENGTH + 1]; // software version in format xxxx[.xxxx.xxxx] //TODO + char project_name[API_PROJECT_NAME_SIZE + 1]; // name of the project (must correspond to the name in the license) + /** + * this number passed in by the application must correspond to the magic number used when compiling the library. + * See cmake parameter -DLCC_PROJECT_MAGIC_NUM and licensecc_properties.h macro VERIFY_MAGIC + */ + unsigned int magic; } 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]; + AuditEvent status[API_AUDIT_EVENT_NUM]; /** * Eventual expiration date of the software, * can be '\0' if the software don't expire * */ - char expiry_date[11]; + char expiry_date[API_EXPIRY_DATE_SIZE + 1]; unsigned int days_left; bool has_expiry; bool linked_to_pc; @@ -108,7 +129,7 @@ /* 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]; + char proprietary_data[API_PROPRIETARY_DATA_SIZE + 1]; int license_version; // license file version } LicenseInfo; @@ -117,13 +138,13 @@ * in most cases. */ typedef enum { - STRATEGY_DEFAULT, - STRATEGY_ETHERNET, - STRATEGY_IP_ADDRESS, - STRATEGY_DISK_NUM, - STRATEGY_DISK_LABEL, - STRATEGY_PLATFORM_SPECIFIC, - STRATEGY_UNKNOWN + STRATEGY_DEFAULT = -1, + STRATEGY_ETHERNET = 0, + STRATEGY_IP_ADDRESS = 1, + STRATEGY_DISK_NUM = 1, + STRATEGY_DISK_LABEL = 2, + STRATEGY_PLATFORM_SPECIFIC = 3, + STRATEGY_UNKNOWN = -2 } IDENTIFICATION_STRATEGY; #ifdef __cplusplus -- Gitblit v1.9.1