1 struct _gpginfo {
2 	int gpg_verified;
3 	int gpg_checked;
4 	char gpg_data[128];
5 };
6 
7 static struct _gpginfo gpginfo = {0, 0, };
8 
9 // return -1 if no license is needed, 1 if licensed, 0 if not licensed
10 static int
is_licensed(LV2_Handle instance)11 is_licensed (LV2_Handle instance)
12 {
13 	if (!gpginfo.gpg_checked) {
14 		gpginfo.gpg_checked = 1;
15 #define self (&gpginfo)
16 #define SIGNOVERSION
17 #include "gpg_check.c"
18 #undef self
19 	}
20 	return gpginfo.gpg_verified ? 1 : 0;
21 }
22 
23 static char*
licensee(LV2_Handle instance)24 licensee (LV2_Handle instance)
25 {
26 	if (gpginfo.gpg_verified) {
27 		if (strlen (gpginfo.gpg_data) > 13 && !strncmp(gpginfo.gpg_data, "Licensed to ", 12)) {
28 			return strdup (&gpginfo.gpg_data[12]);
29 		} else {
30 			return strdup (gpginfo.gpg_data);
31 		}
32 	}
33 	return NULL;
34 }
35 
36 static const char*
product_uri(LV2_Handle instance)37 product_uri (LV2_Handle instance)
38 {
39 	  return RTK_URI;
40 }
41 
42 static const char*
product_name(LV2_Handle instance)43 product_name (LV2_Handle instance)
44 {
45 	  return license_infos.name;
46 }
47 
48 static const char*
store_url(LV2_Handle instance)49 store_url (LV2_Handle instance)
50 {
51 	  return license_infos.store;
52 }
53 
54 #define LV2_LICENSE_EXT_C \
55 	static const LV2_License_Interface lif = { &is_licensed, &licensee, &product_uri, &product_name, &store_url }; \
56 	if (!strcmp(uri, LV2_PLUGINLICENSE__interface)) { return &lif; }
57