Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#define constants for api arrays
  • Loading branch information
gcontini committed Jan 11, 2020
1 parent d4e9dcd commit 5081f5a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
14 changes: 10 additions & 4 deletions include/licensecc/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ extern "C" {
#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
Expand Down Expand Up @@ -59,7 +65,7 @@ typedef struct {
* 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;

/**
Expand All @@ -85,8 +91,8 @@ typedef struct {
* 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 {
Expand All @@ -100,7 +106,7 @@ typedef struct {
* 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;
Expand Down
21 changes: 10 additions & 11 deletions include/licensecc/licensecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#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" {
#endif
Expand All @@ -12,15 +12,16 @@ extern "C" {

/*
* 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.
Expand All @@ -43,13 +44,11 @@ EVENT_TYPE acquire_license(const CallerInformations* callerInformation, const Li
* 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
}
Expand Down
13 changes: 8 additions & 5 deletions src/library/licensecc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//============================================================================
// Name : license-manager-cpp.cpp
// Name : licensecc.cpp
// Author :
// Version :
// Copyright : BSD
Expand All @@ -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;
}
Expand Down

0 comments on commit 5081f5a

Please sign in to comment.