gcontini
2020-01-11 5081f5a80e62322155736ddf5c12140627aff2aa
issue #70

#define constants for api arrays
4个文件已修改
48 ■■■■■ 已修改文件
extern/license-generator @ 61acc7 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
include/licensecc/datatypes.h 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
include/licensecc/licensecc.h 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/licensecc.cpp 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
extern/license-generator
@@ -1 +1 @@
Subproject commit c40c0951e77c012a1c4043182c88ae5fe185efea
Subproject commit 61acc7dee39b9947e08d0753d2f69d2a41d5fe31
include/licensecc/datatypes.h
@@ -26,6 +26,12 @@
#define PC_IDENTIFIER_SIZE 19
#define PROPRIETARY_DATA_SIZE 16
#define AUDIT_EVENT_NUM 5
#define AUDIT_EVENT_PARAM2 255
#define VERSION_SIZE 15
#define PROJECT_NAME_SIZE 15
#define EXPIRY_DATE_SIZE 10
#define ERROR_BUFFER_SIZE 256
typedef enum {
    LICENSE_OK = 0,  // OK
@@ -59,7 +65,7 @@
     * License file name or location where the license is stored.
     */
    char license_reference[MAX_PATH];
    char param2[256];
    char param2[AUDIT_EVENT_PARAM2 + 1];
} AuditEvent;
/**
@@ -85,8 +91,8 @@
 * 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)
    char version[VERSION_SIZE + 1];  // software version in format xxxx.xxxx.xxxx
    char project_name[PROJECT_NAME_SIZE + 1];  // name of the project (must correspond to the name in the license)
    uint32_t magic;  // reserved
} CallerInformations;
typedef struct {
@@ -100,7 +106,7 @@
     * Eventual expiration date of the software,
     * can be '\0' if the software don't expire
     * */
    char expiry_date[11];
    char expiry_date[EXPIRY_DATE_SIZE + 1];
    unsigned int days_left;
    bool has_expiry;
    bool linked_to_pc;
include/licensecc/licensecc.h
@@ -2,7 +2,7 @@
#define LICENSEPP_H_
/*
 * This include file is the public api di License++
 * This include file is the public api di Licensecc
*/
#ifdef __cplusplus
extern "C" {
@@ -12,15 +12,16 @@
/*
 * Method used to convert the LicenseInfo into a human readable
 * representation.
 * representation. //not yet implemented
 */
void print_error(char out_buffer[256], LicenseInfo* licenseInfo);
void print_error(char out_buffer[ERROR_BUFFER_SIZE], LicenseInfo* licenseInfo);
/**
 * This method calculate the pc identifier. The string has to be shown
 * to the user in order to calculate the license.
 * This method calculates the pc identifier. The string need to be shown to the user and given back to the software
 * editor when issuing a license.
 *  pc_id_method = STRATEGY_DEFAULT usually works.
 */
bool identify_pc(IDENTIFICATION_STRATEGY pc_id_method, char* identifier_out, size_t bufSize);
bool identify_pc(IDENTIFICATION_STRATEGY pc_id_method, char* identifier_out, size_t* bufSize);
/**
 * This method is used to request the use of one license for a product.
@@ -43,13 +44,11 @@
 * Should be called from time to time to confirm we're still using the
 * license.
 */
EVENT_TYPE confirm_license(char * featureName,
        LicenseLocation* licenseLocation);
EVENT_TYPE confirm_license(char* featureName, LicenseLocation* licenseLocation);
/**
 * Do nothing for now, useful for network licenses.
 */
EVENT_TYPE release_license(char * featureName,
        LicenseLocation licenseLocation);
EVENT_TYPE release_license(char* featureName, LicenseLocation licenseLocation);
#ifdef __cplusplus
}
src/library/licensecc.cpp
@@ -1,5 +1,5 @@
//============================================================================
// Name        : license-manager-cpp.cpp
// Name        : licensecc.cpp
// Author      :
// Version     :
// Copyright   : BSD
@@ -23,14 +23,17 @@
#include "pc-identifiers.h"
using namespace std;
void print_error(char out_buffer[256], LicenseInfo* licenseInfo) {}
bool identify_pc(IDENTIFICATION_STRATEGY pc_id_method, char* chbuffer, size_t bufSize) {
void print_error(char out_buffer[ERROR_BUFFER_SIZE], LicenseInfo* licenseInfo) {}
bool identify_pc(IDENTIFICATION_STRATEGY pc_id_method, char* chbuffer, size_t* bufSize) {
    FUNCTION_RETURN result = FUNC_RET_BUFFER_TOO_SMALL;
    if (bufSize >= sizeof(PcSignature)) {
    if (*bufSize > sizeof(PcSignature)) {
        PcSignature identifier_out;
        result = generate_user_pc_signature(identifier_out, pc_id_method);
        strncpy(chbuffer, identifier_out, bufSize);
        strncpy(chbuffer, identifier_out, *bufSize);
    } else {
        *bufSize = sizeof(PcSignature) + 1;
    }
    return result == FUNC_RET_OK;
}