# Licensing Engine (Engine `lic`)

This engine, together with the ADM and KRN executors, is located directly in the server kernel.
It gathers the jobs that are responsible for license management of enaio®.
For the use of various functions, a login to the respective licenses must be performed before execution.
 
In particular, for the use of the Standard, DMS and Workflow engines, the kernel checks whether the calling instance is authenticated and has a license assigned.

> **Note:** The login for licenses is performed via [lic.LicLogin](lic.md#lic.LicLogin) or [lic.LicLoginEx](lic.md#lic.LicLoginEx).
The required license strings (especially `ASC`, `MWC`) must be passed before using the DMS and Workflow jobs is possible.

## License Login/Logout

* [lic.LicLogin](lic.md#lic.LicLogin)
* [lic.LicLoginEx](lic.md#lic.LicLoginEx)
* [lic.LicLogout](lic.md#lic.LicLogout)
* [lic.LicLogoutEx](lic.md#lic.LicLogoutEx)

## License Check

* [lic.CheckLicense](lic.md#lic.CheckLicense)
* [lic.LicGetModuleInfo](lic.md#lic.LicGetModuleInfo)
* [lic.LicGetGlobalInfo](lic.md#lic.LicGetGlobalInfo)
* [lic.LicGetGlobalInfoEx](lic.md#lic.LicGetGlobalInfoEx)
* [lic.LicGetQueueStatus](lic.md#lic.LicGetQueueStatus)

## License Management

* [lic.LicCopyDefault](lic.md#lic.LicCopyDefault)
* [lic.LicFreeResource](lic.md#lic.LicFreeResource)
* [lic.LicGetLockCount](lic.md#lic.LicGetLockCount)
* [lic.LicLockResource](lic.md#lic.LicLockResource)
* [lic.LicResetData](lic.md#lic.LicResetData)

## Undocumented Endpoints

The following jobs are offered by the enaio® server but are not currently described in this documentation:

* `lic.LicCheckThreshold`
* `lic.LicKillConnection`
* `lic.LicSetGlobalInfo`

<a id="lic.CheckLicense"></a>

## lic.CheckLicense

This job checks whether the requested modules are licensed for the enaio® client's station.
The license is **not** locked in the database.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Modules` | STRING | Yes | Short labels of the requested modules separated by spaces |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | Return codes separated by spaces for the respective requested modules: +<br>`0` = a license exists for the module +<br>`602` = error |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicCopyDefault"></a>

## lic.LicCopyDefault

This job distributes all named licenses defined in the DB table `oslicresources` for the standard station to all other stations.
This is done, for example, during network setup.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicFreeResource"></a>

## lic.LicFreeResource

This job releases a resource found in the DB table `osresources`.
Resources include: modules (`ADM`, `M_X` etc.) and important system files (`aslisten.dat`, configuration files, background bitmaps etc.).

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `SessionGUID` | STRING | Yes | The current SessionGUID |
| `ResourceID` | STRING | Yes | The ResourceID of the resource to be released |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicGetGlobalInfo"></a>

## lic.LicGetGlobalInfo

This job returns the value of the specified parameter from the license data (`aslic.dat`).

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Info` | STRING | Yes | Name of the requested parameter: +<br>`IDENT` = identification method +<br>`ADDRESS` = GUID or IP address +<br>`CREATED` = creation date of the license +<br>`CREATEDFROM` = created from +<br>`CUSTOMER00` = licensee +<br>`LASTMODIFIED` = last modified on +<br>`MODIFIEDFROM` = modified from +<br>`SERVICENAME` = name of the service +<br>`EXPIRES` = valid until |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | Value of the requested parameter |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

See also: [lic.LicGetGlobalInfoEx](lic.md#lic.LicGetGlobalInfoEx)

<a id="lic.LicGetGlobalInfoEx"></a>

## lic.LicGetGlobalInfoEx

This job returns the values of the specified parameters from the license data (`aslic.dat`).

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Info` | STRING | Yes | Names of the requested parameters in the format `;Parameter;Parameter;...`: +<br>empty = all parameters are returned +<br>`?` = all parameter names are returned |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `[Parametername]` | STRING | Optional | Value of the respective requested parameter |
| `[PARAM[000..nnn]]` | STRING | Optional | Name of the parameter (only when `Info=?`) |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicGetLockCount"></a>

## lic.LicGetLockCount

This job determines all active locks on a named resource.
For each lock found, the server returns one `Info` output parameter with the lock details.

====
This job is not listed in the official enaio® licensing engine overview (`lic`). This description was reconstructed from the call code of the enaio® gateway (`dms-enaio` library).
====

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Reserved; always pass `0`. |
| `ResourceName` | STRING | Yes | Name of the resource whose locks are to be determined. |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Info<n>` | STRING | per active lock | Lock details as semicolon-separated fields in the format `<count>;<sessionGuid>;<instanceName>`. Each parameter name begins with `Info` (e.g. `Info0`, `Info1`, …); the server returns exactly one entry per active lock. |

#### `Info` Value Format

| Field | Index | Type | Description |
|---|---|---|---|
| `count` | 0 | INT | Number of lock entries this session holds on the resource. |
| `sessionGuid` | 1 | STRING | GUID of the working session that holds the lock. |
| `instanceName` | 2 | STRING | Name of the enaio® server instance on which the lock is recorded. |

### Return Value

`(INT)`: `0` = job successful, otherwise error code. On error, no `Info` parameters are returned.

### See Also

* [lic.LicLockResource](lic.md#lic.LicLockResource) — sets a new lock
* [lic.LicFreeResource](lic.md#lic.LicFreeResource) — releases a lock

<a id="lic.LicGetModuleInfo"></a>

## lic.LicGetModuleInfo

This job determines information (type, maximum number of users) about the license for the specified module.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Module` | STRING | Yes | Short label of the requested module |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | String with the license characteristics of the module: +<br>`MaxUseCount` (maximum number of clients that can use the module); +<br>License type: `N` = module can only be used by clients at specific workstations;<br>`C` = module can be used by clients of respective workstations, but only by a certain number (`MaxUseCount`); +<br>Number of configurations that can be created |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicGetQueueStatus"></a>

## lic.LicGetQueueStatus

This job returns information about licenses for specified modules and system files currently issued by the server for the specified stations.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Modules` | STRING | Yes | Short labels of the modules to be queried separated by spaces. Empty = all modules and system files. |
| `Stations` | STRING | Yes | Station names separated by spaces. Empty = all stations. |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `FileCount` | INT | — | Always `1` |

### Output Files

| Name | Description |
|---|---|
| `File list` | File in `.rpt` format with license information per entry: +<br>License issuance time (timestamp);<br>Short label for module/system file;<br>License type (`0` = module; `1` = system file);<br>Name of the workstation;<br>Name of the user;<br>Flags (currently not used);<br>Parameters (currently not used);<br>ID of the server group;<br>GUID of the session;<br>ID of the module/system file |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicLockResource"></a>

## lic.LicLockResource

This job locks a named resource for the current working session.
It complements the publicly documented counterpart [lic.LicFreeResource](lic.md#lic.LicFreeResource), which releases locks, and [lic.LicGetLockCount](lic.md#lic.LicGetLockCount), which determines active locks.

====
This job is not listed in the official enaio® licensing engine overview (`lic`). This description was reconstructed from the call code of the enaio® gateway (`dms-enaio` library).
====

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Reserved; always pass `0`. |
| `ResourceName` | STRING | Yes | Name of the resource to be locked. |
| `SessionGUID` | STRING | Yes | GUID of the active working session to which the lock is assigned. |
| `LockTime` | INT | Yes | Timestamp of the lock start as Unix seconds since epoch. |

### Return Value

`(INT)`: `0` = job successful, otherwise error code.

### See Also

* [lic.LicFreeResource](lic.md#lic.LicFreeResource) — releases a previously locked resource
* [lic.LicGetLockCount](lic.md#lic.LicGetLockCount) — determines the active locks on a resource

<a id="lic.LicLogin"></a>

## lic.LicLogin

This job grants a license for the specified module.
Before a client application can use enaio® modules, it must receive permission from the server for its usage.
The server checks (e.g. maximum number of licenses, access to the module only from specific workstations), whether the client is authorized to use this module.
Upon successful verification, the server locks the license in the database.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Module` | STRING | Yes | Short label of the module |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | `0` = license granted; `>0` = error code |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

See also: [lic.LicLoginEx](lic.md#lic.LicLoginEx), [lic.LicLogout](lic.md#lic.LicLogout)

<a id="lic.LicLoginEx"></a>

## lic.LicLoginEx

This job grants licenses for multiple specified modules simultaneously.
Before a client application can use enaio® modules, it must receive permission from the server for its usage.
The server checks (e.g. maximum number of licenses, access to the module only from specific workstations), whether the client is authorized to use these modules.
Upon successful verification, the server locks the licenses in the database.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Module` | STRING | Yes | Short labels of the modules separated by spaces |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | Result messages separated by spaces per module: `0` = license granted; `>0` = error code |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

See also: [lic.LicLogoutEx](lic.md#lic.LicLogoutEx)

<a id="lic.LicLogout"></a>

## lic.LicLogout

This job releases a license for a specified module that was previously locked using [lic.LicLogin](lic.md#lic.LicLogin) or [lic.LicLoginEx](lic.md#lic.LicLoginEx).

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Module` | STRING | Yes | Short label of the module |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | `0` = license released; `>0` = error code |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicLogoutEx"></a>

## lic.LicLogoutEx

This job releases licenses for multiple modules that were previously locked using [lic.LicLogin](lic.md#lic.LicLogin) or [lic.LicLoginEx](lic.md#lic.LicLoginEx).

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |
| `Modules` | STRING | Yes | Short labels of the modules separated by spaces |

### Output Parameters

| Name | Type | Dependency | Description |
|---|---|---|---|
| `Result` | STRING | — | Result messages separated by spaces per module: `0` = license released; `>0` = error code |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.

<a id="lic.LicResetData"></a>

## lic.LicResetData

This job causes the server to read the license information (`aslic.dat`) again from the database (`oslicense`).

The job is sent by the server that changed the license information to all active servers in the server group.
The receiving servers modify their internal data structures of the license system.

### Input Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Flags` | INT | Yes | Currently not supported — pass `0`. |

### Return Value

`(INT)`: `0` = Job successful, otherwise error code.
