Skip to content

Commit

Permalink
Merge pull request #17 from cryptlex/muneeb/gethostconfig2
Browse files Browse the repository at this point in the history
feat: add function gethostconfig
  • Loading branch information
ahmad-kemsan authored Aug 6, 2024
2 parents 46638a3 + 023ffb7 commit ad913c4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lexfloatclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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()
Expand Down
15 changes: 15 additions & 0 deletions lexfloatclient/LexFloatClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ad913c4

Please sign in to comment.