SqueezeBrains SDK 1.18
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 sb_t_par* par = NULL;
30 char solution_name[] = "solution/solution_test.rprj";
31 char* msg = NULL;
32 int verbosity = 0;
33
34 printf("Select the verbosity [0-1]:");
35 verbosity = getchar() == '0' ? 0 : 1;
36
38 printf("Initialize the SqueezeBrains library\n");
40
41
42 CHECK_FN_GOTO(sb_solution_get_info(solution_name, &solution_info));
43 for(int t=1; t <= 6; t+=5)
44 {
45 printf("----------------------------------------------------------------------\n");
46 printf("Test all the project in the solution with thread number equal to %d\n", t);
47 printf("----------------------------------------------------------------------\n");
51 for (int i = 0; i < solution_info->projects.size; i++)
52 {
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");
88 }
89 }
90FnExit:
91 sb_solution_destroy_info(&solution_info);
92 sb_par_destroy(&par);
93 sb_project_destroy(&project);
94 if (msg)
95 {
96 sb_free(msg);
97 }
98
100 printf("Release SqueezeBrains library\n");
101 sb_release();
102
103 printf("Press ENTER to terminate\n");
104 getchar();
105 return (int)err;
106}
int main(void)
#define CHECK_FN_GOTO(function)
Definition: common.h:34
sb_t_err
Errors code enum.
Definition: sb.h:6230
@ SB_ERR_NONE
No errors.
Definition: sb.h:6231
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:6766
#define SB_INIT_NO_LICENSE_KEY
Use this define with sb_init in order to not manage license keys.
Definition: sb.h:6678
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:7602
@ SB_LICENSE_CONFIGURATION_NUMBER
Number of configurations.
Definition: sb.h:7610
void sb_free(void *ptr)
Deallocates a memory block.
sb_t_err sb_par_destroy(sb_t_par **const par)
Destroys the project parameters structure.
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_load(SB_HANDLE *phandle, const char *const solution_file, const char *const project_uuid, sb_t_project_mode mode)
Loads an existing project from a solution file.
sb_t_err sb_project_destroy(SB_HANDLE *phandle)
Frees all the resources of the project handle.
sb_t_err sb_project_get_par(SB_HANDLE handle, sb_t_par **const par)
Retrieves the project parameters structure.
@ SB_PROJECT_MODE_DETECTION_ONLY
Load/save the minimum module information to allow detection.
Definition: sb.h:9822
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:11797
int num_threads
Maximum number of OpenMP threads that detection can use.
Definition: sb.h:11851
char name[SB_PAR_STRING_LEN]
Project name.
Definition: sb.h:9698
char uuid[SB_PROJECT_UUID_LEN]
Project UUID.
Definition: sb.h:9697
sb_t_project_info * info
Array of solution project information.
Definition: sb.h:9707
int size
Number of projects.
Definition: sb.h:9708
Solution info structure.
Definition: sb.h:9727
sb_t_projects_info projects
Array of the projects info.
Definition: sb.h:9728