added clang section in installation guide
[deliverable/titan.core.git] / common / license.h
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Baji, Laszlo
10 * Balasko, Jeno
11 * Beres, Szabolcs
12 * Raduly, Csaba
13 * Szabo, Janos Zoltan – initial implementation
14 *
15 ******************************************************************************/
16 #ifndef LICENSE_H
17 #define LICENSE_H
18
19 #include <time.h>
20
21 /* Initial features */
22 #define FEATURE_TTCN3 0x1u
23 #define FEATURE_CODEGEN 0x2u
24 #define FEATURE_TPGEN 0x4u
25 #define FEATURE_SINGLE 0x8u
26 #define FEATURE_MCTR 0x10u
27 #define FEATURE_HC 0x20u
28 #define FEATURE_LOGFORMAT 0x40u
29 /* Added in 1.2.pl0 */
30 #define FEATURE_ASN1 0x80u
31 #define FEATURE_RAW 0x100u
32 #define FEATURE_BER 0x200u
33 #define FEATURE_PER 0x400u
34 /* Added in 1.5.pl7 */
35 #define FEATURE_GUI 0x800u // deprecated mctr GUI was removed
36 /* Added in 1.5.pl8 */
37 #define FEATURE_TEXT 0x1000u
38 /* Added in 1.8.pl0 */
39 #define FEATURE_XER 0x2000u
40
41 /* Limitation types */
42 #define LIMIT_HOST 0x1
43 #define LIMIT_USER 0x2
44
45 /* Limit for expiration warning in days */
46 #define EXPIRY_WARNING 14
47
48 /* Where to send the license.
49 *
50 * The values 1,2,3 work as either an enumeration or a bit field. */
51 #define SENDTO_LICENSEE 1
52 #define SENDTO_CONTACT 2
53 #define SENDTO_BOTH 3
54
55 /** "Cooked" license information suitable for processing. */
56 typedef struct {
57 char *license_file;
58 unsigned int unique_id;
59 char *licensee_name, *licensee_email,
60 *licensee_company, *licensee_department;
61 char *contact_name, *contact_email;
62 unsigned int send_to;
63 time_t valid_from, valid_until;
64 unsigned long int host_id;
65 char *login_name;
66 unsigned int from_major, from_minor, from_patchlevel,
67 to_major, to_minor, to_patchlevel;
68 unsigned int feature_list, limitation_type;
69 unsigned int max_ptcs;
70 } license_struct;
71
72 /** Raw license information.
73 *
74 * The license file is a Base64-encode of a BER-encoded version of this structure.
75 *
76 * @note Modifying this structure will render it incompatible with
77 * previous versions of Titan (the size of the structure is checked) */
78 typedef struct {
79 unsigned char unique_id[4];
80 char licensee_name[48], licensee_email[48],
81 licensee_company[48], licensee_department[16];
82 unsigned char valid_from[4], valid_until[4];
83 unsigned char host_id[4];
84 char login_name[8];
85 unsigned char from_major[4], from_minor[4], from_patchlevel[4],
86 to_major[4], to_minor[4], to_patchlevel[4];
87 unsigned char feature_list[4], limitation_type[4];
88 unsigned char max_ptcs[4];
89 unsigned char dsa_signature[48];
90 } license_raw;
91
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95
96 /** Load license information.
97 *
98 * Loads license information from the file specified in the
99 * \c TTCN3_LICENSE_FILE environment variable.
100 *
101 * Calls \c load_license_from_file()
102 *
103 * @param [out] lptr pointer to license data */
104 void load_license(license_struct *lptr);
105
106 /** Load license information from a specified file.
107 * @param [out] lptr pointer to license data
108 * @param [in] file_name string containing the license file name */
109 void load_license_from_file(license_struct *lptr, const char *file_name);
110
111 /** Free resources
112 * @param [in] lptr pointer to license data */
113 void free_license(license_struct *lptr);
114
115 /** Check if the license allows the use of the product.
116 *
117 * Verifies that we are within the license period, that the host or user
118 * restriction is satisfied, and the program version is within the limits
119 * allowed by the license.
120 *
121 * If the license is about to expire in less than \c EXPIRY_WARNING days,
122 * a warning is printed.
123 *
124 * If a check fails, function returns 0.
125 *
126 * @param [in] lptr pointer to license information
127 * @return 1 if the license is valid, 0 if invalid. */
128 int verify_license(const license_struct *lptr);
129
130 /** Check if the license allows the use of a certain feature.
131 *
132 * @param lptr pointer to license information
133 * @param feature feature to check. It should be one of the FEATURE_ macros.
134 * @return nonzero if feature is enabled, 0 if disabled. */
135 unsigned int check_feature(const license_struct *lptr, unsigned int feature);
136
137 /** Print the details of the supplied license information
138 *
139 * @param [in] lptr pointer to license information */
140 void print_license(const license_struct *lptr);
141
142 /** Print information about the license used by the program.
143 *
144 * The license is loaded from the file specified by the \c TTCN3_LICENSE_FILE
145 * environment variable.
146 *
147 * This function terminates the program if the license is not valid. */
148 void print_license_info(void);
149
150 void init_openssl(void);
151 void free_openssl(void);
152
153 const char * openssl_version_str(void);
154
155 #if defined(WIN32) || defined(INTERIX)
156 long gethostid(void);
157 #endif
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif
This page took 0.036407 seconds and 5 git commands to generate.