-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.c
11509 lines (11386 loc) · 312 KB
/
parse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************
Copyright (C) 2006-2015 Hewlett-Packard Development Company, L.P.
Copyright (C) 2017-2019 Bittium Wireless Ltd.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
***************************************************************/
/* Equivalent to version 1.83 of Core Nomos code. */
#include <ctype.h>
#include "nomos.h"
#include "parse.h"
#include "list.h"
#include "util.h"
#include "nomos_regex.h"
#include "nomos_utils.h"
#include "_autodefs.h"
/* DEBUG
#define DOCTOR_DEBUG 1
#define PROC_TRACE 1
DEBUG */
/**
* \file
* \brief searches for licenses
*
* The main workhorse of nomos. This file contains most of the logic for finding
* licenses in nomos.
*/
/**
* \name license definitions
* Instead of keeping a potentially-growing list of variables used to
* recall specific flags/text, etc., manage it in an array. A little
* slower, sure, but it keeps the number of variables we allocate to
* a more-reasonable minimum.
*/
//@{
#define _mGPL 0
#define _mLGPL 1
#define _mGFDL 2
#define _mQPL 3
#define _mPYTHON 4
#define _mPYTH_TEXT 5
#define _mAPACHE 6
#define _mHP 7
#define _mPHP 8
#define _mMIT 9
#define _mXOPEN 10
#define _mREDHAT 11
#define _mISC 12
#define _mCMU 13
#define _mOSF 14
#define _mSUN 15
#define _mALADDIN 16
#define _mCUPS 17
#define _fOPENLDAP 18
#define _fBSD 19
#define _fGPL 20
#define _mCDDL 21
#define _mLIBRE 22
#define _mGSOAP 23
#define _mMPL 24
#define _fATTRIB 25
#define _fREAL 26
#define _fIETF 27
#define _fDOC 28
#define _fMSCORP 29
#define _fW3C 30
#define _mAPTANA 31
#define _tOPENLDAP 32
#define _mNTP 33 // To avoid W3C-style detection
#define _fIP 34
#define _fANTLR 35
#define _fCCBY 36
#define _fZPL 37
#define _fCLA 38
#define _fODBL 39
#define _fPDDL 40
#define _fRUBY 41
#define _fSAX 42
#define _fAPL 43
#define _fARTISTIC 44
#define _fCITRIX 45
#define _fPURDUE 46
#define _fUNICODE 47
#define _fOFL 48
#define _mAPACHE10 49
#define _mAPACHE11 50
#define _mWORDNET 51
#define _fNCSA 52
#define _fTCL 53
#define _fIJG 54
#define _msize _fIJG+1
//@}
/**
* Regex match related data
*/
static struct {
char *base;
int sso;
int seo;
int index;
} kludge;
#ifdef PRECHECK
extern void preloadResults(char *filetext, char *ltsr);
#endif /* PRECHECK */
/**
* \name local static functions
* Local (static) Functions
*/
//@{
int findPhrase(int, char *,int, int, int, int);
int famOPENLDAP(char *, int ,int, int);
int checkUnclassified(char *, int, int, int, int, int);
int checkPublicDomain(char *, int, int, int, int, int);
static int dbgIdxGrep(int, char *, int);
#ifdef LTSR_DEBUG
void showLTCache(char *);
#endif /* LTSR_DEBUG */
void checkCornerCases(char *, int, int, int, int, int, int, int);
void checkFileReferences(char *, int, int, int, int, int);
void addRef(char *, int);
#ifdef DOCTOR_DEBUG
void dumpMatch(char *, char *);
#endif /* DOCTOR_DEBUG */
void locateRegex(char *, item_t *, int, int, int, int);
void saveRegexLocation(int, int, int, int);
void saveUnclBufLocation(int);
void saveLicenseParagraph(char *, int , int , int);
char *cplVersion(char *, int, int, int);
static char *gplVersion(char *, int, int, int);
char *lgplVersion(char *, int, int, int);
char *agplVersion(char *, int, int, int);
char *gfdlVersion(char *, int, int, int);
char *lpplVersion(char *, int, int, int);
char *mplNplVersion(char *, int, int, int);
char *pythonVersion(char *, int, int, int);
static char *realVersion(char *, int, int, int, int);
static char *sisslVersion(char *, int, int, int);
char *aslVersion(char *, int, int, int);
char *cddlVersion(char *, int, int, int);
char *ccVersion(char *, int, int, int);
char *oslVersion(char *, int, int, int);
char *aflVersion(char *, int, int, int);
static int match3(int, char *, int, int, int, int);
void spdxReference(char *, int, int, int);
void copyleftExceptions(char *, int, int, int);
//@}
/**
* \name local variables
* File local variables
*/
//@{
/**
* Detected licenses are stored here in a form ',BSD,MIT' etc
*/
static char licStr[myBUFSIZ];
static char ltsr[NFOOTPRINTS]; /**< License Text Search Results,
a bytemask for each possible match string */
static char name[256];
static char lmem[_msize];
static list_t searchList;
static list_t whereList;
static list_t whCacheList;
static int refOffset;
static int maxInterest;
static int pd; /**< Flag for whether we've checked for a
public domain "license" */
static int crCheck;
static int checknw;
static int lDebug = 0; /**< set this to non-zero for more debugging */
static int lDiags = 0; /**< set this to non-zero for printing diagnostics */
//@}
/**
* \name micro function definitions
* These #define's save a LOT of typing and indentation... :)
*/
//@{
#define PARSE_ARGS filetext, size, isML, isPS ///< Arguments to parse
#define LVAL(x) (ltsr[x] & LTSR_RMASK) ///< Check LTSR_RMASK on lstr[x]
#define SEEN(x) (ltsr[x] & LTSR_SMASK) ///< Check LTSR_SMASK on lstr[x]
#define INFILE(x) fileHasPatt(x, PARSE_ARGS, 0) ///< Calls fileHasPatt()
#define NOT_INFILE(x) !( fileHasPatt(x, PARSE_ARGS, 0) && clearLastElementOfLicenceBuffer() ) ///< Calls fileHasPatt()
#define RM_INFILE(x) fileHasPatt(x, PARSE_ARGS, 1) ///< Calls fileHasPatt() with qType 1
#define GPL_INFILE(x) fileHasPatt(x, PARSE_ARGS, 2) ///< Calls fileHasPatt() with qType 2
#define PERL_INFILE(x) fileHasPatt(x, PARSE_ARGS, 3) ///< Calls fileHasPatt() with qType 3
#define NY_INFILE(x) fileHasPatt(x, PARSE_ARGS, 4) ///< Calls fileHasPatt() with qType 4
#define X_INFILE(x, y) fileHasPatt(x, PARSE_ARGS, y) ///< Calls fileHasPatt() with qType y
#define DEBUG_INFILE(x) printf(" Regex[%d] = \"%s\"\nINFILE(%d) = %d\n", x, _REGEX(x), x, INFILE(x)); ///< Debug print
#define HASREGEX(x, cp) idxGrep(x, cp, REG_ICASE|REG_EXTENDED) ///< Calls idxGrep()
#define HASREGEX_RI(x, cp) idxGrep_recordIndex(x, cp, REG_ICASE|REG_EXTENDED) ///< Calls idxGrep_recordIndex()
#define HASTEXT(x, fl) idxGrep_recordIndex(x, filetext, REG_ICASE|fl) ///< Calls idxGrep_recordIndex()
#define URL_INFILE(x) (INFILE(x) || fileHasPatt(x, PARSE_ARGS, -1)) ///< Check in file with qType 0|1
#define CANSKIP(i,x,y,z) ((i >= y) && (i <= z) && !(kwbm & (1 << (x - _KW_first))))
#define HASKW(x, y) (x & (1 << (y - _KW_first)))
#define TRYGROUP(x) x(PARSE_ARGS)
#define LOWINTEREST(x) addRef(x, IL_LOW)
#define MEDINTEREST(x) addRef(x, IL_MED)
//#define INTERESTING(x) printf("INTERESTING: %s, %d, %s\n", __FILE__, __LINE__, x);addRef(x, IL_HIGH)
#define INTERESTING(x) addRef(x, IL_HIGH)
#define ASLVERS() aslVersion(PARSE_ARGS)
#define CCVERS() ccVersion(PARSE_ARGS)
#define AFLVERS() aflVersion(PARSE_ARGS)
#define OSLVERS() oslVersion(PARSE_ARGS)
#define CPLVERS() cplVersion(PARSE_ARGS)
#define GPLVERS() gplVersion(PARSE_ARGS)
#define LGPLVERS() lgplVersion(PARSE_ARGS)
#define AGPLVERS() agplVersion(PARSE_ARGS)
#define GFDLVERS() gfdlVersion(PARSE_ARGS)
#define CDDLVERS() cddlVersion(PARSE_ARGS)
#define LPPLVERS() lpplVersion(PARSE_ARGS)
#define MPLVERS() mplNplVersion(PARSE_ARGS)
#define PYTHVERS() pythonVersion(PARSE_ARGS)
#define SISSLVERS() sisslVersion(PARSE_ARGS)
#define REALVERS(x) realVersion(PARSE_ARGS, x)
#define PR_REGEX(x) printf("check %d = %s\n", x, _REGEX(x));
#define mCR_CMU() (INFILE(_CR_CMU_1) || INFILE(_CR_CMU_2))
#define mCR_EDIN() (INFILE(_CR_EDINBURGH_1) || INFILE(_CR_EDINBURGH_2))
#define mCR_FSF() (INFILE(_CR_FSF1) || INFILE(_CR_FSF2))
#define mCR_HP() (INFILE(_CR_HP_1)|| INFILE(_CR_HP_2) || INFILE(_CR_DEC) || INFILE(_CR_EDS))
#define mCR_IETF() (INFILE(_CR_IETF_1) || INFILE(_CR_IETF_2))
#define mCR_MIT() (INFILE(_CR_MIT1) || INFILE(_CR_MIT2))
#define mCR_X11() (INFILE(_CR_X11) || INFILE(_CR_XFREE86))
#define mCR_IPTC() (INFILE(_CR_IPTC1) || INFILE(_CR_IPTC2))
#define SPDXREF() spdxReference(PARSE_ARGS)
#define EXCEPTIONS() copyleftExceptions(PARSE_ARGS)
//@}
/**
* \brief Checks for a phrase in a file
* \param licTextIdx Index of phrase to look
* \param filetext Content of file
* \param size File size
* \param isML File content is HTML/XML
* \param isPS File content is a post script
* \param qType <0, look at raw text. >=0 look in doctored buffers
* \return True if pattern found
*/
static int fileHasPatt(int licTextIdx, char *filetext, int size,
int isML, int isPS, int qType)
{
int ret = 0;
int show = 0;
item_t *ip;
#ifdef PROC_TRACE
traceFunc("== fileHasPatt(size=%d, isML=%d, isPS=%d, qType=%d, idx=%d)\n",
size, isML, isPS, qType, licTextIdx);
#endif /* PROC_TRACE */
/*
* If qType is negative, then we should call idxGrep to look at the
* raw text of the file; non-negative value means look in the doctored
* text buffers...
*/
if ((qType >= 0) && (qType & FL_SHOWMATCH)) {
qType &= ~FL_SHOWMATCH;
show = FL_SHOWMATCH;
}
if (qType < 0) {
ret = idxGrep_recordPosition(licTextIdx, filetext, REG_ICASE | REG_EXTENDED | show);
if (lDiags && ret) {
#ifdef DOCTOR_DEBUG
dumpMatch(filetext, "RAW-Text");
#endif /* DEBUG */
printRegexMatch(licTextIdx, NO);
saveRegexLocation(licTextIdx, cur.regm.rm_so,
cur.regm.rm_eo - cur.regm.rm_so, YES);
#ifdef DEBUG
printf("WINDOW-RAW: offset %d, length %d\n",
cur.regm.rm_so, cur.regm.rm_eo - cur.regm.rm_so);
#endif /* DEBUG */
}
return(ret);
}
if (SEEN(licTextIdx)) {
#ifdef LTSR_DEBUG
printf("Cache hit: ltsr[%d] = 0x%x\n", licTextIdx, ltsr[licTextIdx]);
#endif /* LTSR_DEBUG */
if (lDiags && (ltsr[licTextIdx] & LTSR_YES) == LTSR_YES) {
printRegexMatch(licTextIdx, YES);
(void) sprintf(name, "reg%04d", licTextIdx);
ip = listGetItem(&whCacheList, name);
if (ip->bIndex != licTextIdx) {
listDump(&whCacheList, NO);
LOG_FATAL("Offset-cache (\"%s\") == %d, not %d!", name, ip->bIndex, licTextIdx)
Bail(-__LINE__);
}
saveRegexLocation(licTextIdx, ip->bStart, ip->bLen, NO);
}
return(ltsr[licTextIdx] & LTSR_RMASK);
}
return(findPhrase(licTextIdx, PARSE_ARGS, qType));
}
/**
* \brief Debugging call for idxGrep()
*
* Function calls idxGrep() and print the regex match using printRegexMatch()
* \param licTextIdx license index
* \param buf
* \param show
* \return -1 on regex-compile failure, 1 if regex search fails, and 0 if
* regex search is successful.
*/
static int dbgIdxGrep(int licTextIdx, char *buf, int show)
{
int ret;
int flags = REG_ICASE|REG_EXTENDED;
if (SEEN(licTextIdx)) {
return(ltsr[licTextIdx] & LTSR_RMASK);
}
if (show) {
flags |= FL_SHOWMATCH;
}
ret = idxGrep(licTextIdx, buf, flags);
if (lDiags && ret) {
printRegexMatch(licTextIdx, NO);
saveRegexLocation(licTextIdx, cur.regm.rm_so,
cur.regm.rm_eo - cur.regm.rm_so, YES);
}
ltsr[licTextIdx] |= ret;
return ret;
}
/**
* \brief Parse a file to check all the possible licenses and add them to
* matches
*
* The function calls fileHasPatt() if the file contains a pattern defined in
* STRINGS.in. If a match is found, then it can call idxGrep_recordIndex() to
* check if the file has some additional text and finally adds the license
* using addRef(). The results found are also stored in licStr as a comma
* separated list.
*
* The function first check if a file contains an interesting string which can
* denote a license. If it is found then the heuristics are done in detail to
* find the exact license match. For more info please refer to
* [nomos wiki](https://github.com/fossology/fossology/wiki/Nomos#step-2-change-the-scanner---parsec)
* \param filetext File content
* \param size File size
* \param[out] scp Scan results
* \param isML Source is HTML/XML
* \param isPS Source is PostScript
* \return Next index in licStr
*/
char *parseLicenses(char *filetext, int size, scanres_t *scp,
int isML, int isPS)
{
static int first = 1;
char *cp;
int i;
int j;
int nw = 0;
int score = scp->score;
int kwbm = scp->kwbm;
#ifdef PRECHECK
extern void preloadResults(char *, char *);
#endif /* PRECHECK */
#if defined(PROC_TRACE) || defined(DOCTOR_DEBUG)
traceFunc("== parseLicenses(%p, %d, [%d, 0x%x], %d, %d)\n",
filetext, size, score, kwbm, isML, isPS );
#endif /* PROC_TRACE || DOCTOR_DEBUG */
if (size == 0) {
LOWINTEREST("Empty-file-no-data!");
return(licStr+1);
}
if (first) {
if (optionIsSet(OPTS_DEBUG)) {
lDebug = 1;
lDiags = 1;
}
listInit(&searchList, 0, "pattern-search list");
listInit(&whereList, 0, "regex-match locations list");
listInit(&whCacheList, 0, "regex-cache-match list");
first = 0;
}
crCheck = 0;
kludge.base = NULL_STR;
/*
* Interestingly enough, the headers for Nomos-generated file (e.g., the
* page containing the keywords found, file attributes and file text, etc.)
* contain enough data to confuse the parser in multiple ways... in the
* rare event we encounter a data file we generated, skip the header.
*****
* AND, not all nomos-created files have the same header(s).
*/
pd = -1; /* unchecked */
cp = filetext;
maxInterest = IL_INIT;
cur.licPara = NULL_STR; /* unclassified license data */
gl.flags &= ~FL_FRAGMENT;
#ifdef FLAG_NO_COPYRIGHT
gl.flags &= ~FL_NOCOPYRIGHT;
#endif /* FLAG_NO_COPYRIGHT */
if (scp->dataOffset && lDiags) {
LOG_NOTICE("%s-generated link, ignore header (%d bytes)!",
gl.progName, scp->dataOffset);
}
/*
* It's been observed over time that the file-magic() stuff doesn't always
* identify everything correctly. One case in particular is PostScript files
* when the "%%PS" directive isn't the first line in a file... but the rest
* of the data really IS PostScript
*/
if (!isPS && (strncasecmp(filetext, "%%page:", 7) == 0 || strncasecmp(filetext, "{\\rtf", 5) == 0)) {
#if defined(DEBUG) || defined(DOCTOR_DEBUG)
printf("File is really postscript, %s filetext !\n", filetext);
#endif /* DEBUG || DOCTOR_DEBUG */
isPS = 1;
}
*licStr = NULL_CHAR;
refOffset = 0;
(void) memset(ltsr, 0, sizeof(ltsr));
(void) memset(lmem, 0, sizeof(lmem));
#if defined(DEBUG) && defined(LTSR_DEBUG)
showLTCache("LTSR-results START:");
#endif /* DEBUG && LTSR_DEBUG */
#ifdef PRECHECK
preloadResults(/*PARSE_ARGS*/filetext, ltsr);
#endif /* PRECHECK */
#ifdef MEMSTATS
memStats("parseLicenses: BOP");
#endif /* MEMSTATS */
lmem[_mPYTH_TEXT] = HASTEXT(_TEXT_PYTHON, 0);
lmem[_tOPENLDAP] = HASTEXT(_TEXT_OPENLDAP, 0);
(void) INFILE(_TEXT_GNU_LIC_INFO);
#ifdef LTSR_DEBUG
showLTCache("LTSR-results INIT-SCAN:");
#endif /* LTSR_DEBUG */
/*
* MySQL.FLOSS exception
*/
if (INFILE(_LT_MYSQL_EXCEPT) || INFILE(_PHR_FREE_LIBRE)) {
if (INFILE(_TITLE_ALFRESCO)) {
INTERESTING("Alfresco-FLOSS");
}
else if (HASTEXT(_TEXT_ALFRESCO, 0)) {
INTERESTING("Alfresco");
}
else if (INFILE(_CR_MYSQL) || INFILE(_TITLE_mysql_floss_exception)) {
if (INFILE(_TITLE_MYSQL_V03)) {
INTERESTING("MySQL-0.3");
}
else {
INTERESTING("mysql-floss-exception");
}
}
else {
INTERESTING("MySQL-style");
}
lmem[_mLIBRE] = 1;
}
/*
* Some RealNetworks licenses included a list of "compatible" licenses that
* can confuse the license-detection algorithms within. Look for these early
* in the process, and ignore the known (false) matches when we detect the
* RPSL/RCSL licenses.
*/
if (HASTEXT(_TEXT_REALNET, REG_EXTENDED)) {
/*
* List of other licenses should be excluded only if full license text is found
*/
if (INFILE(_LT_RPSL_COMPATIBLE)) {
lmem[_fREAL] = 1;
}
if (INFILE(_LT_REAL_RPSL)) {
cp = REALVERS(_TITLE_RPSL);
INTERESTING(lDebug ? "RPSL" : cp);
}
else if (INFILE(_LT_REAL_RPSLref)) {
cp = REALVERS(_TITLE_RPSL);
INTERESTING(lDebug ? "Real-RPSL(ref)" : cp);
}
if (INFILE(_LT_REAL_RCSL)) {
cp = REALVERS(_TITLE_RCSL);
INTERESTING(lDebug ? "RCSL" : cp);
}
else if (INFILE(_LT_REAL_RCSLref)) {
cp = REALVERS(_TITLE_RCSL);
INTERESTING(lDebug ? "Real-RCSL(ref)" : cp);
}
if (INFILE(_TITLE_REAL_EULA)) {
INTERESTING("RealNetworks-EULA");
}
else if (INFILE(_LT_HELIX_TITLE)) {
INTERESTING("Helix.RealNetworks-EULA");
}
}
cleanLicenceBuffer();
/*
* Zope - this license is explicitly listed (by title) in several other
* licenses...
*/
if (!lmem[_mLIBRE] && !lmem[_fREAL] && INFILE(_TITLE_ZOPE)) {
if (INFILE(_TITLE_ZOPE_V21)) {
INTERESTING("ZPL-2.1");
lmem[_fZPL] = 1;
}
else if (INFILE(_TITLE_ZOPE_V20)) {
INTERESTING("ZPL-2.0");
lmem[_fZPL] = 1;
}
else if (INFILE(_TITLE_ZOPE_V10)) {
INTERESTING("ZPL-1.0");
lmem[_fZPL] = 1;
}
else if (INFILE(_TITLE_ZOPE_V11)) {
INTERESTING("ZPL-1.1");
lmem[_fZPL] = 1;
}
else if (INFILE(_SPDX_ZPL_11)) {
INTERESTING("ZPL-1.1");
lmem[_fZPL] = 1;
}
else if (INFILE(_SPDX_ZPL_20)) {
INTERESTING("ZPL-2.0");
lmem[_fZPL] = 1;
}
else if (INFILE(_SPDX_ZPL_21)) {
INTERESTING("ZPL-2.1");
lmem[_fZPL] = 1;
}
else if (INFILE(_TITLE_ZIMBRA_13)) {
INTERESTING("Zimbra-1.3");
}
else if (INFILE(_TITLE_ZIMBRA_12)) {
INTERESTING("Zimbra-1.2");
}
else {
INTERESTING(lDebug ? "Zope(ref)" : "ZPL");
lmem[_fZPL] = 1;
}
}
cleanLicenceBuffer();
/*
* Check Apache licenses before BSD
*/
if (HASTEXT(_PHR_Apache_ref0, REG_EXTENDED) || INFILE(_PHR_Apache_ref7)) {
cp = ASLVERS();
INTERESTING(cp);
}
cleanLicenceBuffer();
/*
* BSD and all the variant 'flavors'. BSD licenses are kind of like
* the cooking concept of 'the mother sauces' -- MANY things are derived
* from the wordings of these licenses. There are still many more, for
* certain, but LOTS of licenses are based on ~10 originally-BSD-phrases.
*/
if (INFILE(_LT_BSD_1)) {
if (INFILE(_TITLE_PHP301)) {
INTERESTING(lDebug ? "PHP(v3.01#1)" : "PHP-3.01");
lmem[_mPHP] = 1;
}
else if (INFILE(_TITLE_PHP30)) {
INTERESTING(lDebug ? "PHP(v3.0#1)" : "PHP-3.0");
lmem[_mPHP] = 1;
}
else if (INFILE(_TITLE_PHP202)) {
INTERESTING(lDebug ? "PHP(v2.0.2#1)" : "PHP-2.0.2");
lmem[_mPHP] = 1;
}
else if (INFILE(_CR_VOVIDA) || INFILE(_TITLE_VOVIDA)) {
INTERESTING("VSL-1.0");
lmem[_fBSD] = 1;
}
else if (INFILE(_CR_NAUMEN) || INFILE(_TITLE_NAUMEN)) {
INTERESTING("Naumen");
}
else if (INFILE(_CR_ENTESSA) || INFILE(_TITLE_ENTESSA)) {
INTERESTING("Entessa");
}
else if (INFILE(_LT_ATTRIB) || INFILE(_TITLE_ATTRIBUTION)) {
INTERESTING("AAL");
lmem[_fATTRIB] = 1;
}
else if (INFILE(_CR_ZOPE)) {
INTERESTING(lDebug ? "Zope(bsd)" : "ZPL");
}
else if (INFILE(_LT_Oracle_Berkeley_DB)) {
INTERESTING("Oracle-Berkeley-DB");
}
else if (INFILE(_CR_SLEEPYCAT) || INFILE(_LT_SLEEPYCAT_1)) {
MEDINTEREST(lDebug ? "Sleepycat(1)" : "Sleepycat");
}
else if (INFILE(_TITLE_PHP202)) {
INTERESTING(lDebug ? "PHP(v2.0.2#2)" : "PHP-2.0.2");
lmem[_mPHP] = 1;
}
else if (INFILE(_TITLE_ZEND_V20)) {
INTERESTING("Zend-2.0");
}
else if (!lmem[_fOPENLDAP] && !TRYGROUP(famOPENLDAP)) {
if (HASTEXT(_LT_OPENSSLref5, REG_EXTENDED)) {
INTERESTING(lDebug ? "OpenSSL(ref)" : "OpenSSL");
}
else if (INFILE(_LT_BSD_CLAUSE_0) && INFILE(_LT_BSD_CLAUSE_1) && INFILE(_LT_BSD_CLAUSE_2)) {
if (INFILE(_LT_BSD_CLAUSE_3) && (INFILE(_LT_BSD_CLAUSE_4) || INFILE(_LT_BSD_CLAUSE_4_LONG)) && INFILE(_LT_UC)) {
INTERESTING("BSD-4-Clause-UC");
}
else if (INFILE(_LT_BSD_CLAUSE_3) && (INFILE(_LT_BSD_CLAUSE_4) || INFILE(_LT_BSD_CLAUSE_4_LONG))) {
INTERESTING("BSD-4-Clause");
}
else if (INFILE(_LT_BSD_CLAUSE_4) && INFILE(_LT_BSD_CLAUSE_CLEAR)) {
INTERESTING("BSD-3-Clause-Clear");
}
else if (INFILE(_LT_BSD_CLAUSE_4) && HASTEXT(_KW_severability, REG_EXTENDED)) {
INTERESTING("BSD-3-Clause-Severability");
}
else if (INFILE(_LT_XML_DB_V10)) {
INTERESTING("XMLDB-1.0");
}
else if (INFILE(_LT_BSD_CLAUSE_4) && INFILE(_LT_ANT_BSD_RESTRICTION)) {
INTERESTING("ANT+SharedSource");
}
else if (!lmem[_mAPACHE11] && INFILE(_LT_Apache_11_CLAUSE_3) && INFILE(_LT_Apache_11_CLAUSE_4) && INFILE(_LT_Apache_11_CLAUSE_5)) {
INTERESTING(lDebug ? "BSD(Apache-1.1)" : "Apache-1.1-style");
}
else if(HASTEXT(_LT_Sendmail_823_title, 0)) {
INTERESTING("Sendmail-8.23");
}
else if (!lmem[_mAPACHE10] && !lmem[_mAPACHE11] && INFILE(_LT_BSD_CLAUSE_ATTRIBUTION)) {
INTERESTING("BSD-3-Clause-Attribution");
}
else if (!lmem[_mAPACHE10] && !lmem[_mAPACHE11] && INFILE(_LT_BSD_CLAUSE_4)) {
INTERESTING("BSD-3-Clause");
}
else if (INFILE(_LT_SSLEAY)) {
INTERESTING("SSLeay");
}
else if (INFILE(_LT_TMATE)) {
INTERESTING("TMate");
}
else if (INFILE(_LT_MUP)) {
INTERESTING("Mup");
}
else if (INFILE(_LT_FREE_BSD)) {
INTERESTING("BSD-2-Clause-FreeBSD");
}
else if (INFILE(_LT_BSD_CLAUSE_PATENT)) {
INTERESTING("BSD-2-Clause-Patent");
}
else if (INFILE(_CR_NETBSD)) {
INTERESTING("BSD-2-Clause-NetBSD");
}
else if (INFILE(_LT_MIT_0)) {
lmem[_mMIT] = 1;
INTERESTING("Linux-OpenIB");
}
else if (!lmem[_mAPACHE10] && !lmem[_mAPACHE11]) {
INTERESTING("BSD-2-Clause");
}
}
else if (INFILE(_CR_CRYPTOGAMS)) {
INTERESTING("Cryptogams");
}
else if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(1)" : "BSD");
}
else if (HASTEXT(_TEXT_ALTERED_SOURCE, REG_EXTENDED) && HASTEXT(_TEXT_ORIGIN, 0)) {
if (INFILE(_PHR_BZIP2_3)) {
INTERESTING("bzip2-1.0.5");
}
else if (HASTEXT(_PHR_BZIP2_4, REG_EXTENDED)) {
INTERESTING("bzip2-1.0.6");
}
else {
INTERESTING("bzip2");
}
}
else if (mCR_CMU()) {
INTERESTING(lDebug ? "CMU(BSD-ish)" : "CMU");
}
else if (INFILE(_LT_MTLL)) {
INTERESTING("MTLL");
}
else if (INFILE(_LT_BSD_CLAUSE_1_DISCLAIMER)) {
INTERESTING("BSD-1-Clause");
}
else if (!lmem[_fZPL]) {
INTERESTING(lDebug ? "BSD-style(1)" : "BSD-style");
}
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_CLEAR_CLAUSE_0) && INFILE(_LT_BSD_CLAUSE_1) && INFILE(_LT_BSD_CLAUSE_2)) {
INTERESTING("BSD-3-Clause-Clear");
}
else if (INFILE(_PHR_Linux_OpenIB)) {
INTERESTING("Linux-OpenIB");
}
else if (INFILE(_LT_BSD_2)) {
/*
* Python, OSF, SecretLabs, some universities, some vendors, etc., have
* variants here.
*/
if (INFILE(_CR_PYTHON) || INFILE(_TITLE_PYTHON)) {
cp = PYTHVERS();
INTERESTING(lDebug ? "Python(3)" : cp);
lmem[_mPYTHON] = 1;
}
else if (INFILE(_CR_OSF)) {
INTERESTING(lDebug ? "OSF(1)" : "OSF");
lmem[_mOSF] = 1;
}
else if (INFILE(_CR_UI)) {
INTERESTING(lDebug ? "UI(1)" : "Unix-Intl");
}
else if (INFILE(_CR_XOPEN)) {
INTERESTING(lDebug ? "XOpen(1)" : "X/Open");
lmem[_mXOPEN] = 1;
}
else if (INFILE(_PHR_HISTORICAL)) {
INTERESTING("HPND");
}
else if (INFILE(_LT_CMU_7)) {
if (INFILE(_CR_CMU_1) || INFILE(_CR_CMU_2) || INFILE(_CR_BSDCAL)) {
INTERESTING("MIT-CMU");
}
else {
INTERESTING("MIT-CMU-style");
}
lmem[_mCMU] = 1;
}
else if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(2)" : "BSD");
}
else if (INFILE(_LT_NTP)) {
INTERESTING("NTP");
}
else if (INFILE(_LT_WORDNET))
{
INTERESTING("WordNet-3.0");
lmem[_mMIT] = 1;
}
else if (INFILE(_LT_NOT_ADVERTISING)) {
INTERESTING(lDebug ? "BSD-style(2)" : "BSD-style");
}
else if (INFILE(_PHR_NO_WARRANTY_12)) {
INTERESTING(lDebug ? "ISC(BSD-style)" : "ISC-style");
}
else {
INTERESTING(lDebug ? "BSD-style(2)-MIT" : "MIT-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_3) && NOT_INFILE(_TITLE_OPENLDAP)) {
if (INFILE(_LT_AMPAS)) {
INTERESTING("AMPAS");
}
else if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(3)" : "BSD");
}
else if (INFILE(_TITLE_OZPLB_10)) {
INTERESTING("OZPLB-1.0");
}
else if (NOT_INFILE(_CR_XFREE86) && NOT_INFILE(_TITLE_NCSA) && NOT_INFILE(_TITLE_INNERNET200)) {
INTERESTING(lDebug ? "BSD-style(3)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_4)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(4)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(4)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
/*
* FIX-ME: this license text explicitly mentions "for no-profit", and as
* such it should list it in the license-summary, yes?
*/
else if (INFILE(_LT_BSD_5)) {
if (!lmem[_mPYTHON] && INFILE(_CR_PYTHON)) {
INTERESTING(lDebug ? "Python(2)" : "Python");
lmem[_mPYTHON] = 1;
}
else if (INFILE(_CR_USL_EUR)) {
INTERESTING(lDebug ? "USLE(1)" : "USL-Europe");
}
else if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(5)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(5)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_6)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(6)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(6)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_7)) {
if (HASTEXT(_LT_MAKEINDEX_1, 0) && HASTEXT(_LT_MAKEINDEX_2, 0)) {
INTERESTING("MakeIndex");
}
else if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(7)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(7)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_8)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(8)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(8)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_9)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(9)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(8)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_10)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(10)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(9)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_11)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(11)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(10)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_12)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(12)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(11)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_13)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(13)" : "BSD");
}
else {
INTERESTING(lDebug ? "BSD-style(12)" : "BSD-style");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_LT_BSD_NONC)) {
if (INFILE(_CR_BSDCAL)) {
INTERESTING(lDebug ? "BSD(NonC)" : "BSD.non-commercial");
}
else {
INTERESTING(lDebug ? "BSD-style(NonC)" : "Non-commercial");
}
lmem[_fBSD] = 1;
}
else if (INFILE(_SPDX_BSD_3_Clause_Clear)) {
INTERESTING("BSD-3-Clause-Clear");
}
else if (INFILE(_SPDX_BSD_3_Clause_No_Nuclear_License_2014)) {
INTERESTING("BSD-3-Clause-No-Nuclear-License-2014");
}
else if (INFILE(_SPDX_BSD_3_Clause_No_Nuclear_License)) {
INTERESTING("BSD-3-Clause-No-Nuclear-License");
}
else if (INFILE(_SPDX_BSD_3_Clause_No_Nuclear_Warranty)) {
INTERESTING("BSD-3-Clause-No-Nuclear-Warranty");
}
else if (INFILE(_SPDX_BSD_3_Clause_Attribution)) {
INTERESTING("BSD-3-Clause-Attribution");
}
else if (INFILE(_SPDX_BSD_3_Clause_LBNL)) {
INTERESTING("BSD-3-Clause-LBNL");
}
else if (INFILE(_SPDX_BSD_3_Clause)) {
INTERESTING("BSD-3-Clause");
}
else if (INFILE(_PHR_BSD_3_CLAUSE_1) || INFILE(_PHR_BSD_3_CLAUSE_2) || INFILE(_PHR_BSD_3_CLAUSE_3) || INFILE(_PHR_BSD_3_CLAUSE_4)) {
INTERESTING(lDebug ? "BSD(phr1/2)" : "BSD-3-Clause");
}
else if (INFILE(_SPDX_BSD_2_Clause_FreeBSD)) {
INTERESTING("BSD-2-Clause-FreeBSD");
}
else if (INFILE(_SPDX_BSD_2_Clause_NetBSD)) {
INTERESTING("BSD-2-Clause-NetBSD");
}
else if (INFILE(_SPDX_BSD_2_Clause_Patent)) {
INTERESTING("BSD-2-Clause-Patent");
}
else if (INFILE(_SPDX_BSD_2_Clause_1)) {
INTERESTING("BSD-2-Clause");
}
else if (INFILE(_SPDX_BSD_2_Clause_2)) {
INTERESTING("BSD-2-Clause");
}
else if (INFILE(_PHR_BSD_2_CLAUSE_1)
|| INFILE(_PHR_BSD_2_CLAUSE_2)
|| INFILE(_PHR_BSD_2_CLAUSE_3)
|| INFILE(_PHR_BSD_2_CLAUSE_4)
|| INFILE(_PHR_BSD_2_CLAUSE_5)
|| INFILE(_PHR_BSD_2_CLAUSE_6)) {
INTERESTING(lDebug ? "BSD(phr1/2/3/4/5/6)" : "BSD-2-Clause");
}
else if (INFILE(_SPDX_BSD_4_Clause_UC)) {
INTERESTING("BSD-4-Clause-UC");
}
else if (INFILE(_SPDX_BSD_4_Clause)) {
INTERESTING("BSD-4-Clause");
}
else if (INFILE(_PHR_BSD_4_CLAUSE_1)) {
INTERESTING(lDebug ? "BSD-4-Clause(phr1)" : "BSD-4-Clause");
}
else if (INFILE(_PHR_BSD_CLEAR_1)) {
INTERESTING(lDebug ? "BSD-Clear(phr1)" : "BSD-3-Clause-Clear");
}
else if (INFILE(_PHR_BSD_3_CLAUSE_LBNL)) {
INTERESTING("BSD-3-Clause-LBNL");
}
else if (INFILE(_SPDX_BSD_Protection)) {
INTERESTING("BSD-Protection");
}
else if (INFILE(_SPDX_BSD_Source_Code)) {
INTERESTING("BSD-Source-Code");
}
else if (INFILE(_SPDX_BSD_1_Clause)) {
INTERESTING("BSD-1-Clause");
}
else if (INFILE(_LT_BSDref1)) {
INTERESTING(lDebug ? "BSD(ref1)" : "BSD");
}
else if (INFILE(_LT_BSDref2)) {
INTERESTING(lDebug ? "BSD(ref2)" : "BSD");
}
else if (INFILE(_LT_BSDref3)) {
INTERESTING(lDebug ? "BSD(ref3)" : "BSD");
}
else if (INFILE(_LT_BSDref4)) {
INTERESTING(lDebug ? "BSD(ref4)" : "BSD");
}
else if (INFILE(_LT_BSDref5)) {
INTERESTING(lDebug ? "BSD(ref5)" : "BSD");
}
else if (INFILE(_LT_BSDref6)) {
INTERESTING(lDebug ? "BSD(ref6)" : "BSD");
}
else if (INFILE(_LT_BSDref7)) {
INTERESTING(lDebug ? "BSD(ref7)" : "BSD");
}
else if (INFILE(_LT_BSDref8)) {
INTERESTING(lDebug ? "BSD(ref8)" : "BSD");
}
else if (INFILE(_LT_BSDref9)) {
INTERESTING(lDebug ? "BSD(ref9)" : "BSD");