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