99 #include <sys/types.h> 100 #include <sys/stat.h> 101 #include <sys/wait.h> 102 #include <sys/mman.h> 103 #include <sys/time.h> 104 #include "nomos_gap.h" 106 #include <semaphore.h> 112 #include "standalone.h" 115 #include <libfossdbmanager.h> 123 #ifdef MEMORY_TRACING 128 #define GPLV2_BEATS_GPLV3 129 #define SAVE_UNCLASSIFIED_LICENSES 132 #ifdef PROC_TRACE_SWITCH 136 #define myBUFSIZ 4096 137 #define MAX_RENAME 1000 138 #define TEMP_FILE_LEN 100 144 #define MAX_SCANBYTES 1024*1024 151 #define OPTS_DEBUG 0x1 152 #define OPTS_TRACE_SWITCH 0x2 153 #define OPTS_LONG_CMD_OUTPUT 0x4 154 #define OPTS_HIGHLIGHT_STDOUT 0x8 155 #define OPTS_NO_HIGHLIGHTINFO 0x10 156 #define OPTS_JSON_OUTPUT 0x20 157 #define OPTS_SCANNING_DIRECTORY 0x40 168 #define FL_SAVEBASE 0x20 169 #define FL_FRAGMENT 0x40 170 #define FL_SHOWMATCH 0x80 171 #define FL_NOCOPYRIGHT 0x100 176 #define FILE_FOUND "Found.txt" 177 #define FILE_SCORES "_scores" 178 #define DEBUGLOG "/tmp/NomosDebugLog" 192 #define SORT_BY_NAME 1 193 #define SORT_BY_NAME_ICASE 2 194 #define SORT_BY_COUNT_DSC 3 195 #define SORT_BY_COUNT_ASC 4 196 #define SORT_BY_ALIAS 5 197 #define SORT_BY_BASENAME 6 209 #define LTSR_RMASK ((char) 1) 210 #define LTSR_SMASK ((char) 2) 211 #define LTSR_YES ((char) 3) 212 #define LTSR_NO LTSR_SMASK 217 #define STR_NOTPKG "None (not an rpm-format package)" 228 #define LS_NONE "None" 229 #define LS_UNLIKELY "LikelyNot" 230 #define LS_NOSUM "No_license_found" 231 #define LS_UNCL "UnclassifiedLicense" 232 #define LS_NOT_PD "NOT-public-domain" 233 #define LS_PD_CLM "Public-domain" 234 #define LS_PD_CPRT "Public-domain(C)" 235 #define LS_PD_ONLY "Public-domain-ref" 236 #define LS_CPRTONLY "Misc-Copyright" 237 #define LS_TDMKONLY "Trademark-ref" 238 #define LS_LICRONLY "License-ref" 239 #define LS_PATRONLY "Patent-ref" 244 #define NULL_ITEM (item_t *) NULL 245 #define NULL_LIST (list_t *) NULL 246 #define NULL_FH (fh_t *) NULL 247 #define NULL_CHAR '\0' 248 #define NULL_STR (char *) NULL 253 #define isEOL(x) (((x == '\n') || (x == '\r') || (x == '\v'))) 254 #define IS_HUGE(x) (x >= gl.blkUpperLimit) 258 #define NOMOS_TEMP "/tmp/nomos.tempdir" 259 #define NOMOS_TLOCK "/tmp/nomos.tempdir/.lock.tmp," 301 #define foundTool val 307 #define isProcessed val2 367 #ifdef PROC_TRACE_SWITCH 427 char *licenseList[512];
432 GArray* docBufferPositionsAndOffsets;
433 int currentLicenceIndex;
460 #define _REGEX(x) licText[x].regex 464 #define _SEED(x) licText[x].tseed 486 #define MTAG_UNSORTKEY "list/str (initially-UNsorted key)" 487 #define MTAG_SORTKEY "list/str (initially-sorted key)" 488 #define MTAG_LISTKEY "list/str (sorted/unsorted key)" 489 #define MTAG_REPLKEY "list/str (replaced primary key)" 490 #define MTAG_LISTBUF "list/buf (any data)" 491 #define MTAG_PATHBASE "list/buf (path basename)" 492 #define MTAG_PKGINFO "list/buf (pkg rname/type/name/vers/lic)" 493 #define MTAG_PKG_NV "list/buf (pkg name/vers)" 494 #define MTAG_MD5SUM "list/buf (distro-arch MD5SUM)" 495 #define MTAG_COUNTER "list/buf integer (counter)" 496 #define MTAG_PKGNAME "list/buf (package-name)" 497 #define MTAG_PKGVERS "list/buf (package-vers)" 498 #define MTAG_CLAIMLIC "list/buf (claimlic copy)" 499 #define MTAG_COMPLIC "list/buf (pkg compLic copy)" 500 #define MTAG_URLCOPY "list/buf (pkg URL copy)" 501 #define MTAG_FILELIC "list/buf (file-license copy)" 502 #define MTAG_FIXNAME "list/buf (fixed-package name)" 506 #define MTAG_SEEDTEXT "search-seed text" 507 #define MTAG_SRCHTEXT "license-search text" 508 #define MTAG_MMAPFILE "mmap-file data" 509 #define MTAG_MAGICDATA "file magic description" 510 #define MTAG_PATTRS "pkg-attr buffer" 511 #define MTAG_DOUBLED "doubled (reallocated) data" 512 #define MTAG_SEARCHBUF "initial search-data buffer" 513 #define MTAG_TOOSMALL "too-small half-size buffer" 514 #define MTAG_TEXTPARA "paragraph text" 515 #define MTAG_LIST "dynamically-allocated list" 516 #define MTAG_ENV "environment variable" 517 #define MTAG_SCANRES "scan-results list" 523 void Bail(
int exitval);
538 #ifdef MEMORY_TRACING 539 char *memAllocTagged();
540 void memFreeTagged();
541 #define memFree(x,y) memFreeTagged(x, y) 542 #define memAlloc(x,y) memAllocTagged(x, y) 544 #define memFree(x,y) free(x) 545 #define memAlloc(x,y) calloc(x, 1) 552 #define DECL_TIMER struct timeval bTV, eTV; float proctime 553 #define ZERO_TIMER memcpy((void *) &bTV, (void *) &eTV, sizeof(eTV)) 554 #define RESET_TIMER END_TIMER; ZERO_TIMER 555 #define START_TIMER RECORD_TIMER(bTV) 556 #define END_TIMER RECORD_TIMER(eTV) ; \ 557 proctime = (float) (eTV.tv_sec - bTV.tv_sec) + \ 558 ((float) (eTV.tv_usec - bTV.tv_usec) * 0.000001) 559 #define RECORD_TIMER(x) (void) gettimeofday(&x, (struct timezone *) NULL) 560 #define PRINT_TIMER(x,y) printf("%11.6f seconds: %s\n", proctime, x); \ 561 if (y) { DUMP_TIMERS; } 562 #define DUMP_TIMERS printf("[1]: %d.%06d\n", bTV.tv_sec, bTV.tv_usec); \ 563 printf("[2]: %d.%06d\n", eTV.tv_sec, eTV.tv_usec) 580 PRINT_TIMER(
"unpack", 0);
int len
Length of pattern.
int optionIsSet(int val)
Check if an CLI option is set.
tricky data structure used for a list of 'items'
searchString_t text
License text.
char * tseed
unencrypted license text
Structure holding data truly global in that it remains consistent for each file scanned.
int score
License match score.
GArray * matchPositions
Match positions.
void Bail(int exitval)
Close connections and exit.
int start
Start position of match.
char * patt
License pattern to use.
char * csData
String data.
fo_dbManager * dbManager
FOSSology DB manager.
searchString_t seed
License seed.
char debugStr[myBUFSIZ]
Debug string.
char * licenceName
License names.
The main FOSSology C library.
int index
Enums from index (Entrynumber) in STRINGS.in.
char dbErrString[myBUFSIZ]
DB error string.
size_t hashEntries
Hash entries.
int end
End position of match.
#define myBUFSIZ
Buffer max length.
list_t type structure used to keep various lists. (e.g. there are multiple lists).
GArray * indexList
License indexes.
void * mmPtr
Memory pointer.
Struct that tracks state related to current file being scanned.
char * regex
License regex.
GArray * keywordPositions
char saveLics[myBUFSIZ]
License string.
int licenseFileId
PFile id.
PGconn * pgConn
DB Connection.