88 #include <sys/types.h>
93 #include "nomos_gap.h"
95 #include <semaphore.h>
101 #include "standalone.h"
104 #include <libfossdbmanager.h>
110 #ifdef MEMORY_TRACING
115 #define GPLV2_BEATS_GPLV3
116 #define SAVE_UNCLASSIFIED_LICENSES
119 #ifdef PROC_TRACE_SWITCH
123 #define myBUFSIZ 4096
124 #define MAX_RENAME 1000
125 #define TEMP_FILE_LEN 100
131 #define MAX_SCANBYTES 1024*1024
138 #define OPTS_DEBUG 0x1
139 #define OPTS_TRACE_SWITCH 0x2
140 #define OPTS_LONG_CMD_OUTPUT 0x4
141 #define OPTS_HIGHLIGHT_STDOUT 0x8
142 #define OPTS_NO_HIGHLIGHTINFO 0x10
143 #define OPTS_JSON_OUTPUT 0x20
144 #define OPTS_SCANNING_DIRECTORY 0x40
155 #define FL_SAVEBASE 0x20
156 #define FL_FRAGMENT 0x40
157 #define FL_SHOWMATCH 0x80
158 #define FL_NOCOPYRIGHT 0x100
163 #define FILE_FOUND "Found.txt"
164 #define FILE_SCORES "_scores"
165 #define DEBUGLOG "/tmp/NomosDebugLog"
179 #define SORT_BY_NAME 1
180 #define SORT_BY_NAME_ICASE 2
181 #define SORT_BY_COUNT_DSC 3
182 #define SORT_BY_COUNT_ASC 4
183 #define SORT_BY_ALIAS 5
184 #define SORT_BY_BASENAME 6
196 #define LTSR_RMASK ((char) 1)
197 #define LTSR_SMASK ((char) 2)
198 #define LTSR_YES ((char) 3)
199 #define LTSR_NO LTSR_SMASK
204 #define STR_NOTPKG "None (not an rpm-format package)"
215 #define LS_NONE "None"
216 #define LS_UNLIKELY "LikelyNot"
217 #define LS_NOSUM "No_license_found"
218 #define LS_UNCL "UnclassifiedLicense"
219 #define LS_NOT_PD "NOT-public-domain"
220 #define LS_PD_CLM "Public-domain"
221 #define LS_PD_CPRT "Public-domain(C)"
222 #define LS_PD_ONLY "Public-domain-ref"
223 #define LS_CPRTONLY "Misc-Copyright"
224 #define LS_TDMKONLY "Trademark-ref"
225 #define LS_LICRONLY "License-ref"
226 #define LS_PATRONLY "Patent-ref"
231 #define NULL_ITEM (item_t *) NULL
232 #define NULL_LIST (list_t *) NULL
233 #define NULL_FH (fh_t *) NULL
234 #define NULL_CHAR '\0'
235 #define NULL_STR (char *) NULL
240 #define isEOL(x) (((x == '\n') || (x == '\r') || (x == '\v')))
241 #define IS_HUGE(x) (x >= gl.blkUpperLimit)
245 #define NOMOS_TEMP "/tmp/nomos.tempdir"
246 #define NOMOS_TLOCK "/tmp/nomos.tempdir/.lock.tmp,"
288 #define foundTool val
294 #define isProcessed val2
354 #ifdef PROC_TRACE_SWITCH
419 GArray* docBufferPositionsAndOffsets;
420 int currentLicenceIndex;
447 #define _REGEX(x) licText[x].regex
451 #define _SEED(x) licText[x].tseed
473 #define MTAG_UNSORTKEY "list/str (initially-UNsorted key)"
474 #define MTAG_SORTKEY "list/str (initially-sorted key)"
475 #define MTAG_LISTKEY "list/str (sorted/unsorted key)"
476 #define MTAG_REPLKEY "list/str (replaced primary key)"
477 #define MTAG_LISTBUF "list/buf (any data)"
478 #define MTAG_PATHBASE "list/buf (path basename)"
479 #define MTAG_PKGINFO "list/buf (pkg rname/type/name/vers/lic)"
480 #define MTAG_PKG_NV "list/buf (pkg name/vers)"
481 #define MTAG_MD5SUM "list/buf (distro-arch MD5SUM)"
482 #define MTAG_COUNTER "list/buf integer (counter)"
483 #define MTAG_PKGNAME "list/buf (package-name)"
484 #define MTAG_PKGVERS "list/buf (package-vers)"
485 #define MTAG_CLAIMLIC "list/buf (claimlic copy)"
486 #define MTAG_COMPLIC "list/buf (pkg compLic copy)"
487 #define MTAG_URLCOPY "list/buf (pkg URL copy)"
488 #define MTAG_FILELIC "list/buf (file-license copy)"
489 #define MTAG_FIXNAME "list/buf (fixed-package name)"
493 #define MTAG_SEEDTEXT "search-seed text"
494 #define MTAG_SRCHTEXT "license-search text"
495 #define MTAG_MMAPFILE "mmap-file data"
496 #define MTAG_MAGICDATA "file magic description"
497 #define MTAG_PATTRS "pkg-attr buffer"
498 #define MTAG_DOUBLED "doubled (reallocated) data"
499 #define MTAG_SEARCHBUF "initial search-data buffer"
500 #define MTAG_TOOSMALL "too-small half-size buffer"
501 #define MTAG_TEXTPARA "paragraph text"
502 #define MTAG_LIST "dynamically-allocated list"
503 #define MTAG_ENV "environment variable"
504 #define MTAG_SCANRES "scan-results list"
510 void Bail(
int exitval);
525 #ifdef MEMORY_TRACING
526 char *memAllocTagged();
527 void memFreeTagged();
528 #define memFree(x,y) memFreeTagged(x, y)
529 #define memAlloc(x,y) memAllocTagged(x, y)
531 #define memFree(x,y) free(x)
532 #define memAlloc(x,y) calloc(x, 1)
539 #define DECL_TIMER struct timeval bTV, eTV; float proctime
540 #define ZERO_TIMER memcpy((void *) &bTV, (void *) &eTV, sizeof(eTV))
541 #define RESET_TIMER END_TIMER; ZERO_TIMER
542 #define START_TIMER RECORD_TIMER(bTV)
543 #define END_TIMER RECORD_TIMER(eTV) ; \
544 proctime = (float) (eTV.tv_sec - bTV.tv_sec) + \
545 ((float) (eTV.tv_usec - bTV.tv_usec) * 0.000001)
546 #define RECORD_TIMER(x) (void) gettimeofday(&x, (struct timezone *) NULL)
547 #define PRINT_TIMER(x,y) printf("%11.6f seconds: %s\n", proctime, x); \
548 if (y) { DUMP_TIMERS; }
549 #define DUMP_TIMERS printf("[1]: %d.%06d\n", bTV.tv_sec, bTV.tv_usec); \
550 printf("[2]: %d.%06d\n", eTV.tv_sec, eTV.tv_usec)
567 PRINT_TIMER(
"unpack", 0);
The main FOSSology C library.
#define myBUFSIZ
Buffer max length.
char debugStr[myBUFSIZ]
Debug string.
void Bail(int exitval)
Close connections and exit.
char saveLics[myBUFSIZ]
License string.
size_t hashEntries
Hash entries.
char dbErrString[myBUFSIZ]
DB error string.
int optionIsSet(int val)
Check if an CLI option is set.
GArray * matchPositions
Match positions.
GArray * indexList
License indexes.
char * licenceName
License names.
int licenseFileId
PFile id.
int start
Start position of match.
int index
Enums from index (Entrynumber) in STRINGS.in.
int end
End position of match.
Struct that tracks state related to current file being scanned.
GArray * keywordPositions
char targetFile[myBUFSIZ]
Structure holding data truly global in that it remains consistent for each file scanned.
PGconn * pgConn
DB Connection.
fo_dbManager * dbManager
FOSSology DB manager.
char initwd[myBUFSIZ]
CDB, would like to workaround/eliminate.
char progName[64]
Program name.
searchString_t text
License text.
searchString_t seed
License seed.
int len
Length of pattern.
char * patt
License pattern to use.
char * regex
License regex.
char * tseed
unencrypted license text
list_t type structure used to keep various lists. (e.g. there are multiple lists).
tricky data structure used for a list of 'items'
char label[myBUFSIZ]
Label.
void * mmPtr
Memory pointer.
int score
License match score.
char * csData
String data.