SqueezeBrains SDK 1.18
common.c
Go to the documentation of this file.
1
5#include "common.h"
6
12{
13 sb_t_license license_info;
14 int wait;
15 // Wait the license to be ready.
16 do {
17 int i;
18 wait = 0;
19 sb_license_get_info(&license_info);
20 for (i = 0; i < SB_LICENSE_MODULE_NUMBER; ++i)
21 {
22 //List of conditions for which you want to wait
23 if (
24 //The license manager has not yet started.
25 (license_info.module[i].status == SB_LICENSE_MODULE_STATUS_NULL && license_info.module[i].type == SB_LICENSE_NULL && license_info.module[i].err == SB_ERR_NONE)
26 //USB dongle key license not found. It happen if you call sb_init with SB_INIT_ONLY_HW_LICENSE_KEY and the key is not present.
27 || (license_info.module[i].status == SB_LICENSE_MODULE_STATUS_ERR && license_info.module[i].type == SB_LICENSE_NULL && license_info.module[i].err == SB_ERR_LICENSE_NOT_FOUND)
28 //License file not found. It happens if the license file is not found and the license server is not reachable.
29 || (license_info.module[i].status == SB_LICENSE_MODULE_STATUS_ERR && license_info.module[i].type == SB_LICENSE_NULL && license_info.module[i].err == SB_ERR_LICENSE_FILE)
30 //License server is not reachable. It happens if you have a DEMO license and the license server is not reachable.
31 || (license_info.module[i].status == SB_LICENSE_MODULE_STATUS_ERR && license_info.module[i].type == SB_LICENSE_NULL && license_info.module[i].err == SB_ERR_LICENSE_WAIT_SERVER)
32 //License server is not reachable. It happens if you have a Master license and a DEMO license and the license server is not reachable.
33 || (license_info.module[i].status == SB_LICENSE_MODULE_STATUS_ERR && license_info.module[i].type == SB_LICENSE_DEMO && license_info.module[i].err == SB_ERR_LICENSE_WAIT_SERVER)
34 )
35 {
36 wait = 1;
37 printf("wait for license \"%s\", status=\"%s\", type=\"%s\", err=\"%s\"\n",
40 sb_license_format_type(license_info.module[i].type),
41 sb_err_format(license_info.module[i].err));
42 }
43 }
44 if (wait) // wait one second before next request
45#ifdef _WIN32
46 Sleep(1000);
47#elif __linux__
48 sleep(1);
49#endif
50 } while (wait);
51
52 // Print license file information
53 char license_str[4096];
54 sb_license_format_info(&license_info, license_str, sizeof(license_str));
55 printf(license_str);
56 return SB_ERR_NONE;
57}
sb_t_err wait_license(void)
The functions wait until the license status is active.
Definition: common.c:11
Examples - Common header.
sb_t_err
Errors code enum.
Definition: sb.h:6230
const char * sb_err_format(sb_t_err code)
Returns the error message.
@ SB_ERR_LICENSE_NOT_FOUND
License key not found.
Definition: sb.h:6323
@ SB_ERR_LICENSE_WAIT_SERVER
Waiting to contact the license server.
Definition: sb.h:6329
@ SB_ERR_NONE
No errors.
Definition: sb.h:6231
@ SB_ERR_LICENSE_FILE
License file error (not exist, not readable, wrong format, wrong mail address)
Definition: sb.h:6318
const char * sb_license_format_type(sb_t_license_type type)
Returns the string of the license type.
sb_t_err sb_license_get_info(sb_t_license *const info)
Returns the license information.
sb_t_license_module_id
Enumerations of modules of the SB library.
Definition: sb.h:7618
const char * sb_license_format_module_id(sb_t_license_module_id code)
Returns the string of the module id.
sb_t_err sb_license_format_info(const sb_t_license *const info, char *const str, int str_size)
Formats the license structure.
const char * sb_license_format_module_status(sb_t_license_module_status status)
Returns the string of the feature status.
@ SB_LICENSE_MODULE_STATUS_ERR
There is an error. See the field sb_t_license_module::err.
Definition: sb.h:7581
@ SB_LICENSE_MODULE_STATUS_NULL
The license status is undefined.
Definition: sb.h:7578
@ SB_LICENSE_MODULE_NUMBER
Number of modules.
Definition: sb.h:7629
@ SB_LICENSE_NULL
License type isn't defined.
Definition: sb.h:7590
@ SB_LICENSE_DEMO
Demo license: has an expiry date.
Definition: sb.h:7592
sb_t_license_module_status status
The license status.
Definition: sb.h:7720
sb_t_err err
The license error.
Definition: sb.h:7726
sb_t_license_type type
License type of the module.
Definition: sb.h:7681
Defines the license and its properties.
Definition: sb.h:7741
sb_t_license_module module[SB_LICENSE_MODULE_NUMBER]
Array of the license of the modules Retina, Surface, Deep Surface and Deep Cortex.
Definition: sb.h:7757