FOSSology  4.4.0
Open Source License Compliance by Open Source Software
nomos.h File Reference

Nomos header file. More...

#include <glib.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <search.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <dirent.h>
#include <ftw.h>
#include <regex.h>
#include <getopt.h>
#include <time.h>
#include <libgen.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/time.h>
#include "nomos_gap.h"
#include <stdbool.h>
#include <semaphore.h>
#include "json_writer.h"
#include <libfossology.h>
#include <libfossdbmanager.h>
Include dependency graph for nomos.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mm_cache
 
struct  listitem
 tricky data structure used for a list of 'items' More...
 
struct  list
 list_t type structure used to keep various lists. (e.g. there are multiple lists). More...
 
struct  searchString
 
struct  licenseSpec
 
struct  globals
 Structure holding data truly global in that it remains consistent for each file scanned. More...
 
struct  MatchPositionAndType
 
struct  LicenceAndMatchPositions
 
struct  curScan
 Struct that tracks state related to current file being scanned. More...
 
struct  license
 
struct  licensetext
 
struct  scanResults
 

Macros

#define _GNU_SOURCE
 
#define PRECHECK
 
#define GPLV2_BEATS_GPLV3
 
#define SAVE_UNCLASSIFIED_LICENSES
 
#define myBUFSIZ   4096
 Buffer max length.
 
#define MAX_RENAME   1000
 Max rename length.
 
#define TEMP_FILE_LEN   100
 Max temp file length.
 
#define MAX_SCANBYTES   1024*1024
 
#define OPTS_DEBUG   0x1
 
#define OPTS_TRACE_SWITCH   0x2
 
#define OPTS_LONG_CMD_OUTPUT   0x4
 
#define OPTS_HIGHLIGHT_STDOUT   0x8
 
#define OPTS_NO_HIGHLIGHTINFO   0x10
 
#define OPTS_JSON_OUTPUT   0x20
 
#define OPTS_SCANNING_DIRECTORY   0x40
 
#define FL_SAVEBASE   0x20
 
#define FL_FRAGMENT   0x40
 
#define FL_SHOWMATCH   0x80
 
#define FL_NOCOPYRIGHT   0x100
 
#define FILE_FOUND   "Found.txt"
 
#define FILE_SCORES   "_scores"
 
#define DEBUGLOG   "/tmp/NomosDebugLog"
 
#define NO   0
 
#define YES   1
 
#define UNSORTED   0
 
#define SORT_BY_NAME   1
 
#define SORT_BY_NAME_ICASE   2
 
#define SORT_BY_COUNT_DSC   3
 
#define SORT_BY_COUNT_ASC   4
 
#define SORT_BY_ALIAS   5
 
#define SORT_BY_BASENAME   6
 
#define IL_HIGH   3
 
#define IL_MED   2
 
#define IL_LOW   1
 
#define IL_NONE   0
 
#define IL_INIT   -1
 
#define LTSR_RMASK   ((char) 1)
 
#define LTSR_SMASK   ((char) 2)
 
#define LTSR_YES   ((char) 3)
 
#define LTSR_NO   LTSR_SMASK
 
#define STR_NOTPKG   "None (not an rpm-format package)"
 
#define _scCOMFORT   9
 
#define _scINVALID   4
 
#define LS_NONE   "None"
 
#define LS_UNLIKELY   "LikelyNot"
 
#define LS_NOSUM   "No_license_found"
 
#define LS_UNCL   "UnclassifiedLicense"
 
#define LS_NOT_PD   "NOT-public-domain"
 
#define LS_PD_CLM   "Public-domain"
 
#define LS_PD_CPRT   "Public-domain(C)"
 
#define LS_PD_ONLY   "Public-domain-ref"
 
#define LS_CPRTONLY   "Misc-Copyright"
 
#define LS_TDMKONLY   "Trademark-ref"
 
#define LS_LICRONLY   "License-ref"
 
#define LS_PATRONLY   "Patent-ref"
 
#define NULL_ITEM   (item_t *) NULL
 NULL item.
 
#define NULL_LIST   (list_t *) NULL
 NULL list.
 
#define NULL_FH   (fh_t *) NULL
 NULL fh.
 
#define NULL_CHAR   '\0'
 NULL character.
 
#define NULL_STR   (char *) NULL
 NULL string.
 
#define isEOL(x)   (((x == '\n') || (x == '\r') || (x == '\v')))
 Check if x points to a EOL character. More...
 
#define IS_HUGE(x)   (x >= gl.blkUpperLimit)
 
#define NOMOS_TEMP   "/tmp/nomos.tempdir"
 
#define NOMOS_TLOCK   "/tmp/nomos.tempdir/.lock.tmp,"
 
#define seqNo   val
 
#define foundTool   val
 
#define refCount   val
 
#define num   val
 
#define bStart   val
 
#define iFlag   val
 
#define ssComp   val2
 
#define isProcessed   val2
 
#define iLevel   val2
 
#define nMatch   val2
 
#define bLen   val2
 
#define bDocLen   val3
 
#define bIndex   val3
 
#define bList   buf
 
#define _REGEX(x)   licText[x].regex
 
#define _SEED(x)   licText[x].tseed
 
#define MTAG_UNSORTKEY   "list/str (initially-UNsorted key)"
 
#define MTAG_SORTKEY   "list/str (initially-sorted key)"
 
#define MTAG_LISTKEY   "list/str (sorted/unsorted key)"
 
#define MTAG_REPLKEY   "list/str (replaced primary key)"
 
#define MTAG_LISTBUF   "list/buf (any data)"
 
#define MTAG_PATHBASE   "list/buf (path basename)"
 
#define MTAG_PKGINFO   "list/buf (pkg rname/type/name/vers/lic)"
 
#define MTAG_PKG_NV   "list/buf (pkg name/vers)"
 
#define MTAG_MD5SUM   "list/buf (distro-arch MD5SUM)"
 
#define MTAG_COUNTER   "list/buf integer (counter)"
 
#define MTAG_PKGNAME   "list/buf (package-name)"
 
#define MTAG_PKGVERS   "list/buf (package-vers)"
 
#define MTAG_CLAIMLIC   "list/buf (claimlic copy)"
 
#define MTAG_COMPLIC   "list/buf (pkg compLic copy)"
 
#define MTAG_URLCOPY   "list/buf (pkg URL copy)"
 
#define MTAG_FILELIC   "list/buf (file-license copy)"
 
#define MTAG_FIXNAME   "list/buf (fixed-package name)"
 
#define MTAG_SEEDTEXT   "search-seed text"
 
#define MTAG_SRCHTEXT   "license-search text"
 
#define MTAG_MMAPFILE   "mmap-file data"
 
#define MTAG_MAGICDATA   "file magic description"
 
#define MTAG_PATTRS   "pkg-attr buffer"
 
#define MTAG_DOUBLED   "doubled (reallocated) data"
 
#define MTAG_SEARCHBUF   "initial search-data buffer"
 
#define MTAG_TOOSMALL   "too-small half-size buffer"
 
#define MTAG_TEXTPARA   "paragraph text"
 
#define MTAG_LIST   "dynamically-allocated list"
 
#define MTAG_ENV   "environment variable"
 
#define MTAG_SCANRES   "scan-results list"
 
#define memFree(x, y)   free(x)
 
#define memAlloc(x, y)   calloc(x, 1)
 
#define DECL_TIMER   struct timeval bTV, eTV; float proctime
 
#define ZERO_TIMER   memcpy((void *) &bTV, (void *) &eTV, sizeof(eTV))
 
#define RESET_TIMER   END_TIMER; ZERO_TIMER
 
#define START_TIMER   RECORD_TIMER(bTV)
 
#define END_TIMER
 
#define RECORD_TIMER(x)   (void) gettimeofday(&x, (struct timezone *) NULL)
 
#define PRINT_TIMER(x, y)
 
#define DUMP_TIMERS
 

Typedefs

typedef struct listitem item_t
 
typedef struct list list_t
 
typedef struct searchString searchString_t
 
typedef struct licenseSpec licSpec_t
 
typedef struct licensetext licText_t
 
typedef struct scanResults scanres_t
 

Functions

void Bail (int exitval)
 Close connections and exit. More...
 
int optionIsSet (int val)
 Check if an CLI option is set. More...
 

Variables

char debugStr [myBUFSIZ]
 Debug string.
 
char dbErrString [myBUFSIZ]
 DB error string.
 
char saveLics [myBUFSIZ]
 License string.
 
size_t hashEntries
 Hash entries.
 
struct globals gl
 
struct curScan cur
 
licText_t licText []
 
licSpec_t licSpec []
 
int schedulerMode
 

Detailed Description

Nomos header file.

Definition in file nomos.h.

Macro Definition Documentation

◆ _REGEX

#define _REGEX (   x)    licText[x].regex

Get regex of a license text

Definition at line 447 of file nomos.h.

◆ _scCOMFORT

#define _scCOMFORT   9

>= 9 --> certain it's a license

Definition at line 209 of file nomos.h.

◆ _scINVALID

#define _scINVALID   4

< 4 --> probably NOT a license

Definition at line 210 of file nomos.h.

◆ _SEED

#define _SEED (   x)    licText[x].tseed

Get seed of a license text

Definition at line 451 of file nomos.h.

◆ DUMP_TIMERS

#define DUMP_TIMERS
Value:
printf("[1]: %d.%06d\n", bTV.tv_sec, bTV.tv_usec); \
printf("[2]: %d.%06d\n", eTV.tv_sec, eTV.tv_usec)

Definition at line 549 of file nomos.h.

◆ END_TIMER

#define END_TIMER
Value:
RECORD_TIMER(eTV) ; \
proctime = (float) (eTV.tv_sec - bTV.tv_sec) + \
((float) (eTV.tv_usec - bTV.tv_usec) * 0.000001)

Definition at line 543 of file nomos.h.

◆ FILE_FOUND

#define FILE_FOUND   "Found.txt"

Names of various files/dirs created/used

Definition at line 163 of file nomos.h.

◆ FL_SAVEBASE

#define FL_SAVEBASE   0x20

Flags for program control

Definition at line 155 of file nomos.h.

◆ isEOL

#define isEOL (   x)    (((x == '\n') || (x == '\r') || (x == '\v')))

Check if x points to a EOL character.

Macros needed across >1 source module

Definition at line 240 of file nomos.h.

◆ LS_NONE

#define LS_NONE   "None"

LS_ = License Summaries/Strings

Definition at line 215 of file nomos.h.

◆ LTSR_NO

#define LTSR_NO   LTSR_SMASK

Searched but not matched

Definition at line 199 of file nomos.h.

◆ LTSR_RMASK

#define LTSR_RMASK   ((char) 1)

license-text search results (ltsr) stuff True if it's been matched

Definition at line 196 of file nomos.h.

◆ LTSR_SMASK

#define LTSR_SMASK   ((char) 2)

True if it's been searched for

Definition at line 197 of file nomos.h.

◆ LTSR_YES

#define LTSR_YES   ((char) 3)

Both searched, and matched

Definition at line 198 of file nomos.h.

◆ MAX_SCANBYTES

#define MAX_SCANBYTES   1024*1024

MAX_SCANBYTES is the maximum number of bytes that will be scanned in a file. Historically, we have never found a license more than 64k into a file.

Definition at line 131 of file nomos.h.

◆ memFree

#define memFree (   x,
 
)    free(x)

Declarations for using the memory debug stuff

Definition at line 531 of file nomos.h.

◆ MTAG_SEEDTEXT

#define MTAG_SEEDTEXT   "search-seed text"

Miscellaneous memory tags

Definition at line 493 of file nomos.h.

◆ MTAG_UNSORTKEY

#define MTAG_UNSORTKEY   "list/str (initially-UNsorted key)"

List-based memory tags

Definition at line 473 of file nomos.h.

◆ NO

#define NO   0

Symbolic Boolean value for NO

Definition at line 171 of file nomos.h.

◆ NOMOS_TLOCK

#define NOMOS_TLOCK   "/tmp/nomos.tempdir/.lock.tmp,"

CDB, This goes away.

Definition at line 246 of file nomos.h.

◆ OPTS_DEBUG

#define OPTS_DEBUG   0x1

Program options and flags

MD: I think these are used when making nomos

Definition at line 138 of file nomos.h.

◆ PRECHECK

#define PRECHECK

Use nomos in standalone mode (no FOSSology DB) To use our local version of debug-malloc(), compile -DMEMORY_TRACING

Definition at line 114 of file nomos.h.

◆ PRINT_TIMER

#define PRINT_TIMER (   x,
 
)
Value:
printf("%11.6f seconds: %s\n", proctime, x); \
if (y) { DUMP_TIMERS; }

Definition at line 547 of file nomos.h.

◆ seqNo

#define seqNo   val

Defines for the list val fields

Definition at line 287 of file nomos.h.

◆ STR_NOTPKG

#define STR_NOTPKG   "None (not an rpm-format package)"

Miscellaneous strings used in various modules

Definition at line 204 of file nomos.h.

◆ YES

#define YES   1

Symbolic Boolean value for YES

Definition at line 175 of file nomos.h.

Function Documentation

◆ Bail()

void Bail ( int  exitval)

Close connections and exit.

The function closes DB and scheduler connections and calls exit() with the return code passed

Parameters
exitvalReturn code to pass to exit()

Definition at line 533 of file nomos_utils.c.

◆ optionIsSet()

int optionIsSet ( int  val)

Check if an CLI option is set.

Parameters
valBinary position to check
Returns
> 0 if it is set, 0 otherwise

Definition at line 560 of file nomos_utils.c.

Variable Documentation

◆ schedulerMode

int schedulerMode
extern

Non-zero when being run from scheduler

Definition at line 33 of file nomos.c.