-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlexfloatclient.go
More file actions
518 lines (478 loc) · 19.8 KB
/
lexfloatclient.go
File metadata and controls
518 lines (478 loc) · 19.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
// Copyright 2026 Cryptlex LLP. All rights reserved.
package lexfloatclient
/*
#cgo linux,!arm64 LDFLAGS: -Wl,-Bstatic -L${SRCDIR}/libs/linux_amd64 -lLexFloatClient -Wl,-Bdynamic -lm -lstdc++ -lpthread
#cgo linux,arm64 LDFLAGS: -Wl,-Bstatic -L${SRCDIR}/libs/linux_arm64 -lLexFloatClient -Wl,-Bdynamic -lm -lstdc++ -lpthread
#cgo darwin LDFLAGS: -L${SRCDIR}/libs/darwin_universal -lLexFloatClient -lc++ -framework CoreFoundation -framework SystemConfiguration -framework Security
#cgo windows LDFLAGS: -L${SRCDIR}/libs/windows_amd64 -lLexFloatClient
#include "lexfloatclient/LexFloatClient.h"
#include <stdlib.h>
void floatingLicenseCallbackCgoGateway(int status);
*/
import "C"
import (
"encoding/json"
"strings"
"unsafe"
)
type HostConfig struct {
MaxOfflineLeaseDuration int `json:"maxOfflineLeaseDuration"`
}
type HostFeatureEntitlement struct {
FeatureName string `json:"featureName"`
FeatureDisplayName string `json:"featureDisplayName"`
Value string `json:"value"`
BaseValue string `json:"baseValue"`
ExpiresAt int64 `json:"expiresAt"`
}
type callbackType func(int)
const (
LF_USER uint = 10
LF_ALL_USERS uint = 11
)
var floatingLicenseCallbackFunction callbackType
//export floatingLicenseCallbackWrapper
func floatingLicenseCallbackWrapper(status int) {
if floatingLicenseCallbackFunction != nil {
floatingLicenseCallbackFunction(status)
}
}
// SetPermissionFlag sets the permission flag.
//
// This function must be called on every start of your program after SetHostProductId()
// function in case the application allows borrowing of licenses or system wide activation.
//
// Parameters:
// - flags: depending on your application's requirements, choose one of the following values:
// - LF_USER: This flag indicates that the application does not require admin or root permissions to run.
// - LF_ALL_USERS: This flag is specifically designed for Windows and should be used
// for system-wide activations.
//
// Returns: LF_OK, LF_E_PRODUCT_ID
func SetPermissionFlag(flags uint) int {
cFlags := (C.uint)(flags)
status := C.SetPermissionFlag(cFlags)
return int(status)
}
// SetHostProductId sets the product id of your application.
//
// Parameters:
// - productId: the unique product id of your application as mentioned
// on the product page in the dashboard.
//
// Returns: LF_OK, LF_E_PRODUCT_ID
func SetHostProductId(productId string) int {
cProductId := goToCString(productId)
status := C.SetHostProductId(cProductId)
freeCString(cProductId)
return int(status)
}
// SetHostUrl sets the network address of the LexFloatServer.
//
// The url format should be: http://[ip or hostname]:[port]
//
// Parameters:
// - hostUrl: the url string having the correct format
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_HOST_URL
func SetHostUrl(hostUrl string) int {
cHostUrl := goToCString(hostUrl)
status := C.SetHostUrl(cHostUrl)
freeCString(cHostUrl)
return int(status)
}
// SetFloatingLicenseCallback sets the renew license callback function.
//
// Whenever the license lease is about to expire, a renew request is sent to the
// server. When the request completes, the license callback function
// gets invoked with one of the following status codes:
//
// LF_OK, LF_E_INET, LF_E_LICENSE_EXPIRED_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP,
// LF_E_SERVER, LF_E_TIME, LF_E_SERVER_LICENSE_NOT_ACTIVATED,LF_E_SERVER_TIME_MODIFIED,
// LF_E_SERVER_LICENSE_SUSPENDED, LF_E_SERVER_LICENSE_EXPIRED, LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER
//
// Returns: LF_OK, LF_E_PRODUCT_ID
func SetFloatingLicenseCallback(callbackFunction func(int)) int {
status := C.SetFloatingLicenseCallback((C.CallbackType)(unsafe.Pointer(C.floatingLicenseCallbackCgoGateway)))
floatingLicenseCallbackFunction = callbackFunction
return int(status)
}
// SetFloatingClientMetadata sets the floating client metadata.
//
// The metadata appears along with the license details of the license
// in LexFloatServer dashboard.
//
// Parameters:
// - key: string of maximum length 256 characters with utf-8 encoding.
// - value: string of maximum length 4096 characters with utf-8 encoding.
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_METADATA_KEY_LENGTH,
// LF_E_METADATA_VALUE_LENGTH, LF_E_ACTIVATION_METADATA_LIMIT
func SetFloatingClientMetadata(key string, value string) int {
cKey := goToCString(key)
cValue := goToCString(value)
status := C.SetFloatingClientMetadata(cKey, cValue)
freeCString(cKey)
freeCString(cValue)
return int(status)
}
// GetFloatingClientLibraryVersion gets the version of this library.
//
// Parameters:
// - libraryVersion: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_BUFFER_SIZE
func GetFloatingClientLibraryVersion(libraryVersion *string) int {
var cLibraryVersion = getCArray()
status := C.GetFloatingClientLibraryVersion(&cLibraryVersion[0], maxCArrayLength)
*libraryVersion = ctoGoString(&cLibraryVersion[0])
return int(status)
}
// GetHostProductVersionName gets the product version name.
//
// Deprecated: This function is deprecated. Use GetHostLicenseEntitlementSetName() instead.
//
// Parameters:
// - name: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE
func GetHostProductVersionName(name *string) int {
var cName = getCArray()
status := C.GetHostProductVersionName(&cName[0], maxCArrayLength)
*name = ctoGoString(&cName[0])
return int(status)
}
// GetHostProductVersionDisplayName gets the product version display name.
//
// Deprecated: This function is deprecated. Use GetHostLicenseEntitlementSetDisplayName() instead.
//
// Parameters:
// - displayName: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_BUFFER_SIZE
func GetHostProductVersionDisplayName(displayName *string) int {
var cDisplayName = getCArray()
status := C.GetHostProductVersionDisplayName(&cDisplayName[0], maxCArrayLength)
*displayName = ctoGoString(&cDisplayName[0])
return int(status)
}
// GetHostProductVersionFeatureFlag gets the product version feature flag.
//
// Deprecated: This function is deprecated. Use GetHostFeatureEntitlement() instead.
//
// Parameters:
// - name: name of the feature flag
// - enabled: pointer to the integer that receives the value - 0 or 1
// - data: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_PRODUCT_VERSION_NOT_LINKED, LF_E_FEATURE_FLAG_NOT_FOUND, LF_E_BUFFER_SIZE
func GetHostProductVersionFeatureFlag(name string, enabled *bool, data *string) int {
cName := goToCString(name)
var cEnabled C.uint
var cData = getCArray()
status := C.GetHostProductVersionFeatureFlag(cName, &cEnabled, &cData[0], maxCArrayLength)
freeCString(cName)
*enabled = cEnabled > 0
*data = ctoGoString(&cData[0])
return int(status)
}
// GetHostLicenseEntitlementSetName gets the name of the entitlement set associated with the LexFloatServer license.
//
// Parameters:
// - name: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, LF_E_ENTITLEMENT_SET_NOT_LINKED
func GetHostLicenseEntitlementSetName(name *string) int {
var cName = getCArray()
status := C.GetHostLicenseEntitlementSetName(&cName[0], maxCArrayLength)
*name = ctoGoString(&cName[0])
return int(status)
}
// GetHostLicenseEntitlementSetDisplayName gets the display name of the entitlement set associated with the LexFloatServer license.
//
// Parameters:
// - displayName: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, LF_E_ENTITLEMENT_SET_NOT_LINKED
func GetHostLicenseEntitlementSetDisplayName(displayName *string) int {
var cDisplayName = getCArray()
status := C.GetHostLicenseEntitlementSetDisplayName(&cDisplayName[0], maxCArrayLength)
*displayName = ctoGoString(&cDisplayName[0])
return int(status)
}
// GetHostLicenseEntitlementSetTier gets the tier of the entitlement set associated with the LexFloatServer license.
//
// Parameters:
// - tier: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_ENTITLEMENT_SET_NOT_LINKED
func GetHostLicenseEntitlementSetTier(tier *int64) int {
var cTier C.int64_t
status := C.GetHostLicenseEntitlementSetTier(&cTier)
*tier = int64(cTier)
return int(status)
}
// GetHostFeatureEntitlements gets the feature entitlements associated with the LexFloatServer license.
//
// Parameters:
// - hostFeatureEntitlements: pointer to an array of HostFeatureEntitlement structs that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE
func GetHostFeatureEntitlements(hostFeatureEntitlements *[]HostFeatureEntitlement) int {
var cHostFeatureEntitlements = getCArray()
hostFeatureEntitlementsJson := ""
status := C.GetHostFeatureEntitlementsInternal(&cHostFeatureEntitlements[0], maxCArrayLength)
hostFeatureEntitlementsJson = strings.TrimRight(ctoGoString(&cHostFeatureEntitlements[0]), "\x00")
if hostFeatureEntitlementsJson != "" {
json.Unmarshal([]byte(hostFeatureEntitlementsJson), hostFeatureEntitlements)
}
return int(status)
}
// GetHostFeatureEntitlement gets the value of the feature entitlement field associated with the LexFloatServer license.
//
// Parameters:
// - name: name of the feature
// - hostFeatureEntitlement: pointer to the HostFeatureEntitlement struct that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, LF_E_FEATURE_ENTITLEMENT_NOT_FOUND
func GetHostFeatureEntitlement(name string, hostFeatureEntitlement *HostFeatureEntitlement) int {
cName := goToCString(name)
var cHostFeatureEntitlement = getCArray()
status := C.GetHostFeatureEntitlementInternal(cName, &cHostFeatureEntitlement[0], maxCArrayLength)
freeCString(cName)
hostFeatureEntitlementJson := strings.TrimRight(ctoGoString(&cHostFeatureEntitlement[0]), "\x00")
if hostFeatureEntitlementJson != "" {
json.Unmarshal([]byte(hostFeatureEntitlementJson), hostFeatureEntitlement)
}
return int(status)
}
// GetHostProductMetadata gets the value of the product metadata.
//
// Parameters:
// - key: key of the metadata field whose value you want to get
// - value: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, LF_E_METADATA_KEY_NOT_FOUND
func GetHostProductMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetHostProductMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)
}
// GetHostLicenseMetadata gets the value of the license metadata field associated with the LexFloatServer license.
//
// Parameters:
// - key: key of the metadata field whose value you want to get
// - value: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, LF_E_METADATA_KEY_NOT_FOUND
func GetHostLicenseMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetHostLicenseMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)
}
// GetHostLicenseMeterAttribute gets the license meter attribute allowed uses and total uses associated with the LexFloatServer license.
//
// Parameters:
// - name: name of the meter attribute
// - allowedUses: pointer to the integer that receives the value. A value of -1 indicates unlimited allowed uses.
// - totalUses: pointer to the integer that receives the value
// - grossUses: pointer to the integer that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND
func GetHostLicenseMeterAttribute(name string, allowedUses *int64, totalUses *uint64, grossUses *uint64) int {
cName := goToCString(name)
var cAllowedUses C.int64_t
var cTotalUses C.uint64_t
var cGrossUses C.uint64_t
status := C.GetHostLicenseMeterAttribute(cName, &cAllowedUses, &cTotalUses, &cGrossUses)
*allowedUses = int64(cAllowedUses)
*totalUses = uint64(cTotalUses)
*grossUses = uint64(cGrossUses)
freeCString(cName)
return int(status)
}
// GetHostLicenseExpiryDate gets the license expiry date timestamp of the LexFloatServer license.
//
// Parameters:
// - expiryDate: pointer to the integer that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE
func GetHostLicenseExpiryDate(expiryDate *uint) int {
var cExpiryDate C.uint
status := C.GetHostLicenseExpiryDate(&cExpiryDate)
*expiryDate = uint(cExpiryDate)
return int(status)
}
// GetFloatingClientMeterAttributeUses gets the meter attribute uses consumed by the floating client.
//
// Parameters:
// - name: name of the meter attribute
// - uses: pointer to the integer that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND
func GetFloatingClientMeterAttributeUses(name string, uses *uint) int {
cName := goToCString(name)
var cUses C.uint
status := C.GetFloatingClientMeterAttributeUses(cName, &cUses)
*uses = uint(cUses)
freeCString(cName)
return int(status)
}
// GetFloatingClientMetadata gets the value of the floating client metadata.
//
// Parameters:
// - key: key of the metadata field whose value you want to retrieve
// - value: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE, LF_E_METADATA_KEY_NOT_FOUND
func GetFloatingClientMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetFloatingClientMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)
}
// RequestFloatingLicense sends the request to lease the license from the LexFloatServer.
//
// Returns: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL,
// LF_E_CALLBACK, LF_E_LICENSE_LIMIT_REACHED, LF_E_INET, LF_E_TIME, LF_E_CLIENT, LF_E_IP, LF_E_SERVER,
// LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
// LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED
func RequestFloatingLicense() int {
status := C.RequestFloatingLicense()
return int(status)
}
// GetFloatingClientLeaseExpiryDate gets the lease expiry date timestamp of the floating client.
//
// Parameters:
// - leaseExpiryDate: pointer to the integer that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE
func GetFloatingClientLeaseExpiryDate(leaseExpiryDate *uint) int {
var cLeaseExpiryDate C.uint
status := C.GetFloatingClientLeaseExpiryDate(&cLeaseExpiryDate)
*leaseExpiryDate = uint(cLeaseExpiryDate)
return int(status)
}
// DropFloatingLicense sends the request to the LexFloatServer to free the license.
//
// Call this function before you exit your application to prevent zombie licenses.
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_CALLBACK,
// LF_E_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, LF_E_SERVER,
// LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
// LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED
func DropFloatingLicense() int {
status := C.DropFloatingLicense()
return int(status)
}
// HasFloatingLicense checks whether any license has been leased or not. If yes,
// it returns LF_OK.
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE
func HasFloatingLicense() int {
status := C.HasFloatingLicense()
return int(status)
}
// GetHostConfig gets the host configuration.
//
// This function sends a network request to LexFloatServer to get the configuration details.
// Parameters:
// - hostConfig: pointer to the HostConfig struct that receives the value
//
// Returns: 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)
}
// GetFloatingLicenseMode gets the mode of the floating license (online or offline).
//
// Parameters:
// - mode: pointer to a string that receives the value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_BUFFER_SIZE
func GetFloatingLicenseMode(mode *string) int {
var cMode = getCArray()
status := C.GetFloatingLicenseMode(&cMode[0], maxCArrayLength)
*mode= ctoGoString(&cMode[0])
return int(status)
}
// RequestOfflineFloatingLicense sends the request to lease the license from the LexFloatServer for offline usage.
//
// The maximum value of lease duration is configured in the config.yml of LexFloatServer
//
// Parameters:
// - leaseDuration: value of the lease duration.
//
// Returns: LF_OK, LF_FAIL, LF_E_PRODUCT_ID, LF_E_LICENSE_EXISTS, LF_E_HOST_URL,
// LF_E_LICENSE_LIMIT_REACHED, LF_E_INET, LF_E_TIME, LF_E_CLIENT, LF_E_IP, LF_E_SERVER,
// LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
// LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED, LF_E_WMIC, LF_E_SYSTEM_PERMISSION,
// LF_E_LEASE_EXCEEDS_SERVER_LICENSE_EXPIRY
func RequestOfflineFloatingLicense(leaseDuration uint) int {
cLeaseDuration := (C.uint)(leaseDuration)
status := C.RequestOfflineFloatingLicense(cLeaseDuration)
return int(status)
}
// IncrementFloatingClientMeterAttributeUses increments the meter attribute uses of the floating client.
//
// Parameters:
// - name: name of the meter attribute
// - increment: the increment value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND,
// LF_E_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, LF_E_SERVER, LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED,
// LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
// LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED
func IncrementFloatingClientMeterAttributeUses(name string, increment uint) int {
cName := goToCString(name)
cIncrement := (C.uint)(increment)
status := C.IncrementFloatingClientMeterAttributeUses(cName, cIncrement)
freeCString(cName)
return int(status)
}
// DecrementFloatingClientMeterAttributeUses decrements the meter attribute uses of the floating client.
//
// Parameters:
// - name: name of the meter attribute
// - decrement: the decrement value
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND,
// LF_E_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, LF_E_SERVER, LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED,
// LF_E_SERVER_LICENSE_NOT_ACTIVATED, LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED,
// LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED
func DecrementFloatingClientMeterAttributeUses(name string, decrement uint) int {
cName := goToCString(name)
cDecrement := (C.uint)(decrement)
status := C.DecrementFloatingClientMeterAttributeUses(cName, cDecrement)
freeCString(cName)
return int(status)
}
// ResetFloatingClientMeterAttributeUses resets the meter attribute uses consumed by the floating client.
//
// Parameters:
// - name: name of the meter attribute
//
// Returns: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_HOST_URL, LF_E_METER_ATTRIBUTE_NOT_FOUND,
// LF_E_INET, LF_E_LICENSE_NOT_FOUND, LF_E_CLIENT, LF_E_IP, LF_E_SERVER, LF_E_SERVER_LICENSE_NOT_ACTIVATED,
// LF_E_SERVER_TIME_MODIFIED, LF_E_SERVER_LICENSE_SUSPENDED, LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER, LF_E_SERVER_LICENSE_EXPIRED
func ResetFloatingClientMeterAttributeUses(name string) int {
cName := goToCString(name)
status := C.ResetFloatingClientMeterAttributeUses(cName)
freeCString(cName)
return int(status)
}