Zentitle SDK and Library
LICENSE-CODE-BASICS-FEATURES

Pseudo-code for Nalpeiron Licensing using a license code, including
calls that provide basic info about various licensing features.
See C codekit, and here, for actual implementation details.

Pseudo-code docs in this series, illustrating various capabilities:
1) License Code Basics
2) Library Info Calls
3) Licensing Features (this page)
4) Licensing Analytics
5) Account Based Licensing (ABL) Basics

Library calls below are clickable; HOVER over comments or code for important tooltips.

// Library security constants
#define    XAUTH    111
#define    YAUTH    555
#define    ZAUTH    333
#define    CUSTID  4321
#define    PRODID   123 // last 5 digits of full ProductID, excluding any leading zeros
// Location of the licensing library
#define    LIBPATH    "/full/path/to/mylibrary.so"
// Directory where cache, license, log, and info files are stored
#define    WORKDIR    "/my/workdir"
// Logging level
#define    LOGLEVEL   "4"
// License code given to your customer
#define    LICENSECODE  "432100001817930859"
main()
{
    // 'security' is used along with the authentication values stamped into the
    // library to create a unique offset that is added to all returns (except
    // library open and Nalpeiron Analytics calls). Using a random number for
    // 'security' ensures that the offset is different for every run of your
    // software.
    security = 1 + (unsigned int)(500.0 * rand() / (RAND_MAX + 1.0));
    offset = XAUTH + ((security * YAUTH) % ZAUTH);
    // Load library
    libHandle = dlopen(LIBPATH, RTLD_LOCAL | RTLD_LAZY);
    // Open and initialize library
    returnValue = xxxNalpLibOpen(xmlParams, libHandle); // test return value, see code kits
    // Validate the library
    returnValue = xxxNSLValidateLibrary(custID, prodID, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    if ((returnValue < 0) || (licenseStatus <= 0)) // need to renew (reset lease) or get a license
    {
        returnValue = xxxNSLObtainLicense(LICENSECODE, licenseStatus, NULL, NULL, libHandle);
        returnValue = returnValue - offset; // test return value and licenseStatus, see code kits
    }
    // If the application has a valid license, app execution may proceed.
    // If the license has a finite lease period (typically hours, or days),
    // the license status will have to be checked periodically. The simplest
    // method is to set a lease period of one day, and just check license 
    // status at app startup as above (assumes app is started/stopped
    // once per day). See License Code Basics for another approach.
    FEATURES
    // 1) Normal - a normal feature is available, or not. Singular.
    // 2) Floating - like Normal, but is checked out and returned when finished.
    // 3) Element Pool - like Floating, but plural: more than one may be checked out and returned.
    // 4) Consumption Token - like Element, but checked out tokens are consumed (un-returnable).
    // 5) Secure Store - An encrypted area in the license file to read and write a custom string.
    // Check current license for status of featureName (returned in featureStatus)
    returnValue = xxxNSLGetFeatureStatus(featureName, featureStatus, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Checkout a floating feature
    returnValue = xxxNSLCheckoutFeature(featureName, featureStatus, auth, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Return a floating feature
    returnValue = xxxNSLReturnFeature(featureName, auth, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Check Out a Resource Quantity from an Element Pool
    returnValue = xxxNSLCheckoutPool(poolName, poolAmt, poolStatus, auth, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Return a specified number of elements to an Element Pool
    returnValue = xxxNSLReturnPool(poolName, poolAmt, auth, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Withdraw a specified number of consumption tokens from a Token Pool
    returnValue = xxxNSLCheckoutTokens (tokenPoolName, tokenAmt, tokenPoolStatus, auth, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Consume a specified number of consumption tokens already drawn from a Token Pool
    returnValue = xxxNSLConsumeTokens(tokenPoolName, tokenAmt, auth, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Get the number of tokens checked out to current system, along with the status of the Token Pool
    returnValue = xxxNSLGetTokenInfo(tokenPoolName, tokenMax, tokenAmt, tokenPoolStatus, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Read binary string from an encrypted area of the license file
    returnValue = xxxNSLReadSecStore(rawKey, storeName, storeValue, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits
    // Write binary string to an encrypted area of the license file
    returnValue = xxxNSLWriteSecStore(storeSize, rawKey, storeName, storeValue, libHandle);
    returnValue = returnValue - offset; // test return value, see code kits

    // Return a concurrent (cloud) or network license just before the application exits
    returnValue = xxxNSLReturnLicense(LICENSECODE, licenseStatus, libHandle);
    returnValue = returnValue - offset;
    // Close the library just before the application exits
    returnValue = xxxNalpLibClose(libHandle); // see code kits for additional cleanup
}