18 #include "nomos_regex.h"
19 #include <_autodefs.h>
21 #define PG_ERRCODE_UNIQUE_VIOLATION "23505"
22 #define FOSSY_EXIT( XY , XZ) printf(" %s %s,%d", XY , __FILE__, __LINE__); Bail( XZ );
23 #define LICENSE_REF_TABLE "ONLY license_ref"
24 #define SEM_DEFAULT_VALUE 4
47 char *
getFieldValue(
char *inStr,
char *field,
int fieldMax,
char *value,
int valueMax,
char separator);
49 void Usage(
char *Name);
50 void Bail(
int exitval);
66 void addLicence(GArray* theMatches,
char* licenceName );
Usage()
Print Usage statement.
FUNCTION void lrcache_free(cacheroot_t *pcroot)
Free the hash table.
FUNCTION long lrcache_lookup(cacheroot_t *pcroot, char *rf_shortname)
Lookup rf_pk in the license_ref cache rf_shortname is the key.
FUNCTION long add2license_ref(PGconn *pgConn, char *licenseName)
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.
FUNCTION long get_rfpk(PGconn *pgConn, cacheroot_t *pcroot, char *rf_shortname)
Get the rf_pk for rf_shortname.
FUNCTION long lrcache_hash(cacheroot_t *pcroot, char *rf_shortname)
Calculate the hash of an rf_shortname rf_shortname is the key.
void Bail(int exitval)
Close connections and exit.
int optionIsSet(int val)
Check if an CLI option is set.
FUNCTION void freeAndClearScan(struct curScan *thisScan)
Clean-up all the per scan data structures, freeing any old data.
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.
sem_t * mutexJson
Mutex to handle JSON writes.
FUNCTION void cleanTheMatches(GArray *theMatches)
Cleans the match array and free the memory.
FUNCTION void parseLicenseList()
parse the comma separated list of license names found
FUNCTION long updateLicenseFile(long rfPk)
insert rf_fk, agent_fk and pfile_fk into license_file table
FUNCTION void initializeCurScan(struct curScan *cur)
Initialize the scanner.
FUNCTION int recordScanToDB(cacheroot_t *pcroot, struct curScan *scanRecord)
Write out the information about the scan to the FOSSology database.
void cleanLicenceBuffer()
Clean the license buffer.
FUNCTION void addLicence(GArray *theMatches, char *licenceName)
Add a license to the matches array.
FUNCTION MatchPositionAndType * getMatchfromHighlightInfo(GArray *in, int index)
Get the MatchPositionAndType for a given index in highlight array.
FUNCTION void getFileLists(char *dirpath)
Initialize the lists: regular-files list cur.regfList and buffer-offset list cur.offList.
FUNCTION LicenceAndMatchPositions * getLicenceAndMatchPositions(GArray *in, int index)
Get the LicenceAndMatchPositions for a given index in match array.
gboolean * printcomma
True to print comma while printing JSON object.
FUNCTION void cleanLicenceAndMatchPositions(LicenceAndMatchPositions *in)
Cleans the license and match positions object and free the memory.
FUNCTION int initLicRefCache(cacheroot_t *pcroot)
build a cache the license ref db table.
bool clearLastElementOfLicenceBuffer()
Remove the last element from license buffer.
FUNCTION char convertIndexToHighlightType(int index)
Return the highlight type (K|L|0) for a given index.
FUNCTION int updateLicenseHighlighting(cacheroot_t *pcroot)
insert rf_fk, agent_fk, offset, len and type into highlight table
long rf_pk
License id from database.
char * rf_shortname
License shortname.
int maxnodes
No. of nodes in the list.
cachenode_t * nodes
Array of nodes.
Struct that tracks state related to current file being scanned.
FUNCTION int processFile(PGconn *pgConn, pbucketdef_t bucketDefArray, puploadtree_t puploadtree, int agent_pk, int hasPrules)
Process a file.