From 023ffb740a864fe7e79aa73f16175a81d46b545a Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 6 Aug 2024 11:18:30 +0530 Subject: [PATCH] feat: add getHostConfig --- lexfloatclient.go | 34 +++++++++++++++++++++++++++++++++ lexfloatclient/LexFloatClient.h | 15 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lexfloatclient.go b/lexfloatclient.go index 69bfc43..94cc956 100644 --- a/lexfloatclient.go +++ b/lexfloatclient.go @@ -13,9 +13,17 @@ void floatingLicenseCallbackCgoGateway(int status); */ import "C" import ( + "encoding/json" + "strings" "unsafe" ) + +type HostConfig struct { + MaxOfflineLeaseDuration int `json:"maxOfflineLeaseDuration"` +} + + type callbackType func(int) const ( @@ -389,6 +397,32 @@ func HasFloatingLicense() int { return int(status) } +/* + FUNCTION: GetHostConfig() + + PURPOSE: Gets the host configuration. + + This function sends a network request to LexFloatServer to get the configuration details. + + PARAMETERS: + * hostConfig - pointer to a buffer that receives the value of the string + * length - size of the buffer pointed to by the hostConfigPtr parameter + + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL, LF_E_BUFFER_SIZE + LF_E_INET, LF_E_CLIENT, LF_E_IP, LF_E_SERVER +*/ +func GetHostConfig(hostConfig *HostConfig) int { + var cHostConfig = getCArray() + hostConfigJson := "" + status := C.GetHostConfigInternal(&cHostConfig[0], maxCArrayLength) + hostConfigJson = strings.TrimRight(ctoGoString(&cHostConfig[0]), "\x00") + if hostConfigJson != "" { + config := []byte(hostConfigJson) + json.Unmarshal(config, hostConfig) + } + return int(status) +} + /* FUNCTION: GetFloatinglicenseMode() diff --git a/lexfloatclient/LexFloatClient.h b/lexfloatclient/LexFloatClient.h index e076c73..4f6054d 100644 --- a/lexfloatclient/LexFloatClient.h +++ b/lexfloatclient/LexFloatClient.h @@ -146,6 +146,21 @@ LEXFLOATCLIENT_API int LF_CC SetFloatingLicenseCallback(CallbackType callback); */ LEXFLOATCLIENT_API int LF_CC SetFloatingClientMetadata(CSTRTYPE key, CSTRTYPE value); +/* + FUNCTION: GetHostConfigInternal() + + PURPOSE: Gets the host configuration. + This function sends a network request to LexFloatServer to get the configuration details. + + PARAMETERS: + * hostConfig - pointer to a buffer that receives the value of the string + * length - size of the buffer pointed to by the hostConfigPtr parameter + + RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL, LF_E_BUFFER_SIZE + LF_E_INET, LF_E_CLIENT, LF_E_IP, LF_E_SERVER +*/ +LEXFLOATCLIENT_API int LF_CC GetHostConfigInternal(STRTYPE hostConfig, uint32_t length); + /* FUNCTION: GetFloatingClientLibraryVersion()