Chapter 3. FLEXlm Function Calls

lc_auth_data

Syntax

config = lc_auth_data(job, feature)

Description

Gets the license file line for a feature that has been checked out.

Parameters

(LM_HANDLE *) job 


from lc_init, or lm_job

(char *) feature  

The desired feature.

Return

(CONFIG *) config 


The config structure, or NULL if error. The config structure is defined in the header file lm_client.h in the /lmgr/machind directory or \LMGR(32)\H directory on Windows/NT systems.

Error Returns

LM_FUNCNOTAVAIL 


Vendor keys do not support this function.

LM_NOFEATURE 


Feature not found.


Note: If you call lc_checkout() with the LM_CO_LOCALTEST flag, then use the alternate function lc_test_conf() to retrieve the license file line for the tested feature. This can only be done after the most recent call to lc_checkout(). lc_test_conf() takes a job handle parameter and returns a (struct CONFIG *).


See also

  • “lc_get_config”

  • lm_client.h in the /lmgr/machind directory for the CONFIG struct definition.

lc_baddate

Syntax

status = lc_baddate(job)

Description

Checks the / and the /etc directories for any files which have dates in the future. On Windows and Windows NT systems, “\” and the Windows home directory are scanned. If no files have dates in the future, returns 0, otherwise returns 1. lc_baddate() allows a “grace period” of 24 hours, i.e. it will not report on files which are only 24 hours in the future.

lc_baddate() can be used in your client code, or in a daemon initialization routine to deny access on systems with dates that are set back.


Note: This function is available on UNIX and Windows/NT systems only.


Parameters

(LM_HANDLE *) job  


From lc_init()

Return

(int) status - 0 

OK, all files have dates in the past.

<> 0 

Error - some files have dates in the future.

lc_checkin

Syntax

status = lc_checkin(job, feature,keep_conn)

Description

Checks in the licenses of the specified feature. For TCP clients, the daemon will detect the fact that the client exited, and return any licenses that were checked out back to the available pool. For TCP, this call is used if the application has need of a feature for a period of time, then no longer needs it. For UDP, this call is essential to free a license, otherwise, the server has to timeout the license. The second parameter is used for TCP clients to tell FLEXlm to keep the connection open to the server for cases where another feature will be needed shortly after this one is released. If the communications protocol is TCP, there is no appreciable time delay incurred in returning the license if the program exits rather than returning the license via lc_checkin. However if UDP is used, the licenses will not be returned to the pool for LM_A_UDP_TIMEOUT seconds.

Parameters

status = lc_checkin(job, feature,keep_conn)(LM_HANDLE *) job 


From lc_init()

(char *) feature 

The feature name to be checked in.

(int) keep_conn 

If non-zero, means “Keep connection to server”; if 0, drops TCP connection. Unused for UDP.

Return

(int) status - 0 

OK, license checked in.

<> 0 

Error.

Error Returns

LM_CHECKINBAD 


The checkin function failed due to an error at the license server or in communications with the server.

lc_checkout

Syntax

LM_CODE(key, ...)
status = lc_checkout(job, feature, version, num_licenses, flag, key, dup_group)

Description

Checks out one (or more) license(s) of the specified feature and, for counted licenses, keeps the daemon up-to-date on the status of the process using the license(s). If the process that calls lc_checkout (via TCP) exits in any manner, then the checked out license will be returned for re-use by another user. [1] Place the call to lc_checkout in a part of your code that is active whenever the user is using the feature. If flag is specified as LM_CO_WAIT, then the process will wait until the number of licenses requested for this feature are available. The license file must specify a version that is greater than or equal to the version in the lc_checkout call.

If the license file is counted, that is, if the number of users specified on the FEATURE line is more than 0, lc_checkout will request the license from a license server. If the number of users on the FEATURE line is 0, it will grant permission based on the contents of the license file only—hostid, version, expiration date, etc.


Note: Multiple checkout requests from the same process in the same license job will not result in additional licenses being checked out, unless a new request specifies more licenses than were previously checked out. That is, two calls to lc_checkout(...,1,...); will result in only 1 license being checked out, not 2. A second call to request 2 licenses would result in a total of 2 licenses.



Note: For improved security, it is recommended that the parameters feature, version, etc., be “hidden”- the string should not be directly declared in source code. It should be built up chars or smaller strings, and then created via sprintf(). That way users cannot steal licenses by changing the string in the binary.


Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) feature 

The ASCII feature name desired.

(char *) version 

The version of the feature desired in floating point format, 3 decimal places max, e.g.: “12345.123”. This value must be <= the version number in the license file for the checkout to succeed.


Note: letters are not allowed in versions; “v1.0” is illegal.



Note: Before FLEXlm v4.0, the version argument for lc_checkout() is of type double.


(int) num_licenses 


The number of licenses to check out.

(int) flag  

The checkout option flag.

Possible values for flag are:

LM_CO_NOWAIT 


Do not wait—non-blocking.

LM_CO_WAIT 


Wait, return when license is granted—blocking.

LM_CO_QUEUE 


Queue request, return immediately. This request will give you the license if it is available. You can find out if you hold the license by calling lc_status().

LM_CO_LOCALTEST 


Perform local tests, but do not check out a license (return status). The status from this call will detect all checkout errors that can be determined from the license file only. In particular, MAXUSERS is not detected.

(VENDORCODE *) key 


The first argument to LM_CODE, which includes the vendor's encryption seed for this feature.

(int) dup_group 

Duplicate grouping mask for this feature

Requests for licenses from “duplicates” can either be “grouped”, or not “grouped”. Grouping duplicates allows license requests from separate processes to use a single license if the process's USER, HOST, DISPLAY, and/or VENDOR_DEFINED field are the same. The dup_group parameter allows you to select what to compare to constitute a group from the set {USER HOST DISPLAY VENDOR}. Any of the four fields that are not set to compare will automatically “match”; thus not setting any of the four fields yields a site license, since all users on all hosts on all displays are the same as far as the comparison is concerned. The following illustrates the use of the duplicate grouping capability:

dup_group value Meaning

LM_DUP_NONE 


Every process gets a new license. (Same as v1.x: count_duplicates = 1)

LM_DUP_USER 


All requests from this user name share the same license.

LM_DUP_HOST 


All requests from this host name share the same licenses. This is a “floating node-locked” license.

LM_DUP_DISP 


All requests from this display share the same license. (Useful for display or GUI based products, like a window system.)

LM_DUP_VENDOR 


All requests with the same vendor-defined data, such as a process ID (PID) use the same license. (Useful for sharing licenses among otherwise unrelated processes.)

LM_DUP_USER | LM_DUP_HOST 


All requests from this user name on this host name use the same license.

LM_DUP_HOST | LM_DUP_DISP 


All requests from this display on this host name use the same license.

LM_DUP_USER| LM_DUP_DISP 


All requests from this user name on this display use the same license. (One user, displaying on a single node, using several nodes to run the software.)

LM_DUP_USER | LM_DUP_HOST | LM_DUP_DISP 


All requests from this user name on this host name using this display use the same license.

LM_DUP_USER | LM_DUP_VENDOR 


All requests from this user name with the same vendor data use the same license.

LM_DUP_SITE 


All requests from any user on any node on any display with any vendor data use the same license. (SITE LICENSE)

The first client that checks out the feature specifies the duplicate grouping for the feature. (The duplicate grouping value is reset whenever all licenses are checked back in.) Any subsequent client that attempts to check out the feature with a different duplicate grouping mask will be rejected and an error reflecting this will appear in the lmgrd Debug log file.

Return

(int) status 

0 - OK, license checked out.

<> 0 

Error.

Error Returns

LM_BADCODE 


License key in license file does not match other data in file.

LM_BADFILE 

Counted feature not supported (returned by lc_node_lock() only).

LM_BADHANDSHAKE 


Encryption handshake with daemon failed.

LM_BADVERSION 


Version argument is invalid floating point format.

LM_BADPARAM 


“key” structure is incorrect type, or feature == NULL.

LM_BUSYNEWSERV 


License server busy starting another copy of itself—retry.

LM_CANTCONNECT 


Cannot establish a connection with a license server.

LM_FEATQUEUE 


Feature is queued. lc_status will determine when it is available.

LM_FUNCNOTAVAIL 


Vendor keys do not support this function.

LM_LOCALFILTER 


Checkout request filtered by the vendor-defined filter routine.

LM_MAXUSERS 


All licenses in use.

LM_NO_SERVER_IN_FILE 


No license server specified for counted license.

LM_NOFEATURE 


Can not find feature in the license file.

LM_NOSERVSUPP 


Server has different license file than client —client's license has feature, but server's does not.

LM_OLDVER 

License file does not support a version this new.

LM_SERVBUSY 


License server busy— the request should be retried. (This is a rare occurrence.)

lc_ck_feats

Syntax

stat = lc_ck_feats(job, vendor)

Description

Checks the FEATURESET line for a given vendor.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) vendor 

The vendor to be checked.

Return

(int) stat 

Status of the FEATURESET line: 1 if OK, 0 if bad.

Error Returns

LM_NOFEATSET 


No FEATURESET line found for this vendor.

LM_CANTCOMPUTEFEATSET 


Cannot compute FEATURESET code for this vendor

LM_BADFEATSET 


The code on the FEATURESET line is incorrect.

LM_FUNCNOTAVAIL 


Vendorkeys do not support FEATURESET.

lc_crypt

Syntax

CONFIG conf;
char *sdate;
LM_CODE(code, ...)	
enc_code = lc_crypt(job, &conf, sdate, &vc);

Description

Computes the license key for a FLEXlm feature line. lc_crypt() is one of the FLEXlm standard encryption routines, along with lc_crypstr(). It takes its input parameters and creates the license key that appears in the license file. Vendors generally will not call lc_crypt() directly, unless they are writing a custom license generation program, in which case create_lic.c should be used as a guide.

The CONFIG * parameter should be a pointer to a struct that has been correctly filled in. To do so, first make sure it is set to zeroes with memset(&conf, 0, sizeof(conf)). Then fill in each item in the struct, using the definition as it appears in lm_client.h, and noting that many items are now optional, and do not need setting.

The sdate parameter can be obtained by calling l_bin_date() with the date string, e.g.

l_bin_date("1-jan-93");

To obtain the start date from a license file license key (The 20-character code on the FEATURE line), use l_extract_date():

char code[21];
l_extract_date(code);

The last, VENDORCODE * argument must be set up as in the following example:

LM_CODE(code, ENCRYPTION_CODE_1, ENCRYPTION_CODE_2, VENDOR_KEY1,
VENDOR_KEY2, VENDOR_KEY3, VENDOR_KEY4, VENDOR_KEY5);
VENDORCODE vc;
/*...*/
memcpy((char *)&vc, (char *)&code, sizeof(vc));
vc.data[0] ^= VENDOR_KEY5;
vc.data[1] ^= VENDOR_KEY5;
lc_crypt(job, &conf, l_bin_date(0), &vc);


Note: This use of VENDOR_KEY5 is new to FLEXlm v4.0, and is a security precaution taken mostly for dynamic linking environments, which allow access to arguments of FLEXlm functions.


Parameters

(LM_HANDLE *) job 


FLEXlm job, from lc_init()

(CONFIG *) conf 


Filled-in CONFIG structure pointer.

(char *) sdate  

Start date, in coded format. See below.

(VENDORCODE *) vc 


Vendor's encryption seeds (from lm_code.h), where the data[0] and data[1] members have been XORd (“^”) with VENDOR_KEY5.

Return

(char *)enc_code 


The license key, which should match the license file.

(char *)NULL 

Error.

Error Returns

LM_CANTMALLOC 


malloc() call failed.

lc_cryptstr

Syntax

status = lc_cryptstr(job, str, return_str, code, flag, filename, errors)

Description

Generates license file as a string with license keys filled in. This new function is used by the lmcrypter command, and for some vendors will be an easier interface than lc_crypt() for generating licenses. You pass a string, which is a whole, valid license file, with one exception: each 20-character code must be replaced with a single `0' (zero).

If flag has LM_CRYPT_ONLY set, then the function returns the 20-character code for the first FEATURE, INCREMENT, PACKAGE, or UPGRADE line in the file. If !(flag & LM_CRYPT_ONLY), then the whole file is returned as a string, with valid 20-character codes. If flag has LM_CRYPT_FORCE set, then every line will have the 20-character code re-computed, even if the code is not set to `0' If LM_CRYPT_FORCE is set, and if a line already has a 20-character code, the start-date will be taken from the current code.

Comment lines are retained in the return_str output.

return_str and errors are malloc'd by lc_cryptstr(), and not reused by FLEXlm, so it is the responsibility of the programmer to free the space returned if needed.

If you want to specify a start-date, then, in place of a `0' in the 20-character code, use the following syntax:

start:dd-mmm-yyy.

Example

start:1-jan-95

Parameters

(LM_HANDLE *) job 

From lc_init.

(char *)str  

Set str to a complete valid license file, where the 20-character codes are replaced with `0'.

(char **) return_str 


Resulting license file string. Malloc'd by lc_cryptstr, and freed by the calling program. Pass the address of a char pointer.

(VENDORCODE *) codw 


From LM_CODE macro, with code.data[0] and code.data[1] XOR'd with VENDOR_KEY5.

(int) flag 

mask which can be binary OR'd (`|') with the following flags:

LM_CRYPT_ONLY 


If true, only return 20-char crypt code for first FEATURE in str

LM_CRYPT_FORCE 


if true, recompute the 20-character license key for every line, even if the license key is already computed.

(char *) filename 


for error reporting, or (char *)0.

(char **) errors 

for error reporting, or (char **)0. If there are errors, the return value is non-zero, and errors is set to an explanatory string. Malloc'd by lc_cryptstr, and freed by the calling program. Pass the address of a char pointer.

Return

(int) status 

0 == success, else errors is set to an explanatory string.

Error Returns

Since different errors can occur on every line of the input str, lc_cryptstr must be able to report all these errors independently, and does so via the errors parameter. Most reported errors will result in no generated license key, but some act as warnings, and license keys are still generated. Here is an example of error reporting:

Input: 

FEATURE f1 demo 1.a50 01-jan-99 0 0 HOSTID=08002b32b161

Error reported:

stdin:line 1:Bad version number - must be floating point number, with no letters

With this error, no 20-character license key is generated and return_str will be the same as the input str.


Note: Before calling lc_cryptstr(), add the following code:


LM_CODE(code, ENCRYPTION_CODE_1, ENCRYPTION_CODE_2, VENDOR_KEY1,
VENDOR_KEY2, VENDOR_KEY3, VENDOR_KEY4, VENDOR_KEY5);
VENDORCODE vc;
[...]
(void) memcpy((char *)&vc, (char *)&code, sizeof(vc));
vc.data[0] ^= VENDOR_KEY5;
vc.data[1] ^= VENDOR_KEY5;
lc_cryptstr(job, ., &vc, ..); /* for example */

lc_disconn

Syntax

status = lc_disconn(job, flag)

Description

Drops the connection to the server. A count of “logical” connections is maintained, and if other features are active, the connection is maintained, unless flag is non-zero.

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) flag 

Non-zero to force disconnection.

Return

(int) status 

<0 -> error

 

== 0 -> success

 

> 0 -> # of “logical” connections remaining.

lc_display, lc_hostname, lc_username

Syntax

lc_display(job, flag)
lc_hostname(job, flag)
lc_username(job, flag)

Description

Returns environment information about the current process.

Parameters

(LM_HANDLE *) job 

From lc_init()

(int) flag 

0 - Return system's idea of value.
!= 0 - Return FLEXlm's idea of value.

Return

(char *) 

Display name, host name, or user name.

lc_errstring

Syntax

string = lc_errstring(job)

Description

Returns the FLEXlm error string for the most recent FLEXlm error, along with the major and minor error number. If a UNIX error is involved, the UNIX error description will also be included in the message, along with the UNIX errno.

Parameters

(LM_HANDLE *) job 

From lc_init()

Return

(char *) string 

The FLEXlm error string text.

Examples

No such feature exists (-5,116)
Cannot find license file, (-1,73:2), No such file or directory

See also

lc_feat_list

Syntax

list = lc_feat_list(job, floating, dupaction)

Description

Gets the list of all features in the license file.

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) floating 

If non-zero, list only floating features.

(void) (*dupaction)() 


Action routine called when a duplicate feature is found. This routine is called upon the second occurrence of any feature name.

Return

(char **) list 

List of features. list is a pointer to a NULL-terminated array of feature string pointers. Both the pointers and the string data are malloc'd; this memory is freed upon a subsequent call to lc_feat_list(). Do not free this data. If NULL, an error has occurred.

The dupaction() callback routine is called with two parameters:

(*dupaction)(feature, daemon)

where:  

is the:

(char *) feature 

feature name

(char *) daemon 


daemon for “feature”

Error Returns

LM_CANTMALLOC 


malloc() call failed.

LM_NOFEATURE 


Specified feature not found.

lc_feat_set

Syntax

line = lc_feat_set(job, daemon, code, codes)

Description

Computes the FEATURESET code for the specified daemon, if codes is NULL. If codes is a pointer to a char *, the pointer is set to an array of 20-character license keys for each FEATURE line for this daemon.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) daemon 


The daemon desired.

(VENDORCODE *) code  


Vendor's encryption seeds from LM_CODE macro.

(char **) codes 

Concatenated license keys (returned). If a pointer to a char * is passed, this gets set to a string which is a concatenation of the 20-character license keys for each FEATURE line for this vendor daemon—to be used for calculating a checksum using your own checksum algorithm.

Return

(char *) line  

The FEATURESET line for the license file, or NULL for error.

Error Returns

LM_CANTMALLOC  


malloc() call failed.

lc_first_job, lc_next_job

Syntax

LM_HANDLE *job
job = lc_first_job(job);
while (job)
{
/*processing*/
job = lc_next_job(job);
}

Description

lc_first_job() and lc_next_job() are used to walk the list of jobs. This only works properly if all calls to lc_init() have a pointer to the current job as the first parameter.

Parameters

(LM_HANDLE *) job 


current job

Return

(LM_HANDLE *) job 


next currently active job, or (LM_HANDLE *)0 if end.

Error Returns

None

lc_flush_config

Syntax

lc_flush_config(job)

Description

Flushes the in-memory license file data. lc_flush_config() could be used in an application that wished to change the license file location (see lc_set_attr()) while running. A license creation program that creates several license files while running is an example of such a program.


Note: Do not use lc_flush_config() after a successful checkout—this can result in a core dump. Applications cannot reread the license file after a successful checkout. For this reason this function has limited utility.


Parameters

(LM_HANDLE *) job 


From lc_init()

Return

None

Error Returns

LM_BADFILE 

License file corrupted.

LM_BAD_VERSION 


Invalid FLEXlm version format in license.

LM_NOCONFFILE 


License file does not exist.

LM_NOFEATURE 


Specified feature does not exist

LM_NOREADLIC 


Cannot read license file.

LM_SERVNOREADLIC 


Cannot read license data from license server.

lc_free_daemon_list

Syntax

lc_free_daemon_list(job, daemons)

Description

Frees a list of daemons returned by lc_get_dlist()

Parameters

(LM_HANDLE *) job 


From lc_init()

(DAEMON *)daemons 


return value from lc_get_dlist()

Return

None

Error Returns

None

lc_free_job

Syntax

lc_free_job(job_handle)

Description

lc_free_job() frees the memory associated with a job, which has been allocated by lc_init(). This call is only needed by an application that uses a large number of jobs over its lifetime.

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

None

Error Returns

LM_BADPARAM 


no such job

lc_get_attr

Syntax

#include "lm_attr.h"
status = lc_get_attr (job, key, value)

Description

Retrieves a FLEXlm attribute. The key describes which attribute to retrieve, and the value is a pointer to the value for the attribute. See lm_attr.h for key constants and value types.


Note: value must be a pointer to the correct attribute type, and should be cast to a (short *).



Note: Types of char * are handled a little differently than other types. Types of int or short are declared, and a pointer to the declared variable is passed as an argument. Types of char * are declared as char *, and the variable itself is passed.


Parameters

(LM_HANDLE *) job 


From lc_init()

(int) key  

Which attribute to get.

Return

(short *) value  

Value of the attribute (cast to appropriate type).

(int) status 

0 - OK, <>0, error.

Error Returns

LM_NOSUCHATTR 


No such attribute exists.

LM_NOADMINAPI 


LM_A_VD_GENERIC_INFO or LM_A_VD_FEATURE_INFO only—request was made to other company's vendor daemon.

LM_NOSERVSUPP 


LM_A_VD_GENERIC_INFO or
LM_A_VD_FEATURE_INFO only—pre-v4.0 server does not support these requests.

lc_get_config

Syntax

config = lc_get_config(job, feature)

Description

Gets the license file data for a given feature. FLEXlm allows multiple valid FEATURE and INCREMENT lines (of the same feature name) in a license file. lc_get_config() will return the first, and lc_next_config() retrieves the rest, or lc_next_config() can also find the first and remaining.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) feature  

The desired feature.

Return

(struct config *) config 


The config structure. If no feature found, then NULL. The config structure is defined in the header file lm_client.h in the /lmgr/machind directory.

Error Returns

LM_NOFEATURE 


Specified feature does not exist

LM_NOCONFFILE 


License file does not exist.

LM_BADFILE 


License file corrupted.

LM_NOREADLIC 


Cannot read license file.

LM_SERVNOREADLIC 


Cannot read license data from license server.

lc_get_errno

Syntax

error = lc_get_errno(job)

Description

The most recently set FLEXlm error is obtainable via lc_get_errno(). This can be used after any FLEXlm function.

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

(int) error 

See lm_client.h for a list of possible FLEXlm errors

See also

lc_get_dlist

Syntax

DAEMON *daemons;
daemons = lc_get_dlist(job)

Description

lc_get_dlist() gets a list of all vendor daemons from the current license file. The DAEMON structure returned should be freed when it is no longer required with a call to lc_free_daemon_list(daemon).

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

(DAEMON *) daemon 


A list of all vendor daemons, or NULL, if none found.

See also

lc_get_feats

Syntax

fs_code = lc_get_feats(job, vendor)

Description

Gets the license key from the FEATURESET line for the specified vendor.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) vendor 

The vendor name.

Return

(char *) fs_code 

The code from the FEATURESET line for this vendor.

Error Returns

LM_NOFEATURE 


FEATURESET line for requested vendor cannot be found.

lc_gethostid

Syntax

hid = lc_gethostid(job)

Description

Returns the hostid for the local host. lc_gethostid() is simply a call to lc_getid_type(default_hostid_type);

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

(HOSTID *) hid 


A pointer to the hostid structure, filled in for the current host.

Error Returns

LM_CANTFINDETHER 


Cannot find ethernet device. If this error is returned, a pointer to a HOSTID struct with a type field of “NOHOSTID” will be returned.

See also

lc_getid_type

Syntax

hid = lc_getid_type(job, idtype)

Description

Returns the HOSTID of the specified type for the local host.

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) idtype 

The requested hostid type (see lm_client.h in the /lmgr/machind directory). Types are:

HOSTID_LONG 


Longword hostid, e.g., SUN

HOSTID_ETHER 


Ethernet address, e.g., VAX

HOSTID_USER 


Username.

HOSTID_DISPLAY 


Display name.

HOSTID_HOSTNAME 


Node name.

HOSTID_ID_MODULE 


HP300 Id-Module hostid

HOSTID_STRING 


string ID, MAX HOSTID_LEN, used for SCO

HOSTID_SENTINEL_KEY 


Hardway key

HOSTID_DISK_SERIAL_NUM 


Windows and NT disk serial number

HOSTID_INTERNET 


Internet IP address

HOSTID_VENDOR 


Start of Vendor-defined hostid types.

Return

(HOSTID *) hid 


A pointer to the hostid structure, filled in for the current host. (See lm_client.h in the /lmgr/machind directory for the definition of the HOSTID struct.)

Error Returns

LM_CANTFINDETHER 


Cannot find ethernet device.


Note: lc_getid_type() does NOT process either “ANY” or “DEMO” hostid types.


See also

lc_hosttype

Syntax

htype = lc_hosttype(job, benchmark)

Description

Returns information about the local host.

Some typical results when benchmark is set:

Sun 3/50, OS 3.5: 28
Sun Sparcstation 1+, OS 4.0.3: 101
Next OS V1: 68

The number in the vendor_speed field is the manufacturer's stated integer MIP performance (or 0, if no value is available).

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) benchmark 


Controls whether the internal FLEXlm benchmark is to be run. If benchmark is 0, no benchmark is run, otherwise the benchmark is run. The benchmark uses SIGVTALRM, and runs for approximately 0.5 seconds. If this interferes with your application, or if you do not use the benchmark result, then set benchmark to 0 when calling lc_hosttype().

Return

(HOSTTYPE *) htype 


A pointer to the hosttype structure, filled in for the current host. If lc_hosttype() cannot determine the host type, it will return a pointer to a HOSTTYPE struct with a type of LM_UNKNOWN.

Error Returns

LM_FUNCNOTAVAIL 


Vendor keys do not support this function.

lc_idle

Syntax

lc_idle(job, flag)

Description

Informs FLEXlm when the process is idle. lc_idle() enables the end-user feature inactivity TIMEOUT to allow idle licenses to be reclaimed. Use of lc_idle() is recommended for end-users to take advantage of the TIMEOUT option. lc_idle() also affects vendor daemon timeout of UDP clients.

lc_idle() can be used to bracket a portion of the application code that prompts for user input, so that when the user is not using the application, the FLEXlm daemon can detect the fact that the application is idle. lc_idle only sets a flag internally in the application. It is therefore safe to call as often as necessary.

A typical use would be:

lc_idle(1);/* Process is idle now */
... get input from user...
lc_idle(0);/* Process is no longer idle */

Parameters

(int) flag 

0 if process is not idle, non-zero if process is idle

Return

None.


Note: There is no detection of license loss (due to daemon shutdown, etc.) while the application is “idle”. UDP clients can inadvertently lose their license if the application is idle longer than LM_A_UDP_TIMEOUT. When the application is active again, the license, if it is still available, will be re-checked out.


lc_init

Syntax

#include "lm_code.h"
LM_CODE(code, ENCRYPTION_CODE_1, ENCRYPTION_CODE_2, VENDOR_KEY1,
	VENDOR_KEY2, VENDOR_KEY3, VENDOR_KEY4, VENDOR_KEY5);
LM_HANDLE *job = (LM_HANDLE *)NULL;
status = lc_init(job, VENDOR_NAME, &code, &job)

Description

Initializes FLEXlm and creates a license “job.” Subsequent calls to lc_init() create new license jobs. Each license job is independent.


Note: lc_init() MUST be the first FLEXlm call you make in your application. Do NOT call lc_set_attr() or lc_get_attr() before calling lc_init().



Note: The encryption seeds that you use in your lc_init() call MUST be the same as the first set of encryption seeds in your vendor daemon (ls_vendor.c). Otherwise, a “Bad encryption handshake with daemon” error will result from a checkout request.


Parameters

(LM_HANDLE *) job 


Must be NULL on first call to lc_init -- thereafter the current job.

(char *) vendor_id 


VENDOR_NAME (from lm_code.h)

(VENDORCODE *) vendor_key  


The vendor's encryption seed and the FLEXlm vendor keys from the LM_CODE macro.

Return

pointer to (LM_HANDLE *) job 


Set to job for the current process. This is used as the first argument to all subsequent lc_xxx() functions.

(int) status  

Value of lc_get_errno() after initialization is complete, 0 if successful.

Error Returns

LM_BAD_TZ 

Time zone offset from GMT is > 24 hours (implies a user is attempting to cheat)

LM_BADPLATFORM 


Vendor keys do not support this platform.

LM_BADKEYDATA 


Bad vendor keys.

LM_BADVENDORDATA 


Unknown vendor key type.

LM_CANTMALLOC 


malloc() call failed.

LM_DEMOKIT 


Demo kit (informational only)

LM_EXPIRED_KEYS 


Vendor keys have expired.

LM_FUNCNOTAVAIL 


Second call to lc_init() (multiple jobs), and vendor keys do not support multiple jobs.

LM_KEY_NO_DATA 


Vendor key data not supplied.

LM_LIBRARYMISMATCH 


lm_client.h/liblmgr.a version mismatch.

LM_NONETWORK 


Networking software not available on this machine.

LM_OLDVENDORDATA 


Old vendor keys supplied.

lc_isadmin

Syntax

stat = lc_isadmin(job, user)

Description

Verifies that the specified user is a license administrator. A “license administrator” is a member of the “lmadmin” group. If there is no lmadmin group in the /etc/groups file, then anyone in group 0 is a license administrator.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) user 

Login name of user to test.

Return

(int) 

Indication of whether the user is an administrator: 0 if the user is not an administrator, <>0 if an administrator. Always returns 1 on VMS.

lc_lic_where

Syntax

path = lc_lic_where(job)

Description

Returns pathname of FLEXlm license file. This function does not support the colon-separated list in the LM_LICENSE_FILE environment variable — it only reports on the first file in the list. Use lc_get_attr(LM_A_LF_LIST,...) for full list.

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

(char *) path 

Path of the license file that FLEXlm will use. Note—This returned string must not be modified by the caller.

(char *)NULL 

No license file set

lc_log

Syntax

lc_log(job, msg)

Description

Logs a message in the FLEXlm log file.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) msg 

The message to be logged. The maximum length of the string is LM_LOG_MAX_LEN (see lm_comm.h)

Return

None.

Error Returns

LM_NOSOCKET 


Communications failure to daemon.

LM_CANTWRITE 


Write error sending message to daemon.

See also

lc_master_list

Syntax

list = lc_master_list(job)

Description

Returns the list of server nodes.

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

(LM_SERVER *) list 


List of the server nodes. If NULL, error code is in lc_get_errno().

Error Returns

LM_NO_SERVER_IN_FILE 


No SERVER lines in license file.

LM_BADFILE 

Server hostname too long (> MAX_HOSTNAME)

See also

  • lm_client.h in the /lmgr/machind directory for the definition of LM_SERVER struct.

  • “LM_A_MASTER”

lc_next_conf

Syntax

config = lc_next_conf(job, feature, pos)

Description

Returns the next line in the license file matching “feature.” The search is started from “pos”.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) feature  

The desired feature line.

(long *) pos 

Position to start search.

 

(0L to start at first entry).

Return

(struct config *) config 


The config structure. If none found, then NULL.

(long *) pos 

Updated to next license file entry.

Error Returns

(See lc_get_config().)


Note: lc_get_config (feature) is equivalent to: pos = 0L; lc_next_config(feature, &pos).


lc_perror

Syntax

lc_perror (job, string)

Description

Prints a FLEXlm error message, in the same format as the UNIX routine perror(), e.g.:

"string": FLEXlm error-string

If a UNIX error has also occurred, it will be included in the message.

On Windows and Windows NT systems, a message box of type MB_OK will be displayed with the FLEXlm error message. If the last error was a system error, rather than a FLEXlm error, then the error string above will be a UNIX,Windows, or Windows NT error string. The FLEXlm error messages are available by calling lc_errstring().

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) string 

The first part of the error message, as above.

Return

None.

lc_remove

Syntax

status = lc_remove(job, feature, user, host, display)

Description

Removes the specified user's license for feature. This is used by the lmremove command, and has the same restrictions regarding lmadmin group. lc_remove normally is only used when the client's system has had a hard crash, and the server does not detect the client node failure. If lc_remove is called on a healthy client, the license will be re-checked out by the client with its next heartbeat.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) feature 

Remove the license for this feature.

(char *) user 

User name to remove.

(char *) host 

User's host name to remove.

(char *) display 

User's display name to remove.

Return

(int) status  

0 - OK, !=0, error status

Error Returns

LM_BADCOMM 


communications error

LM_BADPARAM 


no licenses issued to this user

LM_CANTCONNECT 


Cannot connect to license server.

LM_CANTREAD 


Cannot read from license server.

LM_CANTWRITE 


Cannot write to license server.

LM_NOFEATURE 


Feature not found in license file data.

LM_NOTLICADMIN 


failed because user is not in lmadmin group.

LM_REMOVETOOSOON 


failed because ls_min_lmremove time has not elapsed.

lc_set_attr

Syntax

#include "lm_attr.h"
status = lc_set_attr(job, key, (LM_A_VAL_TYPE)value)

Description

Sets a FLEXlm attribute. The key describes which attribute to set, and the value is the value for the attribute. See the header file lm_attr.h for key constants and value types.

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) key 

Which attribute to set.

(LM_A_VAL_TYPE) value 


Value to set it to. Values should be of the appropriate type for the particular attribute (see lm_attr.h), but should be cast to LM_A_VAL_TYPE.

Return

(int) status 

0 - OK, !=0, error.

Error Returns

LM_FUNCNOTAVAIL 


Vendor keys do not support this function.

LM_BADPARAM 


Specified parameter is incorrect.

LM_NOCONFFILE 


Specified license file cannot be found (LM_A_LICENSE_FILE or LM_A_LICENSE_FILE_PTR)

LM_NOSUCHATTR 


Specified attribute does not exist.

lc_set_errno

Syntax

lc_set_errno(job, error)

Description

The FLEXlm error is settable via lc_set_errno(). This should not normally be used, since the error should be set by the FLEXlm libraries.

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) error 

See lm_client.h in the /lmgr/machind directory for a list of possible FLEXlm error codes.

Return

(void)  

none

See also

lc_shutdown

Syntax

status = lc_shutdown(job, prompt, print)

Description

Shuts down the FLEXlm servers. This is used by lmdown.

Parameters

(LM_HANDLE *) job 


From lc_init()

(int) prompt 

<> 0 => ask if server should be shut down.

(int) print 

<> 0 => prints which nodes are shut down.

Return

(int) status 

0 - server not shutdown <> 0 - server shut down.

Error Returns

LM_FUNCNOTAVAIL 


Vendor keys do not support this function.

LM_FUNCNOTAVAIL 


(VMS)—This function is not available on VMS.

LM_NOTLICADMIN 


You are not an authorized license administrator.

LM_CANTREAD 


Cannot read data from license server.

lc_startup

Syntax

status = lc_startup (job, lmgrd_path, logfile, license_file)

Description

lc_startup() starts lmgrd from within your program. lc_startup() does not report the success of the lmgrd process. lc_startup() calls the appropriate system() call given its arguments, and is unable to detect success of the system() call, since the process is started in the background.


Note: lc_startup() is available on UNIX systems only. lc_startup() works for non-redundant servers only, and only if the application is running on the license server node.


Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) lmgrd_path  


The pathname to lmgrd.

(char *) logfile 

The daemon log file location. (Passing a NULL string or a NULL pointer will cause the Debug log file to go to stdout, which is probably not what you want.). If the first character is `+', then the logfile will be appended, if it exists. If the logfile does not exist, it will be created.

(char *) license_file 


The location of the license file (NULL for default).

Return

(int) status 

0 - lmgrd_path NULL

 

<> 0 - startup of lmgrd attempted.

lc_status

Syntax

status = lc_status (job, feature)

Description

Returns the status of the requested feature.

This call is used primarily when QUEUEing for a license. Normally QUEUEing is done in the following manner:

rc = lc_checkout(....LM_CO_NOWAIT,...);
if (rc && lc_get_errno(job) == LM_MAXUSERS)
{
printf("Waiting for license...");
rc = lc_checkout(....LM_CO_WAIT,...);
}

However, in this example the application must wait in the lc_checkout call. If the application needs to continue doing processing, you can use lc_status() to periodically check on the status. This might be coded in the following manner:

rc = lc_checkout(...,LM_CO_QUEUE,...)
switch (rc) 
{
case 0:
break; /* got the license */
case LM_MAXUSERS:
case LM_USERSQUEUED:
case LM_FEATQUEUE:
printf("Waiting for license...");
while (lc_status(feature)
{
/* processing */
}
break; /* got the license */
default:
lc_perror("Checkout for license failed");
}

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) feature 

The ASCII feature name.

Return

(int) status 

Status of this feature (in this process):

0  

feature is checked out by this process.

< 0 

error

Error Returns

LM_CANTCONNECT 


Feature was checked out, but lost connection to the daemon.

LM_FEATQUEUE 


This process is in the queue for this feature.

LM_NEVERCHECKOUT 


Feature was never checked out by this process, or was checked back in after a checkout.

lc_timer

Syntax

lc_timer(job)

Description

This routine is called by vendors that cannot tolerate the use of interval timers by FLEXlm. The purpose of lc_timer is twofold:

  • Ensure the vendor daemon is continually running — otherwise an end-user may kill the license server when all licenses are in use, restart the server, and obtain unauthorized licenses.

  • Keep license server informed that the client is still using its license — otherwise the license-server may timeout the client, and drop its license.

If no FLEXlm timers are used, then lc_timer must be called periodically. To avoid FLEXlm's use of timers, call lc_set_attr(LM_A_CHECK_INTERVAL, -1), and lc_set_attr(LM_A_RETRY_INTERVAL, -1).

If the default timer is left installed, lc_timer() is called by the FLEXlm-installed timer. lc_timer() also performs all the reconnection functions, so it is important to keep calling lc_timer(), even if your reconnection handler is called.

lc_timer() must not be called more than once per minute, or it will generate unnecessary networking delays. That is, when used correctly, no delays should occur. Alternatively lc_timer() must be called often enough to avoid the application losing its license — the vendor daemon will time out clients due to either UDP timeout or the end-user TIMEOUT option. The application must ensure that LM_A_UDP_TIMEOUT and ls_minimum_user_timeout are both large enough that the application will not inadvertently lose its license. In general, it is a good idea to lc_timer() once every 5 minutes, although occasional lapses are relatively harmless.

How lc_timer() Works

lc_timer() sends a heartbeat to the server. It then reads the response from the previously sent heartbeat. The first heartbeat is sent when the application first connects to the server, usually in lc_checkout(). In this manner, there is normally no delay in lc_timer().

If lc_timer() is unable to read a response from the server, it attempts to reconnect to the server. If the application has set an LM_A_USER_RECONNECT function, this function will also get called. If this reconnect fails, then an internal flag is set and subsequent calls to lc_timer() will attempt reconnection. These attempts are made for LM_A_RETRY_COUNT times. If a reconnection occurs before LM_A_RETRY_COUNT attempts, the LM_A_USER_RECONNECT_DONE routine, if specified, will be called. If a reconnection fails to occur after LM_A_RETRY_COUNT attempts, the LM_A_USER_EXITCALL routine, if specified, will be called. If LM_A_USER_EXITCALL is not specified, the application will exit with the error message, “Lost license, cannot reconnect” to stderr.

lc_timer() and User TIMEOUT Option and UDP Timeout

If lc_timer() is not called for an extended period, then the application may lose its license. This can happen for two reasons: the application is communicating via UDP or the end-user has set a TIMEOUT for this feature in the end-user options file. In both cases, the server has a timeout associated with the license which gets invoked if lc_timer() is not called within the timeout interval. Make sure that LM_A_UDP_TIMEOUT is large enough to accommodate your usage of lc_timer(). Similarly, make sure ls_minimum_user_timeout in ls_vendor.c is large enough so that users will not timeout applications that are in use.

If the license is inadvertently released, the next lc_timer() will automatically re-checkout the license, if there's still a license available.

Parameters

(LM_HANDLE *) job 


From lc_init()

Return

None

lc_userlist

Syntax

users = lc_userlist(job, feature)

Description

Provides a list of who is using the feature, including information about the user of the license. This is used by lmstat -a.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) feature 

The feature name.

Return

If successful, pointer to an LM_USERS structure.

If unsuccessful:

(LM_USERS *)NULL

Reserved licenses are indicated by the lm_isres() macro (defined in lm_client.h). In this case, the “name” contains the entity that the reservation is for.

The LM_USERS structure is obtained from dynamic memory — it is freed upon a subsequent call to lc_userlist(). Do not free this memory.


Note: lc_userlist() will return no information about users of node-locked, unlimited-use licenses, or demo licenses.



Note: This is a potentially expensive function call. With many active users, this call can generate a lot of network activity, and therefore should not be used too often.


Error Returns

LM_BADCOMM 


Communications error with license server.

LM_CANTMALLOC 


malloc() call failed.

LM_FUNCNOTAVAIL 


Vendor keys do not support this function.

LM_NOFEATURE 


Specified feature cannot be found.

See also

  • “lmstat”

  • lm_client.h in the /lmgr/machind directory for LM_USER struct definition.

lc_vsend

Syntax

rcv_str = lc_vsend(job, send_str)

Description

Sends a message to the vendor daemon and returns a result string. There must be a connection established to the vendor daemon before lc_vsend() will work. You can establish a connection with either lc_checkout() or lc_userlist().

You must set up a processing routine in your vendor daemon to receive the message from lc_vsend() and send the reply. This routine is specified in ls_vendor.c in the variable ls_vendor_msg.

Parameters

(LM_HANDLE *) job 


From lc_init()

(char *) send_str 


String to be send to your vendor daemon.

Return

(char *) rcv_str 

String returned by ls_vendor_msg() in your vendor daemon.

(char *)NULL 

if unsuccessful

Error Returns

LM_BADCOMM 


Communications problem with the vendor daemon.

LM_CANTREAD 


Cannot read data from license server

LM_NOFILEVSEND 


Communications protocol does not support this function.

LM_NOSERVSUPP 


Your vendor daemon does not support this function.

LM_CODE

Syntax

LM_CODE(code, ENCRYPTION_CODE_1, ENCRYPTION_CODE_2, VENDOR_KEY1, VENDOR_KEY2, VENDOR_KEY3, VENDOR_KEY4, VENDOR_KEY5);

Description

LM_CODE is a macro defined in lm_client.h which is used to declare the variable code which is the argument necessary for many other FLEXlm calls. This must be included at the head of any source files which make FLEXlm calls requiring the code argument.

Parameters

code 

this declares and initializes the variable code

ENCRYPTION_CODE_[1-2] 


These are #defined in lm_code.h. These numbers should be 32-bit int values made up by the vendor. These codes are encrypted into the license file.

VENDOR_KEY[1-5] 


These are #defined in lm_code.h, and are provided by Globetrotter Software, enabling FLEXlm to run in either demo mode, or fully-licensed mode on particular platforms which you have licensed. These keys are not encrypted in license files, and can be changed without affecting a license file.


Note: VENDOR_KEY5 is used when calling lc_crypt() or lc_cryptstr(). The data[0] and data[1] elements of the code variable created by LM_CODE must be XOR'd with VENDOR_KEY5 before calling these two functions.




[1] For TCP clients, the resulting checkin is immediate, but for UDP clients, if the client dies or exits and is not able to call lc_checkin, the license server has to timeout the client, and this takes LM_A_UDP_TIMEOUT seconds.