SqueezeBrains SDK 1.13
check_license_configuration.c
Go to the documentation of this file.
1
17#include <stdio.h>
18#include "../lib/sb.h"
19#include "../common/common.h"
20
24int main(void)
25{
27 SB_HANDLE project = NULL;
28 sb_t_solution_info* solution_info = NULL;
29 char solution_name[] = "solution/solution_test.rprj";
30 char* msg = NULL;
31 int verbosity = 0;
32
33 printf("Select the verbosity [0-1]:");
34 verbosity = getchar() == '0' ? 0 : 1;
35
37 printf("Initialize the SqueezeBrains library\n");
39
40
41 CHECK_FN_GOTO(sb_solution_get_info(solution_name, &solution_info));
42 for(int t=1; t <= 6; t+=5)
43 {
44 printf("----------------------------------------------------------------------\n");
45 printf("Test all the project in the solution with thread number equal to %d\n", t);
46 printf("----------------------------------------------------------------------\n");
50 for (int i = 0; i < solution_info->projects.size; i++)
51 {
52 sb_t_par par;
53 printf(">>>> project: \"%s\" <<<<\n", solution_info->projects.info[i].name);
54 // Load the project
55 CHECK_FN_GOTO(sb_project_load(&project, solution_name, solution_info->projects.info[i].uuid, SB_PROJECT_MODE_DETECTION_ONLY));
56 CHECK_FN_GOTO(sb_project_get_par(project, &par));
57 par.num_threads = t;
58 CHECK_FN_GOTO(sb_project_set_par(project, &par));
59 for (int j = 0; j < SB_LICENSE_CONFIGURATION_NUMBER; ++j)
60 {
62 printf("- configuration \"%s\": ", sb_license_format_configuration((sb_t_license_configuration_id)j));
63 // Get license configuration compatibility
65 if (err != SB_ERR_NONE)
66 {
67 printf("ERROR: you cannot to use the project\n");
68 }
69 else if (msg)
70 {
71 printf("WARNING: you can use the project but with some limitations\n");
72 }
73 else
74 {
75 printf("OK: you can use the project without any limitations\n");
76 }
77 if (msg)
78 {
79 if (verbosity)
80 printf("%s\n", msg);
81 sb_free(msg);
82 msg = NULL;
83 }
84 }
85 printf("\n");
87 }
88 }
89FnExit:
90 sb_solution_destroy_info(&solution_info);
91 sb_project_destroy(&project);
92 if (msg)
93 {
94 sb_free(msg);
95 }
96
98 printf("Release SqueezeBrains library\n");
99 sb_release();
100
101 printf("Press ENTER to terminate\n");
102 getchar();
103 return (int)err;
104}
int main(void)
#define CHECK_FN_GOTO(function)
Definition: common.h:34
sb_t_err
Errors code enum.
Definition: sb.h:5541
@ SB_ERR_NONE
No errors.
Definition: sb.h:5542
sb_t_err sb_release(void)
Releases all the resources allocates in the library.
sb_t_err sb_init(const char *const license_file)
Initializes the SB library.
void * SB_HANDLE
HANDLE definition.
Definition: sb.h:6042
#define SB_INIT_NO_LICENSE_KEY
Use this define with sb_init in order to not manage license keys.
Definition: sb.h:5964
sb_t_err sb_license_configuration_check(SB_HANDLE module, sb_t_license_configuration_id configuration_id, char **const msg)
Checks if the project can be used with a license configuration.
const char * sb_license_format_configuration(sb_t_license_configuration_id configuration)
Returns the string of the license configuration.
sb_t_license_configuration_id
Enumerations of the license configurations.
Definition: sb.h:6813
@ SB_LICENSE_CONFIGURATION_NUMBER
Number of configurations.
Definition: sb.h:6821
void sb_free(void *ptr)
Deallocates a memory block.
sb_t_err sb_project_set_par(SB_HANDLE handle, const sb_t_par *const par)
Sets the parameters structure into the project handle.
sb_t_err sb_project_get_par(SB_HANDLE handle, sb_t_par *const par)
Retrieves the project parameters structure.
sb_t_err sb_project_load(SB_HANDLE *phandle, const char *const solution_file, const char *const project_uuid, sb_t_project_mode mode)
Loads an existing project from file.
sb_t_err sb_project_destroy(SB_HANDLE *phandle)
Frees all the resources of the project handle.
@ SB_PROJECT_MODE_DETECTION_ONLY
Load/save the minimum module information to allow detection.
Definition: sb.h:9026
sb_t_err sb_solution_get_info(const char *const solution_file, sb_t_solution_info **const solution)
Returns the information contained in the solution_file.
sb_t_err sb_solution_destroy_info(sb_t_solution_info **const solution)
Destroys the structure of the solution information.
Project parameters.
Definition: sb.h:10647
int num_threads
Maximum number of OpenMP threads that detection can use.
Definition: sb.h:10701
char name[SB_PAR_STRING_LEN]
Project name.
Definition: sb.h:8902
char uuid[SB_PROJECT_UUID_LEN]
Project UUID.
Definition: sb.h:8901
sb_t_project_info * info
Array of solution project information.
Definition: sb.h:8911
int size
Number of projects.
Definition: sb.h:8912
Solution info structure.
Definition: sb.h:8931
sb_t_projects_info projects
Array of the projects info.
Definition: sb.h:8932