FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Utilities used by nomos. More...
Go to the source code of this file.
Functions | |
FUNCTION long | add2license_ref (char *licenseName) |
Add a new license to license_ref table. More... | |
FUNCTION long | lrcache_hash (cacheroot_t *pcroot, char *rf_shortname) |
calculate the hash of an rf_shortname rf_shortname is the key More... | |
FUNCTION void | lrcache_print (cacheroot_t *pcroot) |
Print the contents of the hash table. More... | |
FUNCTION void | lrcache_free (cacheroot_t *pcroot) |
free the hash table More... | |
FUNCTION int | lrcache_add (cacheroot_t *pcroot, long rf_pk, char *rf_shortname) |
add a rf_shortname, rf_pk to the license_ref cache rf_shortname is the key More... | |
FUNCTION long | lrcache_lookup (cacheroot_t *pcroot, char *rf_shortname) |
lookup rf_pk in the license_ref cache rf_shortname is the key More... | |
FUNCTION int | initLicRefCache (cacheroot_t *pcroot) |
build a cache the license ref db table. More... | |
FUNCTION long | get_rfpk (cacheroot_t *pcroot, char *rf_shortname) |
Get the rf_pk for rf_shortname. More... | |
FUNCTION char * | getFieldValue (char *inStr, char *field, int fieldMax, char *value, int valueMax, char separator) |
Given a string that contains field='value' pairs, save the items. More... | |
FUNCTION void | parseLicenseList () |
parse the comma separated list of license names found More... | |
FUNCTION void | Usage (char *Name) |
Print nomos usage help. More... | |
FUNCTION void | Bail (int exitval) |
Close connections and exit. More... | |
FUNCTION int | optionIsSet (int val) |
Check if an CLI option is set. More... | |
FUNCTION void | getFileLists (char *dirpath) |
Initialize the lists: regular-files list cur.regfList and buffer-offset list cur.offList. More... | |
FUNCTION long | updateLicenseFile (long rfPk) |
insert rf_fk, agent_fk and pfile_fk into license_file table More... | |
FUNCTION char | convertIndexToHighlightType (int index) |
Return the highlight type (K|L|0) for a given index. More... | |
FUNCTION int | updateLicenseHighlighting (cacheroot_t *pcroot) |
insert rf_fk, agent_fk, offset, len and type into highlight table More... | |
FUNCTION void | processFile (char *fileToScan) |
process a single file More... | |
void | setLicenseFileIdInHiglightArray (long licenseFileId, char *licenseName) |
Set the license file id to the highlights. More... | |
int | updateLicenseFileAndHighlightArray (char *licenseName, cacheroot_t *pcroot) |
Add a license to hash table, license table and highlight array. More... | |
FUNCTION int | recordScanToDB (cacheroot_t *pcroot, struct curScan *scanRecord) |
Write out the information about the scan to the FOSSology database. More... | |
FUNCTION MatchPositionAndType * | getMatchfromHighlightInfo (GArray *in, int index) |
Get the MatchPositionAndType for a given index in highlight array. More... | |
FUNCTION LicenceAndMatchPositions * | getLicenceAndMatchPositions (GArray *in, int index) |
Get the LicenceAndMatchPositions for a given index in match array. More... | |
FUNCTION void | initializeCurScan (struct curScan *cur) |
Initialize the scanner. More... | |
FUNCTION void | freeAndClearScan (struct curScan *thisScan) |
Clean-up all the per scan data structures, freeing any old data. More... | |
FUNCTION void | cleanTheMatches (GArray *theMatches) |
Cleans the match array and free the memory. More... | |
FUNCTION void | cleanLicenceAndMatchPositions (LicenceAndMatchPositions *in) |
Cleans the license and match positions object and free the memory. More... | |
FUNCTION void | addLicence (GArray *theMatches, char *licenceName) |
Add a license to the matches array. More... | |
void | cleanLicenceBuffer () |
Clean the license buffer. | |
bool | clearLastElementOfLicenceBuffer () |
Remove the last element from license buffer. More... | |
Variables | |
sem_t * | mutexJson |
Mutex to handle JSON writes. | |
gboolean * | printcomma |
True to print comma while printing JSON object. | |
char | saveLics [myBUFSIZ] |
License string. | |
Utilities used by nomos.
Definition in file nomos_utils.c.
FUNCTION long add2license_ref | ( | char * | licenseName | ) |
Add a new license to license_ref table.
Adds a license to license_ref table.
licenseName | Name of license |
Definition at line 34 of file nomos_utils.c.
|
inline |
Add a license to the matches array.
[in,out] | theMatches | The matches array |
[in] | licenceName | License to be added |
fill this later
Definition at line 991 of file nomos_utils.c.
FUNCTION void Bail | ( | int | exitval | ) |
Close connections and exit.
The function closes DB and scheduler connections and calls exit() with the return code passed
exitval | Return code to pass to exit() |
Definition at line 533 of file nomos_utils.c.
|
inline |
Cleans the license and match positions object and free the memory.
in | The matches object |
Definition at line 979 of file nomos_utils.c.
|
inline |
Cleans the match array and free the memory.
theMatches | The matches list |
Definition at line 966 of file nomos_utils.c.
|
inline |
Remove the last element from license buffer.
Definition at line 1014 of file nomos_utils.c.
FUNCTION char convertIndexToHighlightType | ( | int | index | ) |
Return the highlight type (K|L|0) for a given index.
index | Index to convert |
Definition at line 652 of file nomos_utils.c.
FUNCTION void freeAndClearScan | ( | struct curScan * | thisScan | ) |
Clean-up all the per scan data structures, freeing any old data.
thisScan | Scanner to clear |
Definition at line 941 of file nomos_utils.c.
FUNCTION long get_rfpk | ( | cacheroot_t * | pcroot, |
char * | rf_shortname | ||
) |
Get the rf_pk for rf_shortname.
Checks the cache to get the rf_pk for this shortname. If it doesn't exist, add it to both license_ref and the license_ref cache (the hash table).
pcroot | |
rf_shortname |
Definition at line 300 of file nomos_utils.c.
FUNCTION char* getFieldValue | ( | char * | inStr, |
char * | field, | ||
int | fieldMax, | ||
char * | value, | ||
int | valueMax, | ||
char | separator | ||
) |
Given a string that contains field='value' pairs, save the items.
Definition at line 333 of file nomos_utils.c.
FUNCTION void getFileLists | ( | char * | dirpath | ) |
Initialize the lists: regular-files list cur.regfList and buffer-offset list cur.offList.
Definition at line 580 of file nomos_utils.c.
|
inline |
Get the LicenceAndMatchPositions for a given index in match array.
in | Match array |
index | Index to fetch |
Definition at line 913 of file nomos_utils.c.
|
inline |
Get the MatchPositionAndType for a given index in highlight array.
in | Highlight array |
index | Index to fetch |
Definition at line 901 of file nomos_utils.c.
FUNCTION void initializeCurScan | ( | struct curScan * | cur | ) |
Initialize the scanner.
Creates a new index list, match list, keyword position list, doctored buffer and license index
cur | Current scanner |
Definition at line 926 of file nomos_utils.c.
FUNCTION int initLicRefCache | ( | cacheroot_t * | pcroot | ) |
build a cache the license ref db table.
initLicRefCache builds a cache using the rf_shortname as the key and the rf_pk as the value. This is an optimization. The cache is used for reference license lookups instead of querying the db.
pcroot |
Definition at line 260 of file nomos_utils.c.
FUNCTION int lrcache_add | ( | cacheroot_t * | pcroot, |
long | rf_pk, | ||
char * | rf_shortname | ||
) |
add a rf_shortname, rf_pk to the license_ref cache rf_shortname is the key
Add a rf_shortname, rf_pk to the license_ref cache rf_shortname is the key.
Definition at line 185 of file nomos_utils.c.
FUNCTION void lrcache_free | ( | cacheroot_t * | pcroot | ) |
free the hash table
Free the hash table.
pcroot | Table root |
Definition at line 158 of file nomos_utils.c.
FUNCTION long lrcache_hash | ( | cacheroot_t * | pcroot, |
char * | rf_shortname | ||
) |
calculate the hash of an rf_shortname rf_shortname is the key
Calculate the hash of an rf_shortname rf_shortname is the key.
pcroot | Root pointer |
rf_shortname |
Definition at line 113 of file nomos_utils.c.
FUNCTION long lrcache_lookup | ( | cacheroot_t * | pcroot, |
char * | rf_shortname | ||
) |
lookup rf_pk in the license_ref cache rf_shortname is the key
Lookup rf_pk in the license_ref cache rf_shortname is the key.
pcroot | |
rf_shortname |
Definition at line 222 of file nomos_utils.c.
FUNCTION void lrcache_print | ( | cacheroot_t * | pcroot | ) |
Print the contents of the hash table.
pcroot | Table root |
Definition at line 133 of file nomos_utils.c.
FUNCTION int optionIsSet | ( | int | val | ) |
Check if an CLI option is set.
val | Binary position to check |
Definition at line 560 of file nomos_utils.c.
FUNCTION void parseLicenseList | ( | ) |
parse the comma separated list of license names found
Uses cur.compLic and sets cur.licenseList
Definition at line 450 of file nomos_utils.c.
FUNCTION void processFile | ( | char * | fileToScan | ) |
FUNCTION int recordScanToDB | ( | cacheroot_t * | pcroot, |
struct curScan * | scanRecord | ||
) |
Write out the information about the scan to the FOSSology database.
curScan is passed as an arg even though it's available as a global, in order to facilitate future modularization of the code.
Definition at line 850 of file nomos_utils.c.
void setLicenseFileIdInHiglightArray | ( | long | licenseFileId, |
char * | licenseName | ||
) |
Set the license file id to the highlights.
Definition at line 814 of file nomos_utils.c.
FUNCTION long updateLicenseFile | ( | long | rfPk | ) |
insert rf_fk, agent_fk and pfile_fk into license_file table
rfPK | the reference file foreign key |
Definition at line 606 of file nomos_utils.c.
int updateLicenseFileAndHighlightArray | ( | char * | licenseName, |
cacheroot_t * | pcroot | ||
) |
Add a license to hash table, license table and highlight array.
licenseName | License name |
pcroot | Hash table root |
Definition at line 829 of file nomos_utils.c.
FUNCTION int updateLicenseHighlighting | ( | cacheroot_t * | pcroot | ) |
insert rf_fk, agent_fk, offset, len and type into highlight table
pcroot | The root of hash table |
the license File ID was never set and we should not insert it in the database
Definition at line 676 of file nomos_utils.c.
FUNCTION void Usage | ( | char * | Name | ) |
Print nomos usage help.
Say how to run this program.
Name | Path to nomos binary |
Definition at line 509 of file nomos_utils.c.